os-release: add stockholm-version-id option

This commit is contained in:
tv 2024-03-19 14:42:32 +01:00
parent f64e3d14d2
commit c260c4a1de

View File

@ -8,21 +8,26 @@ let
nixos-version = "${nixos-version-id} (${nixos-codeName})"; nixos-version = "${nixos-version-id} (${nixos-codeName})";
nixos-pretty-name = "NixOS ${nixos-version}"; nixos-pretty-name = "NixOS ${nixos-version}";
stockholm-version-id = let stockholm-version = "${config.krebs.os-release.stockholm-version-id}";
eval = builtins.tryEval (removeSuffix "\n" (readFile <stockholm-version>));
in
if eval.success then eval.value else "unknown";
stockholm-version = "${stockholm-version-id}";
stockholm-pretty-name = "stockholm ${stockholm-version}"; stockholm-pretty-name = "stockholm ${stockholm-version}";
version = "${stockholm-version}/${nixos-version}"; version = "${stockholm-version}/${nixos-version}";
version-id = "${stockholm-version-id}/${nixos-version-id}"; version-id = "${config.krebs.os-release.stockholm-version-id}/${nixos-version-id}";
pretty-name = "${stockholm-pretty-name} / ${nixos-pretty-name}"; pretty-name = "${stockholm-pretty-name} / ${nixos-pretty-name}";
home-url = http://cgit.ni.krebsco.de/stockholm; home-url = http://cgit.ni.krebsco.de/stockholm;
in in
{ {
options.krebs.os-release = {
stockholm-version-id = lib.mkOption {
type = lib.types.str;
default = let
eval = builtins.tryEval (removeSuffix "\n" (readFile <stockholm-version>));
in
if eval.success then eval.value else "unknown";
};
};
config = {
# http://0pointer.de/public/systemd-man/os-release.html # http://0pointer.de/public/systemd-man/os-release.html
environment.etc."os-release".text = mkForce '' environment.etc."os-release".text = mkForce ''
NAME="stockholm/NixOS" NAME="stockholm/NixOS"
@ -32,4 +37,5 @@ in
PRETTY_NAME="${pretty-name}" PRETTY_NAME="${pretty-name}"
HOME_URL="${home-url}" HOME_URL="${home-url}"
''; '';
};
} }