stockholm/krebs/3modules/os-release.nix

42 lines
1.4 KiB
Nix
Raw Normal View History

2023-06-10 10:50:53 +00:00
{ config, lib, ... }:
with lib;
2016-03-05 11:40:20 +00:00
let
2018-03-18 16:31:59 +00:00
nixos-version-id = if (hasAttr "nixos" config.system) then
"${config.system.nixos.version}" else "${config.system.nixosVersion}";
nixos-codeName = if (hasAttr "nixos" config.system) then
"${config.system.nixos.codeName}" else "${config.system.nixosCodeName}";
nixos-version = "${nixos-version-id} (${nixos-codeName})";
2016-03-05 11:40:20 +00:00
nixos-pretty-name = "NixOS ${nixos-version}";
stockholm-version = "${config.krebs.os-release.stockholm-version-id}";
2016-03-05 11:40:20 +00:00
stockholm-pretty-name = "stockholm ${stockholm-version}";
version = "${stockholm-version}/${nixos-version}";
version-id = "${config.krebs.os-release.stockholm-version-id}/${nixos-version-id}";
2016-03-05 11:40:20 +00:00
pretty-name = "${stockholm-pretty-name} / ${nixos-pretty-name}";
2016-11-10 22:15:33 +00:00
home-url = http://cgit.ni.krebsco.de/stockholm;
2016-03-05 11:40:20 +00:00
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
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}"
'';
};
2016-03-05 11:40:20 +00:00
}