nixosConfiguration: preSwitchCkeck: nvd

This commit is contained in:
Jonas Rabenstein 2025-11-26 15:58:37 +01:00
commit 1df1a59788

View file

@ -10,6 +10,21 @@
{ ... }@inputs: { ... }@inputs:
{ host, ... }@imports: { host, ... }@imports:
let 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 = system =
hostname: hostname:
{ {
@ -24,6 +39,7 @@ 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
) )
++ [ 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) {