From b4d7b9ade25a49c1a2e77e94b7076ce848b61879 Mon Sep 17 00:00:00 2001 From: Fernando Rodrigues Date: Sun, 27 Oct 2024 19:14:48 +0000 Subject: [PATCH 1/2] nixos/version: use 24-bit ANSI colour code It's almost 2025; we don't need to use 3-bit colour anymore. Let's use the proper colour code for NixOS' light blue: https://github.com/NixOS/nixos-artwork/blob/ea1384e183f556a94df85c7aa1dcd411f5a69646/logo/README.md#colours Signed-off-by: Fernando Rodrigues --- nixos/modules/misc/version.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index 9e9d5f9de4e7..8b6f3b0bfe14 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -36,7 +36,7 @@ let DOCUMENTATION_URL = optionalString isNixos "https://nixos.org/learn.html"; SUPPORT_URL = optionalString isNixos "https://nixos.org/community.html"; BUG_REPORT_URL = optionalString isNixos "https://github.com/NixOS/nixpkgs/issues"; - ANSI_COLOR = optionalString isNixos "1;34"; + ANSI_COLOR = optionalString isNixos "0;38;2;126;186;228"; IMAGE_ID = optionalString (config.system.image.id != null) config.system.image.id; IMAGE_VERSION = optionalString (config.system.image.version != null) config.system.image.version; VARIANT = optionalString (cfg.variantName != null) cfg.variantName; From 02e1f93cb4e713fd56f27445be69b6a6cf12860d Mon Sep 17 00:00:00 2001 From: Fernando Rodrigues Date: Thu, 31 Oct 2024 22:31:40 +0000 Subject: [PATCH 2/2] nixos/version: add extraOSReleaseArgs and extraLSBReleaseArgs A free-form `attrsOf str` option that is merged with the /etc/os-release builder, allowing downstreams to customise arbitrary os-release fields. This is separate from the variant option, as using an attribute set merge means one gets an infinte recursion when making extraOSReleaseArgs a recursive set, and the variant attribute is useful to define elsewhere or multiple times. Ditto for /etc/lsb-release. Signed-off-by: Fernando Rodrigues --- nixos/modules/misc/version.nix | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index 8b6f3b0bfe14..2a982b254def 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -42,8 +42,7 @@ let VARIANT = optionalString (cfg.variantName != null) cfg.variantName; VARIANT_ID = optionalString (cfg.variant_id != null) cfg.variant_id; DEFAULT_HOSTNAME = config.system.nixos.distroId; - SUPPORT_END = "2025-06-30"; - }; + } // cfg.extraOSReleaseArgs; initrdReleaseContents = (removeAttrs osReleaseContents [ "BUILD_ID" ]) // { PRETTY_NAME = "${osReleaseContents.PRETTY_NAME} (Initrd)"; @@ -143,6 +142,26 @@ in default = "NixOS"; description = "The name of the operating system vendor"; }; + + extraOSReleaseArgs = mkOption { + internal = true; + type = types.attrsOf types.str; + default = { }; + description = "Additional attributes to be merged with the /etc/os-release generator."; + example = { + ANSI_COLOR = "1;31"; + }; + }; + + extraLSBReleaseArgs = mkOption { + internal = true; + type = types.attrsOf types.str; + default = { }; + description = "Additional attributes to be merged with the /etc/lsb-release generator."; + example = { + LSB_VERSION = "1.0"; + }; + }; }; image = { @@ -237,13 +256,13 @@ in # https://www.freedesktop.org/software/systemd/man/os-release.html for the # format. environment.etc = { - "lsb-release".text = attrsToText { + "lsb-release".text = attrsToText ({ LSB_VERSION = "${cfg.release} (${cfg.codeName})"; DISTRIB_ID = "${cfg.distroId}"; DISTRIB_RELEASE = cfg.release; DISTRIB_CODENAME = toLower cfg.codeName; DISTRIB_DESCRIPTION = "${cfg.distroName} ${cfg.release} (${cfg.codeName})"; - }; + } // cfg.extraLSBReleaseArgs); "os-release".text = attrsToText osReleaseContents; };