[#33] Refactored existing network config #34

Merged
nerf merged 1 commit from nerf/nixConfig:nerf/networkConfig into main 2024-04-03 13:30:20 +00:00
3 changed files with 50 additions and 17 deletions

View file

@ -4,7 +4,7 @@
../../modules/jitsi.nix
../../roles
../../roles/vm.nix
./network.nix
../../modules/vmNetwork.nix
];
services.mathebau-jitsi = {
@ -14,5 +14,6 @@
# System configuration here
networking.hostName = "ghatanothoa";
vmNetwork.ipv4 = "192.168.0.25";
system.stateVersion = "23.11";
}

View file

@ -1,16 +0,0 @@
# We sohuld put that config somewhere in roles and give it a parameter or something,
# everyone gets the same nameserver and the same prefixLength and address vs defaultGateway alsways
# depend on the same thing
{
imports = [];
networking = {
interfaces.enX0.ipv4.addresses = [
{
address = "192.168.0.25";
prefixLength = 16;
}
];
defaultGateway = "192.168.0.152";
nameservers = ["130.83.2.22" "130.83.56.60" "130.83.22.60" "130.82.22.63"];
};
}

View file

@ -0,0 +1,48 @@
{
lib,
config,
...
}: let
inherit
(lib)
mkOption
types
last
init
;
inherit
(lib.strings)
splitString
concatStringsSep
toInt
;
cfg = config.vmNetwork;
in {
imports = [];
Outdated
Review

Ist es üblich oder notwendig, leere Imports mit hinzuschreiben?

Ist es üblich oder notwendig, leere Imports mit hinzuschreiben?
Outdated
Review

I'm not sure if it is required (I would guess no). But I kind of find it idiomatic to put it there. We should agree if we do it or not and then enforce it across the whole codebase.

I'm not sure if it is required (I would guess no). But I kind of find it idiomatic to put it there. We should agree if we do it or not and then enforce it across the whole codebase.
Outdated
Review

I don't mind. One precedent is https://nixos.wiki/wiki/NixOS_modules#Example which leaves it out. 🤷

I don't mind. One precedent is https://nixos.wiki/wiki/NixOS_modules#Example which leaves it out. 🤷
options.vmNetwork = {
ipv4 = mkOption {
type = types.str;
description = "the ipv4 adress of this machine";
};
};
config = {
networking = {
interfaces.enX0.ipv4.addresses = [
{
address = cfg.ipv4;
prefixLength = 16;
}
];
defaultGateway = let
addr = splitString "." cfg.ipv4;
addrInit = init addr;
addrLastInt = builtins.toString (toInt (last addr) + 127);
in
concatStringsSep "." (addrInit ++ [addrLastInt]);
# https://www.hrz.tu-darmstadt.de/services/it_services/nameserver_dns/index.de.jsp
nerf marked this conversation as resolved Outdated
Outdated
Review

Hierzu sollten wir die Quelle https://www.hrz.tu-darmstadt.de/services/it_services/nameserver_dns/index.de.jsp verlinken. Aus dieser geht hervor, dass die Zeile in Reihenfolge der Hostnamen

      nameservers = ["130.83.22.63" "130.83.22.60" "130.83.56.60"]; 

lauten sollte. Der Server unter 130.83.2.22 hingegen liefert mir keine Antworten (mehr).

Hierzu sollten wir die Quelle https://www.hrz.tu-darmstadt.de/services/it_services/nameserver_dns/index.de.jsp verlinken. Aus dieser geht hervor, dass die Zeile in Reihenfolge der Hostnamen ``` nameservers = ["130.83.22.63" "130.83.22.60" "130.83.56.60"]; ``` lauten sollte. Der Server unter `130.83.2.22` hingegen liefert mir keine Antworten (mehr).
nameservers = ["130.83.22.63" "130.83.22.60" "130.83.56.60"];
};
};
}