From e4cb215d394073f348b52e6c622fcc778fabc6bb Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Tue, 17 Jan 2023 10:27:18 +0100 Subject: [PATCH] Simplify networking configs Introduces values.nix, a place to store information relevant across systems --- base.nix | 4 +++- flake.nix | 4 ++-- hosts/ildkule/configuration.nix | 2 -- hosts/jokum/configuration.nix | 13 +++++-------- values.nix | 25 +++++++++++++++++++++++++ 5 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 values.nix diff --git a/base.nix b/base.nix index b5f6c84..13c9e4b 100644 --- a/base.nix +++ b/base.nix @@ -1,4 +1,4 @@ -{ config, pkgs, inputs, ... }: +{ config, lib, pkgs, inputs, values, ... }: { imports = [ @@ -8,6 +8,8 @@ networking.domain = "pvv.ntnu.no"; networking.useDHCP = false; networking.search = [ "pvv.ntnu.no" "pvv.org" ]; + networking.nameservers = lib.mkDefault [ "129.241.0.200" "129.241.0.201" ]; + networking.defaultGateway = values.gateway; services.resolved = { enable = true; diff --git a/flake.nix b/flake.nix index 75d91d2..dc11725 100644 --- a/flake.nix +++ b/flake.nix @@ -22,7 +22,7 @@ nixosConfigurations = { jokum = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; - specialArgs = { inherit unstable inputs; }; + specialArgs = { inherit unstable inputs; values = import ./values.nix; }; modules = [ ./hosts/jokum/configuration.nix sops-nix.nixosModules.sops @@ -32,7 +32,7 @@ }; ildkule = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; - specialArgs = { inherit unstable inputs; }; + specialArgs = { inherit unstable inputs; values = import ./values.nix; }; modules = [ ./hosts/ildkule/configuration.nix sops-nix.nixosModules.sops diff --git a/hosts/ildkule/configuration.nix b/hosts/ildkule/configuration.nix index d733751..77037cb 100644 --- a/hosts/ildkule/configuration.nix +++ b/hosts/ildkule/configuration.nix @@ -22,7 +22,6 @@ networking.interfaces.ens18.useDHCP = false; - networking.defaultGateway = "129.241.210.129"; networking.interfaces.ens18.ipv4 = { addresses = [ { @@ -39,7 +38,6 @@ } ]; }; - networking.nameservers = [ "129.241.0.200" "129.241.0.201" ]; # List packages installed in system profile environment.systemPackages = with pkgs; [ diff --git a/hosts/jokum/configuration.nix b/hosts/jokum/configuration.nix index f00a047..a4dd882 100644 --- a/hosts/jokum/configuration.nix +++ b/hosts/jokum/configuration.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, pkgs, values, ... }: { imports = [ # Include the results of the hardware scan. @@ -27,16 +27,14 @@ networking.hostName = "jokum"; # Define your hostname. networking.interfaces.ens18.useDHCP = false; - - networking.defaultGateway = "129.241.210.129"; networking.interfaces.ens18.ipv4 = { addresses = [ { - address = "129.241.210.169"; + address = values.jokum.ipv4; prefixLength = 25; } { - address = "129.241.210.213"; + address = values.turn.ipv4; prefixLength = 25; } ]; @@ -44,16 +42,15 @@ networking.interfaces.ens18.ipv6 = { addresses = [ { - address = "2001:700:300:1900::169"; + address = values.jokum.ipv6; prefixLength = 64; } { - address = "2001:700:300:1900::213"; + address = values.turn.ipv6; prefixLength = 64; } ]; }; - networking.nameservers = [ "129.241.0.200" "129.241.0.201" ]; # List packages installed in system profile environment.systemPackages = with pkgs; [ diff --git a/values.nix b/values.nix new file mode 100644 index 0000000..e6cc7f8 --- /dev/null +++ b/values.nix @@ -0,0 +1,25 @@ +# Feel free to change the structure of this file + +rec { + gateway = "129.241.210.129"; + + + jokum = { + ipv4 = "129.241.210.169"; + ipv6 = "2001:700:300:1900::169"; + }; + matrix = { + ipv4 = jokum.ipv4; + ipv6 = jokum.ipv6; + }; + # Also on jokum + turn = { + ipv4 = "129.241.210.213"; + ipv6 = "2001:700:300:1900::213"; + }; + + ildkule = { + ipv4 = "129.241.210.187"; + ipv6 = "2001:700:300:1900::187"; + }; +}