more configuration cleanup and modularization

This commit is contained in:
Douze Bé 2024-12-19 18:22:19 +01:00
parent 0700b75f3e
commit 0791356a34
4 changed files with 92 additions and 97 deletions

View file

@ -6,6 +6,7 @@
./hardware-configuration.nix ./hardware-configuration.nix
/var/src/modules/nixin.nix /var/src/modules/nixin.nix
/var/src/modules/users.nix /var/src/modules/users.nix
/var/src/modules/wireguard-client.nix
]; ];
# Bootloader. # Bootloader.
@ -25,25 +26,11 @@
address = "10.0.0.1"; address = "10.0.0.1";
prefixLength = 24; prefixLength = 24;
} ]; } ];
nameservers = [ "80.67.169.12" "80.67.169.40" "2001:910:800::12" "2001:910:800::40" ]; };
enableIPv6 = true;
# wireguard VPN to be reachable from internet
wg-quick.interfaces = {
wg0 = {
address = [ "192.168.12.2/32" "2a01:4f9:1a:9a05::2/128" ];
dns = [ "80.67.169.12" "80.67.169.40" "2001:910:800::12" "2001:910:800::40" ];
privateKeyFile = "/var/src/secrets/wg-private.key";
peers = [ nixin.wg.client = {
{ ipv4 = "192.168.12.2/32";
publicKey = "cUmp55I20JEhxr+RMmOsX+6U9kcDiAq3grnvzjQ642w="; ipv6 = "2a01:4f9:1a:9a05::2/128";
allowedIPs = [ "0.0.0.0/0" "::/0" ];
endpoint = "vpn.lab12.fr:51812";
persistentKeepalive = 15;
}
];
};
};
}; };
# Enable ip forwarding to route packets for the local network connected to enp3s0 # Enable ip forwarding to route packets for the local network connected to enp3s0
@ -53,32 +40,14 @@
}; };
# Open ports in the firewall. # Open ports in the firewall.
# Or disable the firewall altogether.
# networking.firewall.enable = false;
networking.firewall.allowedTCPPorts = [ 80 144 443 ]; networking.firewall.allowedTCPPorts = [ 80 144 443 ];
#networking.firewall.allowedUDPPorts = [ 53 ]; #networking.firewall.allowedUDPPorts = [ 53 ];
# allow UDP port range for mosh # allow UDP port range for mosh
networking.firewall.allowedUDPPortRanges = [ networking.firewall.allowedUDPPortRanges = [
{ from = 60000; to = 61000; } { from = 60000; to = 61000; }
]; ];
# Or disable the firewall altogether.
# Set your time zone. # networking.firewall.enable = false;
time.timeZone = "Etc/UTC";
# Select internationalisation properties.
i18n.defaultLocale = "fr_FR.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "fr_FR.UTF-8";
LC_IDENTIFICATION = "fr_FR.UTF-8";
LC_MEASUREMENT = "fr_FR.UTF-8";
LC_MONETARY = "fr_FR.UTF-8";
LC_NAME = "fr_FR.UTF-8";
LC_NUMERIC = "fr_FR.UTF-8";
LC_PAPER = "fr_FR.UTF-8";
LC_TELEPHONE = "fr_FR.UTF-8";
LC_TIME = "fr_FR.UTF-8";
};
# Configure console keymap # Configure console keymap
console.keyMap = "fr"; console.keyMap = "fr";
@ -86,25 +55,10 @@
# Allow unfree packages # Allow unfree packages
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
# vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
git
wget
tmux
htop
mosh
dig
mtr mtr
]; ];
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
};
# This value determines the NixOS release from which the default # This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions # settings for stateful data, like file locations and database versions
# on your system were taken. It's perfectly fine and recommended to leave # on your system were taken. It's perfectly fine and recommended to leave

View file

@ -10,6 +10,7 @@
./hardware-configuration.nix ./hardware-configuration.nix
/var/src/modules/nixin.nix /var/src/modules/nixin.nix
/var/src/modules/users.nix /var/src/modules/users.nix
/var/src/modules/wireguard-client.nix
]; ];
hardware.sensor.hddtemp.enable = true; hardware.sensor.hddtemp.enable = true;
@ -29,48 +30,20 @@
prefixLength = 24; prefixLength = 24;
} ]; } ];
defaultGateway = "192.168.36.1"; defaultGateway = "192.168.36.1";
nameservers = [ "80.67.169.12" "80.67.169.40" "2001:910:800::12" "2001:910:800::40" ];
enableIPv6 = true;
wg-quick.interfaces = {
wg0 = {
address = [ "192.168.12.3/32" "2a01:4f9:1a:9a05::3/128" ];
dns = [ "80.67.169.12" "80.67.169.40" "2001:910:800::12" "2001:910:800::40" ];
privateKeyFile = "/var/src/secrets/wg-private.key";
peers = [
{
publicKey = "cUmp55I20JEhxr+RMmOsX+6U9kcDiAq3grnvzjQ642w=";
allowedIPs = [ "0.0.0.0/0" "::/0" ];
endpoint = "vpn.lab12.fr:51812";
persistentKeepalive = 15;
}
];
};
};
}; };
# Set your time zone. nixin.wg.client = {
time.timeZone = "Europe/Paris"; ipv4 = "192.168.12.3/32";
ipv6 = "2a01:4f9:1a:9a05::3/128";
};
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
console = { console = {
font = "Lat2-Terminus16"; font = "Lat2-Terminus16";
keyMap = "fr"; keyMap = "fr";
#useXkbConfig = true; # use xkb.options in tty. #useXkbConfig = true; # use xkb.options in tty.
}; };
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
git
wget
tmux
htop
memtester memtester
# Useful podman development tools # Useful podman development tools
#dive # look into docker image layers #dive # look into docker image layers
@ -83,12 +56,6 @@
# Some programs need SUID wrappers, can be configured further or are # Some programs need SUID wrappers, can be configured further or are
# started in user sessions. # started in user sessions.
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
};
virtualisation.containers.enable = true; virtualisation.containers.enable = true;
virtualisation.podman = { virtualisation.podman = {
enable = true; enable = true;
@ -99,12 +66,6 @@
# Required for containers under podman-compose to be able to talk to each other. # Required for containers under podman-compose to be able to talk to each other.
defaultNetwork.settings.dns_enabled = true; defaultNetwork.settings.dns_enabled = true;
}; };
#virtualisation.oci-containers.containers = {
# nixos = {
# image = "nix:latest"
# extraOptions = [ "--network=host" ];
# };
#};
services.gitea-actions-runner = { services.gitea-actions-runner = {
package = pkgs.forgejo-runner; package = pkgs.forgejo-runner;

View file

@ -4,6 +4,11 @@
# Set NIX_PATH to use nixpkgs deployed with krops # Set NIX_PATH to use nixpkgs deployed with krops
environment.variables.NIX_PATH = lib.mkForce "/var/src"; environment.variables.NIX_PATH = lib.mkForce "/var/src";
networking = {
nameservers = [ "80.67.169.12" "80.67.169.40" "2001:910:800::12" "2001:910:800::40" ];
enableIPv6 = true;
};
environment.shellAliases = { environment.shellAliases = {
tm = "tmux new -A -s shared" ; tm = "tmux new -A -s shared" ;
ll = "ls -al"; ll = "ls -al";
@ -18,4 +23,42 @@
KbdInteractiveAuthentication = false; KbdInteractiveAuthentication = false;
}; };
# Set your time zone.
time.timeZone = "Etc/UTC";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
LANGUAGE = "en_US.UTF-8";
LC_ALL = "en_US.UTF-8";
LC_CTYPE = "en_US.UTF-8";
LC_COLLATE = "en_US.UTF-8";
LC_MESSAGES = "en_US.UTF-8";
};
environment.systemPackages = with pkgs; [
git
wget
tmux
htop
mosh
dig
];
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
};
} }

View file

@ -0,0 +1,37 @@
# Wireguard VPN client configuration
{ config, pkgs, lib, ... }:
let
inherit (lib) mkOption mkDefault;
in
{
options = {
nixin.wg.client = {
ipv4 = mkOption { };
ipv6 = mkOption { };
};
};
config = {
networking = {
wg-quick.interfaces = {
wg0 = {
address = [ config.nixin.wg.client.ipv4 config.nixin.wg.client.ipv6 ];
dns = [ "80.67.169.12" "80.67.169.40" "2001:910:800::12" "2001:910:800::40" ];
privateKeyFile = "/var/src/secrets/wg-private.key";
peers = [
{
publicKey = "cUmp55I20JEhxr+RMmOsX+6U9kcDiAq3grnvzjQ642w=";
allowedIPs = [ "0.0.0.0/0" "::/0" ];
endpoint = "vpn.lab12.fr:51812";
persistentKeepalive = 15;
}
];
};
};
};
};
}