Compare commits

...

2 commits

Author SHA1 Message Date
d1e661df5d nixosConfiguration: preSwitchCkeck: nvd 2025-11-26 19:51:13 +01:00
01106110fe automatically import ${namespace}.${class(es)} as modules
Allow to specify a list of classes in the host/<hostname>.nix (by
default the class <hostname> is used) that will automatically load
specified outputs of inputs.
2025-11-26 14:12:19 +01:00

View file

@ -10,11 +10,29 @@
{ ... }@inputs: { ... }@inputs:
{ host, ... }@imports: { host, ... }@imports:
let 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 = system =
hostname: hostname:
{ {
namespace ? "fbs42", namespace ? "fbs42",
nixpkgs ? "nixpkgs", nixpkgs ? "nixpkgs",
classes ? [ hostname ],
}: }:
inputs.${nixpkgs}.lib.nixosSystem { inputs.${nixpkgs}.lib.nixosSystem {
specialArgs = { inherit inputs flake namespace; }; specialArgs = { inherit inputs flake namespace; };
@ -24,6 +42,10 @@ let
base: builtins.attrValues (flake.lib.scan { base = "${base}/host/${hostname}"; }) base: builtins.attrValues (flake.lib.scan { base = "${base}/host/${hostname}"; })
) flake.lib.schema.base ) flake.lib.schema.base
) )
++ map (class: {
imports = map (input: input.${namespace}.${class} or { }) (builtins.attrValues inputs);
}) classes
++ [ pre-switch-check ]
++ [ { config.networking.hostName = hostname; } ] ++ [ { config.networking.hostName = hostname; } ]
++ [ nixosModules.default ] ++ [ nixosModules.default ]
++ inputs.${nixpkgs}.lib.optional (inputs ? home-manager) { ++ inputs.${nixpkgs}.lib.optional (inputs ? home-manager) {