From 5464e0a0182603b13d9d8779bffb417e01b1273f Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 4 Jan 2023 18:14:12 +0100 Subject: nixos/misc: add VARIANT_ID in /etc/os-release for identifying nixos installer This is a feature useful for nixos-remote and other installation tools that try to identify if the remote machine has been successfully booted into an installer. --- nixos/modules/misc/version.nix | 9 +++++++++ nixos/modules/profiles/installation-device.nix | 1 + 2 files changed, 10 insertions(+) diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index 1067b21a22b07..c9e06382b7ac2 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -28,6 +28,8 @@ let DOCUMENTATION_URL = "https://nixos.org/learn.html"; SUPPORT_URL = "https://nixos.org/community.html"; BUG_REPORT_URL = "https://github.com/NixOS/nixpkgs/issues"; + } // lib.optionalAttrs (cfg.variant_id != null) { + VARIANT_ID = cfg.variant_id; }; initrdReleaseContents = osReleaseContents // { @@ -87,6 +89,13 @@ in description = lib.mdDoc "The NixOS release code name (e.g. `Emu`)."; }; + nixos.variant_id = mkOption { + type = types.nullOr (types.strMatching "^[a-z0-9._-]+$"); + default = null; + description = lib.mdDoc "A lower-case string identifying a specific variant or edition of the operating system"; + example = "installer"; + }; + stateVersion = mkOption { type = types.str; # TODO Remove this and drop the default of the option so people are forced to set it. diff --git a/nixos/modules/profiles/installation-device.nix b/nixos/modules/profiles/installation-device.nix index ae9be08c8d859..4d9bd69666c09 100644 --- a/nixos/modules/profiles/installation-device.nix +++ b/nixos/modules/profiles/installation-device.nix @@ -20,6 +20,7 @@ with lib; ]; config = { + system.nixos.variant_id = lib.mkDefault "installer"; # Enable in installer, even if the minimal profile disables it. documentation.enable = mkImageMediaOverride true; -- cgit 1.4.1