Add state-version option

This commit is contained in:
pinpox
2025-06-30 11:32:44 +02:00
parent ef3c22f240
commit 507152a1cc
6 changed files with 76 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ in
imports = filter pathExists [
./backups/flake-module.nix
../nixosModules/clanCore/machine-id/tests/flake-module.nix
../nixosModules/clanCore/state-version/tests/flake-module.nix
./devshell/flake-module.nix
./flash/flake-module.nix
./impure/flake-module.nix

View File

@@ -19,6 +19,7 @@
./nixos-facter.nix
./vm.nix
./machine-id
./state-version
./wayland-proxy-virtwl.nix
./zerotier
./zfs.nix

View File

@@ -0,0 +1,31 @@
{
lib,
config,
...
}:
let
var = config.clan.core.vars.generators.state-version.files.version or { };
in
{
options.clan.core.settings.state-version = {
enable = lib.mkEnableOption "automatic state-version generation.
The option will take the specified version, if one is already supplied through
the config or generate one if not.
";
};
config = lib.mkIf (config.clan.core.settings.state-version.enable) {
system.stateVersion = lib.mkDefault (lib.removeSuffix "\n" var.value);
clan.core.vars.generators.state-version = {
files.version = {
secret = false;
value = lib.mkDefault config.system.nixos.release;
};
runtimeInputs = [ ];
script = ''
echo -n ${config.system.stateVersion} > "$out"/version
'';
};
};
}

View File

@@ -0,0 +1,38 @@
{ ... }:
{
perSystem =
{ ... }:
{
clan.nixosTests.state-version = {
name = "state-version";
clan = {
directory = ./.;
# Workaround until we can use nodes.server = { };
modules."@clan/importer" = ../../../../clanServices/importer;
inventory = {
machines.server = { };
instances.importer = {
module.name = "@clan/importer";
roles.default.tags.all = { };
roles.default.extraModules = [
{
clan.core.settings.state-version.enable = true;
}
];
};
};
};
# TODO: Broken. Use instead of importer after fixing.
# nodes.server = { };
# This is not an actual vm test, this is a workaround to
# generate the needed vars for the eval test.
testScript = "";
};
};
}

View File

@@ -0,0 +1,4 @@
{
"publickey": "age1qm0p4vf9jvcnn43s6l4prk8zn6cx0ep9gzvevxecv729xz540v8qa742eg",
"type": "age"
}