Add state-version option
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
./nixos-facter.nix
|
||||
./vm.nix
|
||||
./machine-id
|
||||
./state-version
|
||||
./wayland-proxy-virtwl.nix
|
||||
./zerotier
|
||||
./zfs.nix
|
||||
|
||||
31
nixosModules/clanCore/state-version/default.nix
Normal file
31
nixosModules/clanCore/state-version/default.nix
Normal 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
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
38
nixosModules/clanCore/state-version/tests/flake-module.nix
Normal file
38
nixosModules/clanCore/state-version/tests/flake-module.nix
Normal 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 = "";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"publickey": "age1qm0p4vf9jvcnn43s6l4prk8zn6cx0ep9gzvevxecv729xz540v8qa742eg",
|
||||
"type": "age"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
25.11
|
||||
Reference in New Issue
Block a user