Simplify networking configs

Introduces values.nix, a place to store information relevant across systems
This commit is contained in:
Daniel Lovbrotte Olsen 2023-01-17 10:27:18 +01:00
parent 4e93962f1c
commit e4cb215d39
5 changed files with 35 additions and 13 deletions

View File

@ -1,4 +1,4 @@
{ config, pkgs, inputs, ... }: { config, lib, pkgs, inputs, values, ... }:
{ {
imports = [ imports = [
@ -8,6 +8,8 @@
networking.domain = "pvv.ntnu.no"; networking.domain = "pvv.ntnu.no";
networking.useDHCP = false; networking.useDHCP = false;
networking.search = [ "pvv.ntnu.no" "pvv.org" ]; 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 = { services.resolved = {
enable = true; enable = true;

View File

@ -22,7 +22,7 @@
nixosConfigurations = { nixosConfigurations = {
jokum = nixpkgs.lib.nixosSystem { jokum = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = { inherit unstable inputs; }; specialArgs = { inherit unstable inputs; values = import ./values.nix; };
modules = [ modules = [
./hosts/jokum/configuration.nix ./hosts/jokum/configuration.nix
sops-nix.nixosModules.sops sops-nix.nixosModules.sops
@ -32,7 +32,7 @@
}; };
ildkule = nixpkgs.lib.nixosSystem { ildkule = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = { inherit unstable inputs; }; specialArgs = { inherit unstable inputs; values = import ./values.nix; };
modules = [ modules = [
./hosts/ildkule/configuration.nix ./hosts/ildkule/configuration.nix
sops-nix.nixosModules.sops sops-nix.nixosModules.sops

View File

@ -22,7 +22,6 @@
networking.interfaces.ens18.useDHCP = false; networking.interfaces.ens18.useDHCP = false;
networking.defaultGateway = "129.241.210.129";
networking.interfaces.ens18.ipv4 = { networking.interfaces.ens18.ipv4 = {
addresses = [ addresses = [
{ {
@ -39,7 +38,6 @@
} }
]; ];
}; };
networking.nameservers = [ "129.241.0.200" "129.241.0.201" ];
# List packages installed in system profile # List packages installed in system profile
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View File

@ -1,4 +1,4 @@
{ config, pkgs, ... }: { config, pkgs, values, ... }:
{ {
imports = [ imports = [
# Include the results of the hardware scan. # Include the results of the hardware scan.
@ -27,16 +27,14 @@
networking.hostName = "jokum"; # Define your hostname. networking.hostName = "jokum"; # Define your hostname.
networking.interfaces.ens18.useDHCP = false; networking.interfaces.ens18.useDHCP = false;
networking.defaultGateway = "129.241.210.129";
networking.interfaces.ens18.ipv4 = { networking.interfaces.ens18.ipv4 = {
addresses = [ addresses = [
{ {
address = "129.241.210.169"; address = values.jokum.ipv4;
prefixLength = 25; prefixLength = 25;
} }
{ {
address = "129.241.210.213"; address = values.turn.ipv4;
prefixLength = 25; prefixLength = 25;
} }
]; ];
@ -44,16 +42,15 @@
networking.interfaces.ens18.ipv6 = { networking.interfaces.ens18.ipv6 = {
addresses = [ addresses = [
{ {
address = "2001:700:300:1900::169"; address = values.jokum.ipv6;
prefixLength = 64; prefixLength = 64;
} }
{ {
address = "2001:700:300:1900::213"; address = values.turn.ipv6;
prefixLength = 64; prefixLength = 64;
} }
]; ];
}; };
networking.nameservers = [ "129.241.0.200" "129.241.0.201" ];
# List packages installed in system profile # List packages installed in system profile
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

25
values.nix Normal file
View File

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