Revert "Merge pull request 'Make state-version generation an clan option' (#4056) from state-version-option into main"
This reverts commit8a7b6d13b5, reversing changes made to7a4eeb5b16.
This commit is contained in:
@@ -22,7 +22,6 @@ in
|
|||||||
imports = filter pathExists [
|
imports = filter pathExists [
|
||||||
./backups/flake-module.nix
|
./backups/flake-module.nix
|
||||||
../nixosModules/clanCore/machine-id/tests/flake-module.nix
|
../nixosModules/clanCore/machine-id/tests/flake-module.nix
|
||||||
../nixosModules/clanCore/state-version/tests/flake-module.nix
|
|
||||||
./devshell/flake-module.nix
|
./devshell/flake-module.nix
|
||||||
./flash/flake-module.nix
|
./flash/flake-module.nix
|
||||||
./impure/flake-module.nix
|
./impure/flake-module.nix
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ in
|
|||||||
root-password = ./root-password;
|
root-password = ./root-password;
|
||||||
single-disk = ./single-disk;
|
single-disk = ./single-disk;
|
||||||
sshd = ./sshd;
|
sshd = ./sshd;
|
||||||
|
state-version = ./state-version;
|
||||||
static-hosts = ./static-hosts;
|
static-hosts = ./static-hosts;
|
||||||
sunshine = ./sunshine;
|
sunshine = ./sunshine;
|
||||||
syncthing = ./syncthing;
|
syncthing = ./syncthing;
|
||||||
|
|||||||
18
clanModules/state-version/README.md
Normal file
18
clanModules/state-version/README.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
description = "Automatically generate the state version of the nixos installation."
|
||||||
|
features = [ "inventory", "deprecated" ]
|
||||||
|
---
|
||||||
|
|
||||||
|
This module generates the `system.stateVersion` of the nixos installation automatically.
|
||||||
|
|
||||||
|
Options: [system.stateVersion](https://search.nixos.org/options?channel=unstable&show=system.stateVersion&from=0&size=50&sort=relevance&type=packages&query=stateVersion)
|
||||||
|
|
||||||
|
Migration:
|
||||||
|
If you are already setting `system.stateVersion`, then import the module and then either let the automatic generation happen, or trigger the generation manually for the machine. The module will take the specified version, if one is already supplied through the config.
|
||||||
|
To manually generate the version for a specified machine run:
|
||||||
|
|
||||||
|
```
|
||||||
|
clan vars generate [MACHINE]
|
||||||
|
```
|
||||||
|
|
||||||
|
If the setting was already set you can then remove `system.stateVersion` from your machine configuration. For new machines, just import the module.
|
||||||
6
clanModules/state-version/default.nix
Normal file
6
clanModules/state-version/default.nix
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Dont import this file
|
||||||
|
# It is only here for backwards compatibility.
|
||||||
|
# Dont author new modules with this file.
|
||||||
|
{
|
||||||
|
imports = [ ./roles/default.nix ];
|
||||||
|
}
|
||||||
25
clanModules/state-version/roles/default.nix
Normal file
25
clanModules/state-version/roles/default.nix
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
var = config.clan.core.vars.generators.state-version.files.version or { };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
|
||||||
|
warnings = [
|
||||||
|
"The clan.state-version module is deprecated and will be removed on 2025-07-15.
|
||||||
|
Please migrate to user-maintained configuration or the new equivalent clan services
|
||||||
|
(https://docs.clan.lol/reference/clanServices)."
|
||||||
|
];
|
||||||
|
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
37
clanServices/state-version/README.md
Normal file
37
clanServices/state-version/README.md
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
This service generates the `system.stateVersion` of the nixos installation
|
||||||
|
automatically.
|
||||||
|
|
||||||
|
Possible values:
|
||||||
|
[system.stateVersion](https://search.nixos.org/options?channel=unstable&show=system.stateVersion&from=0&size=50&sort=relevance&type=packages&query=stateVersion)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
The following configuration will set `stateVersion` for all machines:
|
||||||
|
|
||||||
|
```
|
||||||
|
inventory.instances = {
|
||||||
|
state-version = {
|
||||||
|
module = {
|
||||||
|
name = "state-version";
|
||||||
|
input = "clan";
|
||||||
|
};
|
||||||
|
roles.default.tags.all = { };
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
## Migration
|
||||||
|
|
||||||
|
If you are already setting `system.stateVersion`, either let the automatic
|
||||||
|
generation happen, or trigger the generation manually for the machine. The
|
||||||
|
service will take the specified version, if one is already supplied through the
|
||||||
|
config.
|
||||||
|
|
||||||
|
To manually generate the version for a specified machine run:
|
||||||
|
|
||||||
|
```
|
||||||
|
clan vars generate [MACHINE]
|
||||||
|
```
|
||||||
|
|
||||||
|
If the setting was already set, you can then remove `system.stateVersion` from
|
||||||
|
your machine configuration. For new machines, just import the service as shown
|
||||||
|
above.
|
||||||
39
clanServices/state-version/default.nix
Normal file
39
clanServices/state-version/default.nix
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
_class = "clan.service";
|
||||||
|
manifest.name = "clan-core/state-version";
|
||||||
|
manifest.description = "Automatically generate the state version of the nixos installation.";
|
||||||
|
manifest.categories = [ "System" ];
|
||||||
|
|
||||||
|
roles.default = {
|
||||||
|
|
||||||
|
perInstance =
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
nixosModule =
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
var = config.clan.core.vars.generators.state-version.files.version or { };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
16
clanServices/state-version/flake-module.nix
Normal file
16
clanServices/state-version/flake-module.nix
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
module = lib.modules.importApply ./default.nix { };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
clan.modules.state-version = module;
|
||||||
|
perSystem =
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
clan.nixosTests.state-version = {
|
||||||
|
imports = [ ./tests/vm/default.nix ];
|
||||||
|
|
||||||
|
clan.modules."@clan/state-version" = module;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
21
clanServices/state-version/tests/vm/default.nix
Normal file
21
clanServices/state-version/tests/vm/default.nix
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
name = "state-version";
|
||||||
|
|
||||||
|
clan = {
|
||||||
|
directory = ./.;
|
||||||
|
inventory = {
|
||||||
|
machines.server = { };
|
||||||
|
instances.default = {
|
||||||
|
module.name = "@clan/state-version";
|
||||||
|
module.input = "self";
|
||||||
|
roles.default.machines."server" = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nodes.server = { };
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
start_all()
|
||||||
|
'';
|
||||||
|
}
|
||||||
@@ -92,6 +92,7 @@ nav:
|
|||||||
- reference/clanServices/mycelium.md
|
- reference/clanServices/mycelium.md
|
||||||
- reference/clanServices/packages.md
|
- reference/clanServices/packages.md
|
||||||
- reference/clanServices/sshd.md
|
- reference/clanServices/sshd.md
|
||||||
|
- reference/clanServices/state-version.md
|
||||||
- reference/clanServices/trusted-nix-caches.md
|
- reference/clanServices/trusted-nix-caches.md
|
||||||
- reference/clanServices/users.md
|
- reference/clanServices/users.md
|
||||||
- reference/clanServices/wifi.md
|
- reference/clanServices/wifi.md
|
||||||
@@ -126,6 +127,7 @@ nav:
|
|||||||
- reference/clanModules/root-password.md
|
- reference/clanModules/root-password.md
|
||||||
- reference/clanModules/single-disk.md
|
- reference/clanModules/single-disk.md
|
||||||
- reference/clanModules/sshd.md
|
- reference/clanModules/sshd.md
|
||||||
|
- reference/clanModules/state-version.md
|
||||||
- reference/clanModules/static-hosts.md
|
- reference/clanModules/static-hosts.md
|
||||||
- reference/clanModules/sunshine.md
|
- reference/clanModules/sunshine.md
|
||||||
- reference/clanModules/syncthing-static-peers.md
|
- reference/clanModules/syncthing-static-peers.md
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
./nixos-facter.nix
|
./nixos-facter.nix
|
||||||
./vm.nix
|
./vm.nix
|
||||||
./machine-id
|
./machine-id
|
||||||
./state-version
|
|
||||||
./wayland-proxy-virtwl.nix
|
./wayland-proxy-virtwl.nix
|
||||||
./zerotier
|
./zerotier
|
||||||
./zfs.nix
|
./zfs.nix
|
||||||
|
|||||||
@@ -63,7 +63,17 @@ def create_base_inventory(ssh_keys_pairs: list[SSHKeyPair]) -> InventoryWrapper:
|
|||||||
ssh_keys.append(InvSSHKeyEntry(f"user_{num}", ssh_key.public.read_text()))
|
ssh_keys.append(InvSSHKeyEntry(f"user_{num}", ssh_key.public.read_text()))
|
||||||
|
|
||||||
"""Create the base inventory structure."""
|
"""Create the base inventory structure."""
|
||||||
legacy_services: dict[str, Any] = {}
|
legacy_services: dict[str, Any] = {
|
||||||
|
"state-version": {
|
||||||
|
"someid": {
|
||||||
|
"roles": {
|
||||||
|
"default": {
|
||||||
|
"tags": ["all"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
instances = InventoryInstancesType(
|
instances = InventoryInstancesType(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
# Set a root password
|
# Set a root password
|
||||||
clan-core.clanModules.root-password
|
clan-core.clanModules.root-password
|
||||||
clan-core.clanModules.user-password
|
clan-core.clanModules.user-password
|
||||||
|
clan-core.clanModules.state-version
|
||||||
|
|
||||||
# You can access other flakes imported in your flake via `self` like this:
|
# You can access other flakes imported in your flake via `self` like this:
|
||||||
# self.inputs.nix-index-database.nixosModules.nix-index
|
# self.inputs.nix-index-database.nixosModules.nix-index
|
||||||
|
|||||||
Reference in New Issue
Block a user