From 01106110fe027fd6bf93dad3f7e4652ef86321fb Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Wed, 26 Nov 2025 02:40:42 +0100 Subject: [PATCH 1/3] automatically import ${namespace}.${class(es)} as modules Allow to specify a list of classes in the host/.nix (by default the class is used) that will automatically load specified outputs of inputs. --- export/nixosConfigurations.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/export/nixosConfigurations.nix b/export/nixosConfigurations.nix index f8dba98..eb8c570 100644 --- a/export/nixosConfigurations.nix +++ b/export/nixosConfigurations.nix @@ -15,6 +15,7 @@ let { namespace ? "fbs42", nixpkgs ? "nixpkgs", + classes ? [ hostname ], }: inputs.${nixpkgs}.lib.nixosSystem { specialArgs = { inherit inputs flake namespace; }; @@ -24,6 +25,9 @@ let base: builtins.attrValues (flake.lib.scan { base = "${base}/host/${hostname}"; }) ) flake.lib.schema.base ) + ++ map (class: { + imports = map (input: input.${namespace}.${class} or { }) (builtins.attrValues inputs); + }) classes ++ [ { config.networking.hostName = hostname; } ] ++ [ nixosModules.default ] ++ inputs.${nixpkgs}.lib.optional (inputs ? home-manager) { From 1df1a59788b96b19e520c41d8eced0480e85bd32 Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Wed, 26 Nov 2025 15:58:37 +0100 Subject: [PATCH 2/3] nixosConfiguration: preSwitchCkeck: nvd --- export/nixosConfigurations.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/export/nixosConfigurations.nix b/export/nixosConfigurations.nix index f8dba98..9c52a84 100644 --- a/export/nixosConfigurations.nix +++ b/export/nixosConfigurations.nix @@ -10,6 +10,21 @@ { ... }@inputs: { host, ... }@imports: let + pre-switch-check = + { pkgs, lib, config, ... }: + { + config.system.preSwitchChecks.nvd = '' + ${lib.getExe pkgs.nvd} --nix-bin-dir ${config.nix.package}/bin diff /run/current-system "''${1}" + if [[ -t 0 ]]; then + printf 'really %s to %s? [y]es/[N]o ' "''${2}" "''${1}" + read -r nvd_check + else + nvd_check=y + fi + [[ "''${nvd_check}" == y ]] + ''; + }; + system = hostname: { @@ -24,6 +39,7 @@ let base: builtins.attrValues (flake.lib.scan { base = "${base}/host/${hostname}"; }) ) flake.lib.schema.base ) + ++ [ pre-switch-check ] ++ [ { config.networking.hostName = hostname; } ] ++ [ nixosModules.default ] ++ inputs.${nixpkgs}.lib.optional (inputs ? home-manager) { From d1e661df5d4ed4d754ecf3b93af65964f3617b47 Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Wed, 26 Nov 2025 15:58:37 +0100 Subject: [PATCH 3/3] nixosConfiguration: preSwitchCkeck: nvd --- export/nixosConfigurations.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/export/nixosConfigurations.nix b/export/nixosConfigurations.nix index eb8c570..21e8a45 100644 --- a/export/nixosConfigurations.nix +++ b/export/nixosConfigurations.nix @@ -10,6 +10,23 @@ { ... }@inputs: { host, ... }@imports: let + pre-switch-check = + { pkgs, lib, config, ... }: + { + config.system.preSwitchChecks.nvd = '' + nvd_check=y + if [[ -d /run/current-system ]] + then + ${lib.getExe pkgs.nvd} --nix-bin-dir ${config.nix.package}/bin diff /run/current-system "''${1}" + if [[ -t 0 ]]; then + printf 'really %s to %s? [y]es/[N]o ' "''${2}" "''${1}" + read -r nvd_check + fi + fi + [[ "''${nvd_check}" == y ]] + ''; + }; + system = hostname: { @@ -28,6 +45,7 @@ let ++ map (class: { imports = map (input: input.${namespace}.${class} or { }) (builtins.attrValues inputs); }) classes + ++ [ pre-switch-check ] ++ [ { config.networking.hostName = hostname; } ] ++ [ nixosModules.default ] ++ inputs.${nixpkgs}.lib.optional (inputs ? home-manager) {