diff --git a/flake.nix b/flake.nix index d841f39..f467ac0 100644 --- a/flake.nix +++ b/flake.nix @@ -19,12 +19,11 @@ }; outputs = - inputs@{ - self, - nixpkgs, - flake-parts, - agenix, - ... + inputs@{ self + , nixpkgs + , flake-parts + , agenix + , ... }: flake-parts.lib.mkFlake { inherit inputs; } { imports = [ inputs.treefmt-nix.flakeModule ]; @@ -38,63 +37,30 @@ ./modules agenix.nixosModules.default ]; + hosts = import ./hosts.nix; in - { - apprentix = nixosSystem { - specialArgs = inputs; - modules = [ ./hosts/vm/apprentix ] ++ baseModules; - }; - - jitsi = nixosSystem { - specialArgs = inputs; - modules = [ ./hosts/vm/jitsi ] ++ baseModules; - }; - - livre = nixosSystem { - specialArgs = inputs; - modules = [ ./hosts/vm/livre ] ++ baseModules; - }; - - neo = nixosSystem { - specialArgs = inputs; - modules = [ ./hosts/vm/neo ] ++ baseModules; - }; - - nextcloud = nixosSystem { - specialArgs = inputs; - modules = [ ./hosts/vm/nextcloud ] ++ baseModules; - }; - - periodique = nixosSystem { - specialArgs = inputs; - modules = [ ./hosts/vm/periodique ] ++ baseModules; - }; - - redite = nixosSystem { - specialArgs = inputs; - modules = [ ./hosts/vm/redite ] ++ baseModules; - }; - - reverseproxy = nixosSystem { - specialArgs = inputs; - modules = [ ./hosts/vm/reverseproxy ] ++ baseModules; - }; - - thot = nixosSystem { - specialArgs = inputs; - modules = [ ./hosts/physiques/thot ] ++ baseModules; - }; - - two = nixosSystem { - specialArgs = inputs; - modules = [ ./hosts/vm/two ] ++ baseModules; - }; - - vaultwarden = nixosSystem { - specialArgs = inputs; - modules = [ ./hosts/vm/vaultwarden ] ++ baseModules; - }; - }; + # Physiques + (mapAttrs + (name: value: + nixosSystem { + specialArgs = inputs; + modules = [ ./hosts/physiques/${name} ] ++ baseModules; + } + ) + # Filtre que c'est bien une machine Nixos + (filterAttrs (n: v: !(attrByPath [ "is_debian" ] false v)) hosts.physiques) + ) // + # VMs + (mapAttrs + (name: value: + nixosSystem { + specialArgs = inputs; + modules = [ ./hosts/vm/${name} ] ++ baseModules; + } + ) + # Filtre que c'est bien une machine Nixos + (filterAttrs (n: v: !(attrByPath [ "is_debian" ] false v)) hosts.vms) + ); }; perSystem = diff --git a/hosts.nix b/hosts.nix new file mode 100644 index 0000000..d85a6d3 --- /dev/null +++ b/hosts.nix @@ -0,0 +1,167 @@ +let + adm = 10; + srv = n: 4; + srv-nat = 2; + san = 3; + adh = 42; +in +{ + physiques ={ + # cephirot = { + # name = "cephirot"; + # id = 3; + # vlans = [ + # adm + # san + # ]; + # serveur_type = ["san"]; + # description = '' + # Un serveur avec peut etre un jour ceph + # ''; + # public-ssh = "ssh-rsa TODOTODOTODOTODOTODOTODOTODO"; + # }; + thot = { + name = "thot"; + id = 14; + vlans = [ + adm + san + ]; + serveur_type = ["backup"]; + description = '' + Serveur de backup du Crans, actuellement en SQ39 + ''; + public-ssh = "ssh-rsa TODOTODOTODOTODOTODOTODOTODO"; + }; + }; + + vms = { + romanesco = { + name = "romanesco"; + is_debian = true; + id = 145; + vlans = [ + adm + (adh "185.230.78.252") + (srv "185.230.79.5") + ]; + description = '' + DNS récursif + ''; + public-ssh = "ssh-rsa TODOTODOTODOTODOTODOTODOTODO"; + }; + neo = { + name = "neo"; + id = 145; + vlans = [ + adm + # pas besoin de spécifier l'ipv6 car elle est construite depuis l'id + (srv "180.230.79.5") + ]; + description = '' + Matrix du crans, heberge également le bridge IRC <-> Matrix + ''; + public-ssh = "ssh-rsa TODOTODOTODOTODOTODOTODOTODO"; + }; + nextcloud = { + id = 146; + vlans = [ + adm + san + srv-nat + ]; + description = '' + NextCloud du Crans + ''; + public-ssh = "ssh-rsa TODOTODOTODOTODOTODOTODOTODO"; + }; + apprentix = { + id = 150; + vlans = [ + adm + ]; + description = '' + VM NixOs apprentie + ''; + public-ssh = "ssh-rsa TODOTODOTODOTODOTODOTODOTODO"; + }; + jitsi = { + id = 163; + vlans = [ + adm + (srv "185.230.79.15") + ]; + description = '' + Jitsi du crans + ''; + public-ssh = "ssh-rsa TODOTODOTODOTODOTODOTODOTODO"; + }; + livre = { + id = 140; + vlans = [ + adm + srv-nat + ]; + description = '' + Stirling PDF + ''; + public-ssh = "ssh-rsa TODOTODOTODOTODOTODOTODOTODO"; + }; + periodique = { + id = 118; + vlans = [ + adm + srv-nat + ]; + description = '' + Client matrix web (element) + ''; + public-ssh = "ssh-rsa TODOTODOTODOTODOTODOTODOTODO"; + }; + redite = { + id = 139; + vlans = [ + adm + srv-nat + ]; + description = '' + Redite + ''; + public-ssh = "ssh-rsa TODOTODOTODOTODOTODOTODOTODO"; + }; + reverseproxy = { + id = 151; + vlans = [ + adm + srv-nat + (srv "185.230.79.42") + ]; + description = '' + NextCloud du Crans + ''; + public-ssh = "ssh-rsa TODOTODOTODOTODOTODOTODOTODO"; + }; + two = { + id = 135; + vlans = [ + adm + srv-nat + ]; + description = '' + Une vm de test + ''; + public-ssh = "ssh-rsa TODOTODOTODOTODOTODOTODOTODO"; + }; + vaultwarden = { + id = 159; + vlans = [ + adm + srv-nat + ]; + description = '' + Vaultwarden + ''; + public-ssh = "ssh-rsa TODOTODOTODOTODOTODOTODOTODO"; + }; + }; +} diff --git a/variables.nix b/variables.nix new file mode 100644 index 0000000..00f475a --- /dev/null +++ b/variables.nix @@ -0,0 +1,8 @@ +let + machines = import ./hosts.nix; +in +{ + + dns-recursif = machines.vms.romanesco.id; + +}