From 5fca38d8d5c834db93a58d9ad199e300845457f8 Mon Sep 17 00:00:00 2001 From: Lyes Saadi Date: Sat, 21 Nov 2026 15:04:52 +0100 Subject: [PATCH 1/7] =?UTF-8?q?D=C3=A9finition=20du=20module=20d'autoUpdat?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/info/autoupdate.nix | 64 +++++++++++++++++++++++++++++++++++++ modules/info/default.nix | 1 + modules/info/monitoring.nix | 9 ++++++ 3 files changed, 74 insertions(+) create mode 100644 modules/info/autoupdate.nix diff --git a/modules/info/autoupdate.nix b/modules/info/autoupdate.nix new file mode 100644 index 0000000..49edfef --- /dev/null +++ b/modules/info/autoupdate.nix @@ -0,0 +1,64 @@ +{ config, lib, ... }: + +let + inherit (lib) mkEnableOption mkOption types; +in +{ + options.autoUpdate = { + enable = mkEnableOption "Activer les mises à jours automatiques."; + autoDeploy = mkOption { + type = types.bool; + description = "Auto-déployer les changements construits."; + default = true; + }; + autoReboot = mkOption { + type = types.nullOr types.str; + description = "Définir une plage d'heure d'auto-reboot."; + default = null; + }; + operation = mkOption { + type = types.str; + description = "L'opération à effectuer (switch, test ou boot)."; + example = "boot"; + default = "switch"; + }; + period = mkOption { + type = types.ints.positive; + description = "Le délai entre chaque pull du git en secondes."; + default = 60; + }; + + main = { + enable = mkOption { + type = types.bool; + description = "Activer le suivi de la branche main."; + default = true; + }; + # branch = mkOption { + # type = types.str; + # description = "La branche à suivre pour les mises à jours principales."; + # default = "main"; + # }; + # operation = mkOption { + # type = types.str; + # description = "L'opération à effectuer (switch, test ou boot)."; + # example = "boot"; + # default = "switch"; + # }; + }; + + testing = { + branch = mkOption { + type = types.str; + description = "La branche à suivre pour les tests."; + default = "testing-${config.name}"; + }; + # operation = mkOption { + # type = types.str; + # description = "L'opération à effectuer (switch, test ou boot)."; + # example = "boot"; + # default = "${config.autoUpdate.main.operation}"; + # }; + }; + }; +} diff --git a/modules/info/default.nix b/modules/info/default.nix index 8fd8502..ba23c20 100644 --- a/modules/info/default.nix +++ b/modules/info/default.nix @@ -14,6 +14,7 @@ in { imports = [ ./acme.nix + ./autoupdate.nix ./home.nix ./meta.nix ./monitoring.nix diff --git a/modules/info/monitoring.nix b/modules/info/monitoring.nix index 181abb5..3b89938 100644 --- a/modules/info/monitoring.nix +++ b/modules/info/monitoring.nix @@ -14,5 +14,14 @@ in default = false; }; }; + + comin = { + enable = mkOption { + type = types.bool; + example = true; + description = "Monitoring de Comin (l'auto-update) par prometheus."; + default = false; + }; + }; }; } From 2497cf0466a018f896369aea7c8f18398117b8b8 Mon Sep 17 00:00:00 2001 From: Lyes Saadi Date: Sat, 21 Nov 2026 16:18:55 +0100 Subject: [PATCH 2/7] Ajout de la configuration pour les autoupdate --- flake.lock | 89 ++++++++++++++++++++++++++++++++---- flake.nix | 8 ++++ modules/crans/autoupdate.nix | 77 +++++++++++++++++++++++++++++++ modules/crans/default.nix | 1 + 4 files changed, 167 insertions(+), 8 deletions(-) create mode 100644 modules/crans/autoupdate.nix diff --git a/flake.lock b/flake.lock index 02b77ad..2b70d64 100644 --- a/flake.lock +++ b/flake.lock @@ -20,6 +20,44 @@ "type": "github" } }, + "comin": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "nixpkgs" + ], + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1795253528, + "narHash": "sha256-TvzBvAV7KVWsvTCQjRg1oY/lhDbuN9YXLDctGGhXPdU=", + "owner": "nlewo", + "repo": "comin", + "rev": "4cc0f6a9764a0ac73ec248d1475a1372c19b4773", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "comin", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1765121682, + "narHash": "sha256-4VBOP18BFeiPkyhy9o4ssBNQEvfvv1kXkasAYd0+rrA=", + "owner": "NixOS", + "repo": "flake-compat", + "rev": "65f23138d8d09a92e30f1e5c87611b23ef451bf3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -40,16 +78,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1793294725, - "narHash": "sha256-loLMnbbS4KhmG2ln9EY6f0YMNCA273Yx02oWYQ9IMeE=", - "owner": "NixOS", + "lastModified": 1770107345, + "narHash": "sha256-tbS0Ebx2PiA1FRW8mt8oejR0qMXmziJmPaU1d4kYY9g=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "6f06d204d8f2d8761d9da78778745974a3216381", + "rev": "4533d9293756b63904b7238acb84ac8fe4c8c2c4", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixos-26.05", + "owner": "nixos", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -69,15 +107,50 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1793294725, + "narHash": "sha256-loLMnbbS4KhmG2ln9EY6f0YMNCA273Yx02oWYQ9IMeE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6f06d204d8f2d8761d9da78778745974a3216381", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-26.05", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "agenix": "agenix", + "comin": "comin", "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs", - "treefmt-nix": "treefmt-nix" + "nixpkgs": "nixpkgs_2", + "treefmt-nix": "treefmt-nix_2" } }, "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1770228511, + "narHash": "sha256-wQ6NJSuFqAEmIg2VMnLdCnUc0b7vslUohqqGGD+Fyxk=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "337a4fe074be1042a35086f15481d763b8ddc0e7", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, + "treefmt-nix_2": { "inputs": { "nixpkgs": [ "nixpkgs" diff --git a/flake.nix b/flake.nix index f00085f..15bb8c1 100644 --- a/flake.nix +++ b/flake.nix @@ -16,6 +16,12 @@ url = "github:ryantm/agenix"; inputs.nixpkgs.follows = "nixpkgs"; }; + + # Auto updates + comin = { + url = "github:nlewo/comin"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -24,6 +30,7 @@ nixpkgs, flake-parts, agenix, + comin, ... }: let @@ -46,6 +53,7 @@ baseModules = [ ./modules agenix.nixosModules.default + comin.nixosModules.default ]; in (attrsToNixosSystem ./hosts/vm attrs_all_info attrs_vm_info baseModules) diff --git a/modules/crans/autoupdate.nix b/modules/crans/autoupdate.nix new file mode 100644 index 0000000..893407a --- /dev/null +++ b/modules/crans/autoupdate.nix @@ -0,0 +1,77 @@ +{ lib, info, ... }: + +let + inherit (lib) mkIf; + cfg = info.autoUpdate; +in +{ + # Options ../info/autoupdate.nix + config = mkIf cfg.enable { + services.comin = { + enable = true; + buildAttemptsLimit = 3; + buildRetryTimer = 5 * 60; + remotes = [ + # TODO : à split en deux remotes, l'une pour main, l'autre pour testing + { + name = "origin"; + url = "https://gitlab.adm.crans.org/nounous/nixos.git"; + poller.period = cfg.period; + branches = { + main = + let + branch = + if cfg.main.enable then + { + branch = "name"; + # period = cfg.main.period; + } + else + cfg.testing; + in + { + inherit (cfg) operation; + name = branch.branch; + }; + testing = { + inherit (cfg) operation; + name = cfg.testing.branch; + }; + }; + } + ]; + + exporter = mkIf info.monitoring.comin.enable { + listen_address = info.networking.adm.ipv4.address; + port = 4267; + }; + }; + + nix = mkIf (info.name != "cephiroth") { + distributedBuilds = true; + + settings = { + max-jobs = 0; + builders-use-substitutes = true; + }; + + buildMachines = [ + { + hostName = "cephiroth.adm.crans.org"; + sshUser = "builder"; + sshKey = "/etc/ssh/ssh_host_ed25519_key"; + system = "x86_64-linux"; + maxJobs = 8; + supportedFeatures = [ + "nixos-test" + "benchmark" + "big-parallel" + "kvm" + ]; + } + ]; + }; + + # TODO : Autoreboot + }; +} diff --git a/modules/crans/default.nix b/modules/crans/default.nix index ee6e5aa..13cc45f 100644 --- a/modules/crans/default.nix +++ b/modules/crans/default.nix @@ -13,6 +13,7 @@ in { imports = [ ./age.nix + ./autoupdate.nix ./grub.nix ./home.nix ./locale.nix From e1ada97e5dbfb0623dd28f1a3154dacd497a5969 Mon Sep 17 00:00:00 2001 From: Lyes Saadi Date: Sat, 21 Nov 2026 16:27:00 +0100 Subject: [PATCH 3/7] Test de comin sur coturn --- hosts/vm/coturn/info.nix | 8 ++++++++ hosts/vm/livre/info.nix | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hosts/vm/coturn/info.nix b/hosts/vm/coturn/info.nix index 7d99a69..65f78c0 100644 --- a/hosts/vm/coturn/info.nix +++ b/hosts/vm/coturn/info.nix @@ -15,6 +15,14 @@ monitoring = { nginx.enable = true; + comin.enable = true; + }; + + autoUpdate = { + enable = true; + + main.enable = false; + testing.branch = "comin"; }; resticClient.when = "06:07"; diff --git a/hosts/vm/livre/info.nix b/hosts/vm/livre/info.nix index 8df46c7..65d6645 100644 --- a/hosts/vm/livre/info.nix +++ b/hosts/vm/livre/info.nix @@ -24,6 +24,6 @@ monitoring = { nginx.enable = true; }; - + resticClient.when = "03:45"; } From 871e4bcfad7ec6f0679c7e42c50a22d25552f026 Mon Sep 17 00:00:00 2001 From: Lyes Saadi Date: Sat, 21 Nov 2026 17:16:47 +0100 Subject: [PATCH 4/7] Flake update --- flake.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index 2b70d64..975233b 100644 --- a/flake.lock +++ b/flake.lock @@ -63,11 +63,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1790898470, - "narHash": "sha256-zTwuwezD0w3hpga6a6P8emidzAZFyWqlNeRBlpWOOl8=", + "lastModified": 1793576659, + "narHash": "sha256-V1h85lUaJBQoHFrB2vpXZOE0Ju1MYSnIpsehoVZYlDo=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "024633cd702b10285db5cb19b40ad48d2399ba60", + "rev": "ea2630b7470978622c7689a1ff75d2b389175399", "type": "github" }, "original": { @@ -94,11 +94,11 @@ }, "nixpkgs-lib": { "locked": { - "lastModified": 1790477367, - "narHash": "sha256-oujbxmVKDhci2E4EM3KyAbRUgp5/IsCoiA/LfEF7OOk=", + "lastModified": 1793504054, + "narHash": "sha256-ThkfL3D/FhCiZFc9+3BtxwuMmpuK+/bGtXCSo1+yVew=", "owner": "nix-community", "repo": "nixpkgs.lib", - "rev": "f7cd230690d9fc982d06129f9189b101fddcfa3b", + "rev": "7851ba61fd862b277cb6a9cef37394bc18bb94e4", "type": "github" }, "original": { @@ -109,11 +109,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1793294725, - "narHash": "sha256-loLMnbbS4KhmG2ln9EY6f0YMNCA273Yx02oWYQ9IMeE=", + "lastModified": 1795137884, + "narHash": "sha256-iKXCN36qYfBni+3nH4vAd98/kshoIsPB2S9mYWhma30=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6f06d204d8f2d8761d9da78778745974a3216381", + "rev": "ab5c18fdedfc8f9bbc9d773f10a540790e2787a7", "type": "github" }, "original": { @@ -157,11 +157,11 @@ ] }, "locked": { - "lastModified": 1791885023, - "narHash": "sha256-C3alQ2MEt0zVrUSho5NUDo3jmhbff72++bfwoqT9Omo=", + "lastModified": 1795173499, + "narHash": "sha256-J8IYl3oEdctyvBgWr+/L01MY5Xm0TU4WXwZDccN5jjk=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "0d6d739a833ba9a9c93034862e4a7b061a062a1c", + "rev": "a0a97e31a897a3537eea5c49df4f8adaa83b3b37", "type": "github" }, "original": { From 48e6c6de3f726a8e15ac45a7691fc307470a6e69 Mon Sep 17 00:00:00 2001 From: Lyes Saadi Date: Sat, 21 Nov 2026 17:49:24 +0100 Subject: [PATCH 5/7] =?UTF-8?q?Am=C3=A9lioration=20des=20param=C3=A8tres?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/crans/autoupdate.nix | 3 ++- modules/info/autoupdate.nix | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/crans/autoupdate.nix b/modules/crans/autoupdate.nix index 893407a..0099c64 100644 --- a/modules/crans/autoupdate.nix +++ b/modules/crans/autoupdate.nix @@ -11,6 +11,7 @@ in enable = true; buildAttemptsLimit = 3; buildRetryTimer = 5 * 60; + buildTimeout = 2 * 60 * 60; remotes = [ # TODO : à split en deux remotes, l'une pour main, l'autre pour testing { @@ -61,7 +62,7 @@ in sshUser = "builder"; sshKey = "/etc/ssh/ssh_host_ed25519_key"; system = "x86_64-linux"; - maxJobs = 8; + maxJobs = 32; supportedFeatures = [ "nixos-test" "benchmark" diff --git a/modules/info/autoupdate.nix b/modules/info/autoupdate.nix index 49edfef..de1a56d 100644 --- a/modules/info/autoupdate.nix +++ b/modules/info/autoupdate.nix @@ -25,7 +25,7 @@ in period = mkOption { type = types.ints.positive; description = "Le délai entre chaque pull du git en secondes."; - default = 60; + default = 5 * 60; }; main = { From 41da111000ecd7237338d8e2be52d8e431616a44 Mon Sep 17 00:00:00 2001 From: Pyjacpp Date: Sat, 21 Nov 2026 18:10:13 +0100 Subject: [PATCH 6/7] ajouts ssh --- hosts/physiques/cephiroth/info.nix | 4 ++++ hosts/physiques/thot/info.nix | 2 ++ hosts/vm/apprentix/info.nix | 2 ++ hosts/vm/collabora/info.nix | 2 ++ hosts/vm/coturn/info.nix | 2 ++ hosts/vm/jitsi/info.nix | 2 ++ hosts/vm/livre/info.nix | 2 ++ hosts/vm/mediakiwi/info.nix | 2 ++ hosts/vm/neo/info.nix | 2 ++ hosts/vm/nextcloud/info.nix | 2 ++ hosts/vm/periodique/info.nix | 2 ++ hosts/vm/reverseproxy/info.nix | 2 ++ hosts/vm/two/info.nix | 2 ++ hosts/vm/vaultwarden/info.nix | 2 ++ modules/info/meta.nix | 5 +++-- 15 files changed, 33 insertions(+), 2 deletions(-) diff --git a/hosts/physiques/cephiroth/info.nix b/hosts/physiques/cephiroth/info.nix index e2f7b28..658f166 100644 --- a/hosts/physiques/cephiroth/info.nix +++ b/hosts/physiques/cephiroth/info.nix @@ -16,6 +16,10 @@ }; }; + resticClient.enable = false; + + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOsBGkhiu6l3jeo15cQHMu3dPyL025zXPV2ZH02EDYEt root@cephiroth"; + ilo = { id = 53; switch.salameche = 20; diff --git a/hosts/physiques/thot/info.nix b/hosts/physiques/thot/info.nix index e46cfc5..d4d7d86 100644 --- a/hosts/physiques/thot/info.nix +++ b/hosts/physiques/thot/info.nix @@ -13,5 +13,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFKNg1b8ft1L55+joXQ/7Dt2QTOdkea8opTEnq4xrhPU root@thot"; + resticClient.enable = false; } diff --git a/hosts/vm/apprentix/info.nix b/hosts/vm/apprentix/info.nix index f569b99..c5ce2fb 100644 --- a/hosts/vm/apprentix/info.nix +++ b/hosts/vm/apprentix/info.nix @@ -13,5 +13,7 @@ homeNounou.enable = false; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDCJV6jqQWEYuwi+OJ9r/4TbBN/cK9NvYWNiJhpFzcc7 root@apprentix"; + users.root.passwordFile = ../../../secrets/apprentix/root.age; } diff --git a/hosts/vm/collabora/info.nix b/hosts/vm/collabora/info.nix index ebe835a..a95b90d 100644 --- a/hosts/vm/collabora/info.nix +++ b/hosts/vm/collabora/info.nix @@ -21,5 +21,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFa2D9fREtO2r2oIx6q9JAKFUHtxGbgEPMjkx09DQSU8 root@collabora"; + resticClient.enable = false; } diff --git a/hosts/vm/coturn/info.nix b/hosts/vm/coturn/info.nix index 7d99a69..971c283 100644 --- a/hosts/vm/coturn/info.nix +++ b/hosts/vm/coturn/info.nix @@ -19,6 +19,8 @@ resticClient.when = "06:07"; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGoR66An5huQucZlueQCcB/vwd085wrS2mUIz39e8QLt root@coturn"; + services = { acme.enable = true; }; diff --git a/hosts/vm/jitsi/info.nix b/hosts/vm/jitsi/info.nix index 3b2b3f9..396f68b 100644 --- a/hosts/vm/jitsi/info.nix +++ b/hosts/vm/jitsi/info.nix @@ -19,6 +19,8 @@ resticClient.when = "02:34"; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB6jVMIZ5y2oXX9HOkw7r5UUjw95MlFaFuu7FnEC0Q8z root@jitsi"; + services = { acme.enable = true; }; diff --git a/hosts/vm/livre/info.nix b/hosts/vm/livre/info.nix index 8df46c7..0418b53 100644 --- a/hosts/vm/livre/info.nix +++ b/hosts/vm/livre/info.nix @@ -25,5 +25,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEVfKNokHG6ig32hhQxTep+fKFmKahlDClPrX/dP4/gb root@livre"; + resticClient.when = "03:45"; } diff --git a/hosts/vm/mediakiwi/info.nix b/hosts/vm/mediakiwi/info.nix index 9c83a63..d31ecfa 100644 --- a/hosts/vm/mediakiwi/info.nix +++ b/hosts/vm/mediakiwi/info.nix @@ -38,5 +38,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFfcKtim7Aj+strHdg847D7KCCdoOAuasxx/2yi2TY1n root@mediakiwi"; + resticClient.when = "06:47"; } diff --git a/hosts/vm/neo/info.nix b/hosts/vm/neo/info.nix index 07716d6..ff5d7b3 100644 --- a/hosts/vm/neo/info.nix +++ b/hosts/vm/neo/info.nix @@ -18,6 +18,8 @@ resticClient.when = "04:56"; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMGfSvxqC2PJYRrxJaivVDujwlwCZ6AwH8hOSA9ktZ1V root@neo"; + services = { acme.enable = true; }; diff --git a/hosts/vm/nextcloud/info.nix b/hosts/vm/nextcloud/info.nix index d6f900b..2a6033f 100644 --- a/hosts/vm/nextcloud/info.nix +++ b/hosts/vm/nextcloud/info.nix @@ -25,5 +25,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMgSP9UmuJw8Bi2ML07WHsWvxN8akkc9XZxXyOgdjXkq root@nextcloud"; + resticClient.enable = false; } diff --git a/hosts/vm/periodique/info.nix b/hosts/vm/periodique/info.nix index fa2da9b..3870bf1 100644 --- a/hosts/vm/periodique/info.nix +++ b/hosts/vm/periodique/info.nix @@ -23,5 +23,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHTdfSIL3AWIv0mjRDam6E/qsjoqwJ8QSm1Cb0xqs1s1 root@periodique"; + resticClient.when = "02:56"; } diff --git a/hosts/vm/reverseproxy/info.nix b/hosts/vm/reverseproxy/info.nix index da7699d..b013eb8 100644 --- a/hosts/vm/reverseproxy/info.nix +++ b/hosts/vm/reverseproxy/info.nix @@ -20,5 +20,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOx/lUQE6naP3EBy81sr93X8ktZmivU09ACx6T43Odhb root@reverseproxy"; + resticClient.when = "03:42"; } diff --git a/hosts/vm/two/info.nix b/hosts/vm/two/info.nix index c345d86..2cb06e2 100644 --- a/hosts/vm/two/info.nix +++ b/hosts/vm/two/info.nix @@ -12,5 +12,7 @@ }; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPpaGf8A+XWXBdNrs69RiC0qPbjPHdtkl31OjxrktmF6 root@two"; + resticClient.when = "07:29"; } diff --git a/hosts/vm/vaultwarden/info.nix b/hosts/vm/vaultwarden/info.nix index 6efcbf0..23c447a 100644 --- a/hosts/vm/vaultwarden/info.nix +++ b/hosts/vm/vaultwarden/info.nix @@ -21,5 +21,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICn6vfDlsZVU6TEWg9vTgq9+Fp3irHjytBTky7A4ErRM root@vaultwarden"; + resticClient.when = "04:44"; } diff --git a/modules/info/meta.nix b/modules/info/meta.nix index ef5cab8..ad18efb 100644 --- a/modules/info/meta.nix +++ b/modules/info/meta.nix @@ -35,8 +35,9 @@ in default = false; }; - public-ssh = mkOption { - type = types.str; + publicSsh = mkOption { + type = types.nullOr types.str; + default = null; description = "Clé ssh publique de la machine."; }; }; From ab370ae9fb4fe17511b14f12e2c4411fb07d46f8 Mon Sep 17 00:00:00 2001 From: Pyjacpp Date: Sat, 21 Nov 2026 18:56:55 +0100 Subject: [PATCH 7/7] feat: known hosts via les infos.nix --- hosts/physiques/cephiroth/info.nix | 1 + modules/crans/ssh.nix | 47 ++++++++++++++++++++++++++++-- modules/info/default.nix | 2 +- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/hosts/physiques/cephiroth/info.nix b/hosts/physiques/cephiroth/info.nix index 658f166..b0cc869 100644 --- a/hosts/physiques/cephiroth/info.nix +++ b/hosts/physiques/cephiroth/info.nix @@ -3,6 +3,7 @@ description = "Serveur de stockage ceph"; id = 3; + enable = true; # Sous Nix mais dans une autre branche isDebian = true; diff --git a/modules/crans/ssh.nix b/modules/crans/ssh.nix index 3bea073..57520fd 100644 --- a/modules/crans/ssh.nix +++ b/modules/crans/ssh.nix @@ -1,5 +1,19 @@ -{ ... }: - +{ + infra, + lib, + hosts, + ... +}: +let + inherit (lib) + attrNames + concatMap + optional + mapAttrs' + mkIf + nameValuePair + ; +in { services.openssh = { enable = true; @@ -7,5 +21,34 @@ settings = { PermitRootLogin = "yes"; }; + + # knownHosts : + # { + # "host" = { + # hostNames = ["host.adm.crans.org" 172.16.10.2 …] + # publicKey = "ssh-ed25519…" + # } + # } + knownHosts = mapAttrs' ( + n: conf: + nameValuePair n ( + mkIf (conf.publicSsh != null) { + publicKey = conf.publicSsh; + + hostNames = [ + "${n}.adm.crans.org" + ] + ++ concatMap ( + vlan: + let + netv = conf.networking.${vlan}; + in + optional (netv.enable && (netv.ipv4.address or null) != null) netv.ipv4.address + ++ optional (netv.enable && (netv.ipv6.address or null) != null) netv.ipv6.address + ) (attrNames infra.vlans); + } + ) + ) hosts; + }; } diff --git a/modules/info/default.nix b/modules/info/default.nix index 8fd8502..27bdfa0 100644 --- a/modules/info/default.nix +++ b/modules/info/default.nix @@ -27,7 +27,7 @@ in example = true; description = "Activer la configuration Crans par défaut"; # On n’utilise pas mkEnableOption pour forcer la définition de enable à true - # ou false (et limiter les oublis) + # ou false (et limiter les oublis). }; config = mkIf config.enable { homeNounou.enable = mkDefault true;