From c260c4a1de0a4c2a129b136932f4cb8ecb074c57 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 19 Mar 2024 14:42:32 +0100 Subject: [PATCH] os-release: add stockholm-version-id option --- krebs/3modules/os-release.nix | 38 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/krebs/3modules/os-release.nix b/krebs/3modules/os-release.nix index bfd352825..929ec45d9 100644 --- a/krebs/3modules/os-release.nix +++ b/krebs/3modules/os-release.nix @@ -8,28 +8,34 @@ let nixos-version = "${nixos-version-id} (${nixos-codeName})"; nixos-pretty-name = "NixOS ${nixos-version}"; - stockholm-version-id = let - eval = builtins.tryEval (removeSuffix "\n" (readFile )); - in - if eval.success then eval.value else "unknown"; - - stockholm-version = "${stockholm-version-id}"; + stockholm-version = "${config.krebs.os-release.stockholm-version-id}"; stockholm-pretty-name = "stockholm ${stockholm-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}"; home-url = http://cgit.ni.krebsco.de/stockholm; in { - # 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}" - ''; + options.krebs.os-release = { + stockholm-version-id = lib.mkOption { + type = lib.types.str; + default = let + eval = builtins.tryEval (removeSuffix "\n" (readFile )); + in + if eval.success then eval.value else "unknown"; + }; + }; + 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}" + ''; + }; }