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,28 +8,34 @@ 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
{ {
# http://0pointer.de/public/systemd-man/os-release.html options.krebs.os-release = {
environment.etc."os-release".text = mkForce '' stockholm-version-id = lib.mkOption {
NAME="stockholm/NixOS" type = lib.types.str;
ID=stockholm default = let
VERSION="${version}" eval = builtins.tryEval (removeSuffix "\n" (readFile <stockholm-version>));
VERSION_ID="${version-id}" in
PRETTY_NAME="${pretty-name}" if eval.success then eval.value else "unknown";
HOME_URL="${home-url}" };
''; };
config = {
# http://0pointer.de/public/systemd-man/os-release.html
environment.etc."os-release".text = mkForce ''
NAME="stockholm/NixOS"
ID=stockholm
VERSION="${version}"
VERSION_ID="${version-id}"
PRETTY_NAME="${pretty-name}"
HOME_URL="${home-url}"
'';
};
} }