diff --git a/flake.nix b/flake.nix index 41505be..826d504 100644 --- a/flake.nix +++ b/flake.nix @@ -53,12 +53,13 @@ in if builtins.pathExists filePath then # let eval = evalModules { + # specialArgs = inputs; # modules = [ - # # ./modules/crans + # ./modules/crans # { # crans = import filePath; # } - # agenix.nixosModules.default + # # agenix.nixosModules.default # ]; # }; # in @@ -79,20 +80,23 @@ map (info: { name = info.crans.name; - value = - nixosSystem { - specialArgs = inputs; - modules = [(path + "/${info.crans.name}")] ++ [info] ++ baseModules - ; - }; + value = info; } ) infos) ; + attrsToNixosSystem = path: all_hosts: hosts: + mapAttrs (name: info: + nixosSystem { + specialArgs = { hosts = all_hosts; inherit inputs;}; + modules = [(path + "/${name}")] ++ [info] ++ baseModules + ; + } + ) hosts; attrs_vm_info = listInfoToAttrs ./hosts/vm hosts_vm_info; attrs_physique_info = listInfoToAttrs ./hosts/physiques hosts_physique_info; attrs_all_info = attrs_physique_info // attrs_vm_info; in - attrs_all_info + (attrsToNixosSystem ./hosts/vm attrs_all_info attrs_vm_info) // { cransIso = nixosSystem { diff --git a/hosts/physiques/cameron/info.nix b/hosts/physiques/cameron/info.nix new file mode 100644 index 0000000..4164a30 --- /dev/null +++ b/hosts/physiques/cameron/info.nix @@ -0,0 +1,22 @@ +{ + name = "cameron"; + description = "Serveur de stockage adh"; + id = 2; + + isDebian = true; + + networking = { + adm.enable = true; + san.enable = true; + + switch = { + # todo recheck port + salameche = -1; + }; + }; + + ilo = { + id = 52; + switch.salameche = 16; + }; +} diff --git a/hosts/physiques/cephiroth/info.nix b/hosts/physiques/cephiroth/info.nix new file mode 100644 index 0000000..6c3b5c7 --- /dev/null +++ b/hosts/physiques/cephiroth/info.nix @@ -0,0 +1,20 @@ +{ + name = "cephiroth"; + description = "Serveur de stockage ceph"; + id = 3; + + networking = { + adm.enable = true; + san.enable = true; + + switch = { + carapuce = 12; + arceus = 12; + }; + }; + + ilo = { + id = 53; + switch.salameche = 20; + }; +} diff --git a/hosts/physiques/daniel/info.nix b/hosts/physiques/daniel/info.nix new file mode 100644 index 0000000..71ae326 --- /dev/null +++ b/hosts/physiques/daniel/info.nix @@ -0,0 +1,23 @@ +{ + name = "daniel"; + description = "PVE adm"; + id = 12; + + isDebian = true; + + networking = { + adm.enable = true; + san.enable = true; + srv-nat.enable = true; + + switch = { + carapuce = 3; + arceus = 3; + }; + }; + + ilo = { + id = 22; + switch.salameche = 4; + }; +} diff --git a/hosts/physiques/ft/info.nix b/hosts/physiques/ft/info.nix new file mode 100644 index 0000000..35c5a67 --- /dev/null +++ b/hosts/physiques/ft/info.nix @@ -0,0 +1,17 @@ +{ + name = "ft"; + description = "Serveur de backup du Crans, en SQ39"; + id = 15; + + isDebian = true; + + networking = { + adm.enable = true; + + switch = { + carapuce = 13; + arceus = 13; + }; + }; + +} diff --git a/hosts/physiques/gulp/info.nix b/hosts/physiques/gulp/info.nix new file mode 100644 index 0000000..9fbf144 --- /dev/null +++ b/hosts/physiques/gulp/info.nix @@ -0,0 +1,22 @@ +{ + name = "gulp"; + description = "PVE adh"; + id = 18; + + isDebian = true; + + networking = { + adm.enable = true; + adh.enable = true; + + switch = { + carapuce = 11; + arceus = 11; + }; + }; + + ilo = { + id = 28; + switch.salameche = 12; + }; +} diff --git a/hosts/physiques/jack/info.nix b/hosts/physiques/jack/info.nix new file mode 100644 index 0000000..3fbb130 --- /dev/null +++ b/hosts/physiques/jack/info.nix @@ -0,0 +1,24 @@ +{ + name = "jack"; + description = "PVE adm"; + id = 13; + + isDebian = true; + + networking = { + adm.enable = true; + san.enable = true; + srv-nat.enable = true; + + switch = { + carapuce = 5; + arceus = 5; + }; + }; + + ilo = { + id = 23; + switch.salameche = 6; + }; +} + diff --git a/hosts/physiques/odlyd/info.nix b/hosts/physiques/odlyd/info.nix new file mode 100644 index 0000000..90dff8c --- /dev/null +++ b/hosts/physiques/odlyd/info.nix @@ -0,0 +1,21 @@ +{ + name = "odlyd"; + description = "PVE adh"; + id = 16; + + isDebian = true; + + networking = { + adm.enable = true; + adh.enable = true; + + switch = { + # pas branche + }; + }; + + ilo = { + id = 26; + switch.salameche = 8; + }; +} diff --git a/hosts/physiques/sam/info.nix b/hosts/physiques/sam/info.nix new file mode 100644 index 0000000..0dd7f9b --- /dev/null +++ b/hosts/physiques/sam/info.nix @@ -0,0 +1,23 @@ +{ + name = "sam"; + description = "PVE adm"; + id = 11; + + isDebian = true; + + networking = { + adm.enable = true; + san.enable = true; + srv-nat.enable = true; + + switch = { + carapuce = 1; + arceus = 1; + }; + }; + + ilo = { + id = 21; + switch.salameche = 2; + }; +} diff --git a/hosts/physiques/stitch/info.nix b/hosts/physiques/stitch/info.nix new file mode 100644 index 0000000..b10b4cc --- /dev/null +++ b/hosts/physiques/stitch/info.nix @@ -0,0 +1,22 @@ +{ + name = "stitch"; + description = "PVE adh"; + id = 17; + + isDebian = true; + + networking = { + adm.enable = true; + adh.enable = true; + + switch = { + carapuce = 9; + arceus = 9; + }; + }; + + ilo = { + id = 27; + switch.salameche = 10; + }; +} diff --git a/hosts/physiques/tealc/info.nix b/hosts/physiques/tealc/info.nix new file mode 100644 index 0000000..1b8a385 --- /dev/null +++ b/hosts/physiques/tealc/info.nix @@ -0,0 +1,22 @@ +{ + name = "tealc"; + description = "Serveur de stockage adm"; + id = 1; + + isDebian = true; + + networking = { + adm.enable = true; + san.enable = true; + + switch = { + carapuce = 10; + arceus = 10; + }; + }; + + ilo = { + id = 51; + switch.salameche = 18; + }; +} diff --git a/hosts/physiques/zamok/info.nix b/hosts/physiques/zamok/info.nix new file mode 100644 index 0000000..ce45c1b --- /dev/null +++ b/hosts/physiques/zamok/info.nix @@ -0,0 +1,23 @@ +{ + name = "zamok"; + description = "Serveur de calcul adhérent"; + id = 31; + + isDebian = true; + + networking = { + adm.enable = true; + adh.enable = true; + san.enable = true; + + switch = { + carapuce = 7; + arceus = 4; + }; + }; + + ilo = { + id = 54; + switch.salameche = 14; + }; +} diff --git a/hosts/vm/jitsi/info.nix b/hosts/vm/jitsi/info.nix index 64e9044..5818ab2 100644 --- a/hosts/vm/jitsi/info.nix +++ b/hosts/vm/jitsi/info.nix @@ -5,6 +5,7 @@ id = 163; networking = { + adm.enable = true; srv = { enable = true; ipv4 = "185.230.79.15"; diff --git a/modules/crans/networking.nix b/modules/crans/networking.nix index ca220d3..37fcc4f 100644 --- a/modules/crans/networking.nix +++ b/modules/crans/networking.nix @@ -1,4 +1,4 @@ -{ lib, config, ... }: +{ lib, config, hosts, ... }: let cfg = config.crans; @@ -9,6 +9,7 @@ let mkIf mkOption types + mod ; idString = toString cfg.id; @@ -16,6 +17,8 @@ let hostIdString = lib.fixedWidthString 2 "0" (toString hostId); isVm = cfg.id >= 100; isVmString = toString isVm; + get_mac = id: vlan_num: + "02:00:00:0${toString (id >= 100)}:${toString (mod id 100)}:${toString vlan_num}"; in { options.crans.networking = { @@ -30,6 +33,21 @@ in example = "ens20"; description = "Nom de l'interface réseau sur laquelle est située le VLAN adm."; }; + + ipv4 = mkOption { + type = types.str; + example = "176.16.10.102"; + default = "172.16.10.${idString}"; + description = "Adresse IPv4 de la machine sur le VLAN adm"; + }; + + ipv6 = mkOption { + type = types.str; + example = "fd00::10:0:ff:fe01:0210"; + default = "fd00::10:0:ff:fe0${isVmString}:${hostIdString}10"; + description = "Adresse IPv6 de la machine sur le VLAN adm"; + }; + }; srv = { @@ -47,6 +65,13 @@ in example = "185.230.79.1"; description = "Adresse IPv4 de la machine."; }; + + ipv6 = mkOption { + type = types.str; + example = "2a0c:700:2::ff:fe01:0202"; + default = "2a0c:700:2::ff:fe0${isVmString}:${hostIdString}02"; + description = "Adresse IPv6 de la machine sur le VLAN srv."; + }; }; srvNat = { @@ -58,6 +83,20 @@ in example = "ens20"; description = "Nom de l'interface réseau sur laquelle est située le VLAN srv-nat."; }; + + ipv4 = mkOption { + type = types.str; + example = "176.16.3.102"; + default = "172.16.3.${idString}"; + description = "Adresse IPv4 de la machine sur le VLAN srv-nat."; + }; + + ipv6 = mkOption { + type = types.str; + example = "2a0c:700:3::ff:fe01:0203"; + default = "2a0c:700:3::ff:fe0${isVmString}:${hostIdString}03"; + description = "Adresse IPv6 de la machine sur le VLAN srv-nat."; + }; }; san = { @@ -68,6 +107,20 @@ in example = "ens19"; description = "Nom de l'interface réseau sur laquelle est située le VLAN san."; }; + + ipv4 = mkOption { + type = types.str; + example = "176.16.4.102"; + default = "172.16.4.${idString}"; + description = "Adresse IPv4 de la machine sur le VLAN srv-nat."; + }; + + ipv6 = mkOption { + type = types.str; + example = "fd00::4:0:ff:fe01:0204"; + default = "fd00::4:0:ff:fe0${isVmString}:${hostIdString}04"; + description = "Adresse IPv6 de la machine sur le VLAN san."; + }; }; }; @@ -98,14 +151,14 @@ in adm = { ipv4.addresses = [ { - address = "172.16.10.${idString}"; + address = cfg-net.adm.ipv4; prefixLength = 24; } ]; ipv6.addresses = [ { - address = "fd00::10:0:ff:fe0${isVmString}:${hostIdString}10"; + address = cfg-net.adm.ipv6; prefixLength = 64; } ]; @@ -131,7 +184,7 @@ in ipv6 = { addresses = [ { - address = "2a0c:700:2::ff:fe0${isVmString}:${hostIdString}02"; + address = cfg-net.srv.ipv6; prefixLength = 64; } ]; @@ -150,7 +203,7 @@ in ipv4 = { addresses = [ { - address = "172.16.3.${idString}"; + address = cfg-net.srvNat.ipv4; prefixLength = 24; } ]; @@ -166,7 +219,7 @@ in ipv6 = { addresses = [ { - address = "2a0c:700:3::ff:fe0${isVmString}:${hostIdString}03"; + address = cfg-net.srvNat.ipv6; prefixLength = 64; } ]; @@ -184,14 +237,14 @@ in san = { ipv4.addresses = [ { - address = "172.16.4.${idString}"; + address = cfg-net.san.ipv4; prefixLength = 24; } ]; ipv6.addresses = [ { - address = "fd00::4:0:ff:fe0${isVmString}:${hostIdString}04"; + address = cfg-net.san.ipv6; prefixLength = 64; } ]; diff --git a/modules/crans/users.nix b/modules/crans/users.nix index c229bf4..5686447 100644 --- a/modules/crans/users.nix +++ b/modules/crans/users.nix @@ -18,7 +18,7 @@ in root = { passwordFile = mkOption { - type = types.path; + type = types.externalPath; default = ../../secrets/common/root.age; example = ../../secrets/apprentix/root.age; description = "Fichier chiffré par age contenant le mot de passe root.";