From 9f39802d285a8ab59c1a68bf70e503f7898124ee Mon Sep 17 00:00:00 2001 From: coolneng Date: Sat, 18 Apr 2020 21:04:14 +0200 Subject: [PATCH] Add network configuration in a different module --- README.org | 2 +- configuration.nix | 12 ++++++++++++ modules/networking.nix | 43 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 modules/networking.nix diff --git a/README.org b/README.org index 14e5093..d6a1da3 100644 --- a/README.org +++ b/README.org @@ -8,6 +8,6 @@ - ZFS pool configuration: hardware-configuration.nix - Network configuration: networking.nix - - Printing and scanner server: printing.nix + - Printing and scanner client: printing.nix All the modules are imported in *configuration.nix* diff --git a/configuration.nix b/configuration.nix index 273d4a6..9e5723b 100644 --- a/configuration.nix +++ b/configuration.nix @@ -3,6 +3,7 @@ { # Kernel configuration boot = { + kernelPackages = pkgs.linuxPackages_latest; kernelParams = [ "zfs.zfs_arc_max=536870912" ]; kernelModules = [ "i915" "acpi_call" ]; extraModulePackages = with config.boot.kernelPackages; [ acpi_call ]; @@ -44,4 +45,15 @@ # Clean tmp directory on shutdown boot.cleanTmpDir = true; + # Rotate logs after 7 days + services.journald.extraConfig = "SystemMaxFiles=7"; + + # Allow propietary software + nixpkgs.config.allowUnfree = true; + + # Import other configuration modules + imports = [ + ./modules/networking.nix + ]; + } diff --git a/modules/networking.nix b/modules/networking.nix new file mode 100644 index 0000000..badbf05 --- /dev/null +++ b/modules/networking.nix @@ -0,0 +1,43 @@ +{ config, lib, pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + avahi + wireguard + ]; + + # Set hostname and hostid + networking = { + hostName = "panacea"; + hostId = ""; + }; + + # Enable zeroconf + services.avahi = { + enable = true; + nssmdns = true; + publish = { + enable = true; + userServices = true; + }; + reflector = true; + }; + + # Wireguard setup + networking.wireguard.interfaces = { + wg0 = { + ips = [ "10.8.0.4/32" ]; + privateKeyFile = "/home/coolneng/.wg/keys/privatekey"; + peers = [ + # zion + { + publicKey = "GN8lqPBZYOulh6xD4GhkoEWI65HMMCpSxJSH5871YnU="; + allowedIPs = [ "0.0.0.0/0" ]; + endpoint = "coolneng.duckdns.org:1194"; + persistentKeepalive = 25; + } + ]; + }; + }; + +}