Add network configuration in a different module

This commit is contained in:
coolneng 2020-04-18 21:04:14 +02:00
parent c754716596
commit 9f39802d28
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
3 changed files with 56 additions and 1 deletions

View File

@ -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*

View File

@ -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
];
}

43
modules/networking.nix Normal file
View File

@ -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;
}
];
};
};
}