From 58aad1b397dcf2f6b0205527931a191a131fe46c Mon Sep 17 00:00:00 2001 From: Pyjacpp Date: Wed, 11 Nov 2026 18:32:37 +0100 Subject: [PATCH] =?UTF-8?q?Suppression=20de=20la=20double=20=C3=A9valuatio?= =?UTF-8?q?n=20des=20info.nix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hosts/vm/coturn/livekit.nix | 4 ++-- lib/info.nix | 2 +- modules/crans/default.nix | 17 +++++------------ modules/crans/home.nix | 8 +++----- modules/crans/monitoring.nix | 5 +++-- modules/crans/networking.nix | 7 +++---- modules/crans/restic_client.nix | 9 +++++++-- modules/crans/users.nix | 4 ++-- modules/services/nginx.nix | 9 +++++++-- 9 files changed, 33 insertions(+), 32 deletions(-) diff --git a/hosts/vm/coturn/livekit.nix b/hosts/vm/coturn/livekit.nix index eee380c..8a1a320 100644 --- a/hosts/vm/coturn/livekit.nix +++ b/hosts/vm/coturn/livekit.nix @@ -5,7 +5,7 @@ # secrets de turn. # -{ config, pkgs, lib, ... }: +{ config, info, pkgs, lib, ... }: let keyFile = "/run/livekit.key"; @@ -24,7 +24,7 @@ in rtc = { use_external_ip = false; - node_ip = config.crans.info.networking.srv.ipv4.address; + node_ip = info.networking.srv.ipv4.address; tcp_port = 8101; port_range_start = 50000; port_range_end = 52000; diff --git a/lib/info.nix b/lib/info.nix index 03b9aeb..4ed4ea7 100644 --- a/lib/info.nix +++ b/lib/info.nix @@ -49,10 +49,10 @@ rec { specialArgs = inputs // { hosts = all_hosts; crans = cransConfig; + inherit info; }; modules = [ (path + "/${name}") - ({ ... }: { config.crans.info = info; }) ] ++ baseModules; } diff --git a/modules/crans/default.nix b/modules/crans/default.nix index be63606..469d5c7 100644 --- a/modules/crans/default.nix +++ b/modules/crans/default.nix @@ -2,12 +2,11 @@ lib, config, crans, + info, ... }: let - cfg = config.crans.info; - inherit (lib) mkOption mkIf @@ -34,19 +33,13 @@ in ./virtualisation.nix ]; - options.crans.info = mkOption { - type = types.submoduleWith { - modules = [ ../info ]; - specialArgs = { inherit crans; }; - }; - description = "Informations de la machines (info.nix)"; - }; + # Options ../info/meta.nix - config = mkIf cfg.enable { + config = mkIf info.enable { warnings = ( optional ( - cfg.isVm != (cfg.id >= 100) - ) "${cfg.name}: isVm (${toString cfg.isVm}) est incohérent avec son id (${toString cfg.id})" + info.isVm != (info.id >= 100) + ) "${info.name}: isVm (${toString info.isVm}) est incohérent avec son id (${toString info.id})" ); }; } diff --git a/modules/crans/home.nix b/modules/crans/home.nix index ffd5d8b..57cc051 100644 --- a/modules/crans/home.nix +++ b/modules/crans/home.nix @@ -1,8 +1,6 @@ -{ lib, config, ... }: +{ lib, info, ... }: let - cfg = config.crans.info; - inherit (lib) mkIf; in @@ -10,7 +8,7 @@ in # Options ../info/home.nix config = { fileSystems = { - home_nounou = mkIf cfg.homeNounou.enable { + home_nounou = mkIf info.homeNounou.enable { mountPoint = "/home_nounou"; device = "172.16.10.1:/pool/home"; fsType = "nfs"; @@ -20,7 +18,7 @@ in ]; }; - home_adh = mkIf cfg.homeAdh.enable { + home_adh = mkIf info.homeAdh.enable { mountPoint = "/home-adh"; device = "172.16.4.2:/pool/home"; fsType = "nfs"; diff --git a/modules/crans/monitoring.nix b/modules/crans/monitoring.nix index 81562c4..f0ee161 100644 --- a/modules/crans/monitoring.nix +++ b/modules/crans/monitoring.nix @@ -1,11 +1,12 @@ { config, + info, lib, ... }: let - cfg = config.crans.info.monitoring; + cfg = info.monitoring; nginxEnable = config.services.nginx.enable; inherit (lib) mkIf optional; @@ -18,7 +19,7 @@ in config = { warnings = optional (cfg.enable && (nginxEnable != cfg.nginx.enable)) '' - ${config.crans.info.name} : config.services.nginx.enable (${boolToStr nginxEnable}) n’est pas cohérent avec le monitoring déclaré dans l’info.nix (${boolToStr cfg.nginx.enable}) + ${info.name} : config.services.nginx.enable (${boolToStr nginxEnable}) n’est pas cohérent avec le monitoring déclaré dans l’info.nix (${boolToStr cfg.nginx.enable}) ''; services.prometheus.exporters = mkIf cfg.enable { diff --git a/modules/crans/networking.nix b/modules/crans/networking.nix index 37c8063..5e0ce50 100644 --- a/modules/crans/networking.nix +++ b/modules/crans/networking.nix @@ -1,13 +1,12 @@ { lib, - config, crans, + info, ... }: let - cfg = config.crans.info; - cfg-net = cfg.networking; + cfg-net = info.networking; inherit (lib) mkIf @@ -21,7 +20,7 @@ in # Options ../info/networking.nix config = mkIf cfg-net.enable { networking = { - hostName = cfg.name; + hostName = info.name; useDHCP = false; firewall.enable = mkDefault false; nameservers = [ diff --git a/modules/crans/restic_client.nix b/modules/crans/restic_client.nix index 7b0f1fa..05f530c 100644 --- a/modules/crans/restic_client.nix +++ b/modules/crans/restic_client.nix @@ -1,7 +1,12 @@ -{ config, lib, ... }: +{ + config, + info, + lib, + ... +}: let - cfg = config.crans.info.resticClient; + cfg = info.resticClient; inherit (lib) mkIf; in diff --git a/modules/crans/users.nix b/modules/crans/users.nix index 3e478cc..02802ee 100644 --- a/modules/crans/users.nix +++ b/modules/crans/users.nix @@ -1,6 +1,6 @@ -{ config, ... }: +{ config, info, ... }: let - cfg = config.crans.info.users; + cfg = info.users; in { # Options : ../info/users.nix diff --git a/modules/services/nginx.nix b/modules/services/nginx.nix index 2ae62c5..c4e61e7 100644 --- a/modules/services/nginx.nix +++ b/modules/services/nginx.nix @@ -1,7 +1,12 @@ -{ lib, config, ... }: +{ + lib, + config, + info, + ... +}: let - cfg = config.crans.info.monitoring; + cfg = info.monitoring; in { services.nginx = lib.mkIf config.services.nginx.enable {