Loading nixos/modules/misc/version.nix +76 −70 Original line number Diff line number Diff line Loading @@ -5,17 +5,21 @@ let opt = options.system.nixos; inherit (lib) concatStringsSep mapAttrsToList toLower concatStringsSep mapAttrsToList toLower optionalString literalExpression mkRenamedOptionModule mkDefault mkOption trivial types; needsEscaping = s: null != builtins.match "[a-zA-Z0-9]+" s; escapeIfNecessary = s: if needsEscaping s then s else ''"${lib.escape [ "\$" "\"" "\\" "\`" ] s}"''; attrsToText = attrs: concatStringsSep "\n" ( mapAttrsToList (n: v: ''${n}=${escapeIfNecessary (toString v)}'') attrs ) + "\n"; concatStringsSep "\n" (mapAttrsToList (n: v: ''${n}=${escapeIfNecessary (toString v)}'') attrs) + "\n"; osReleaseContents = { osReleaseContents = let isNixos = cfg.distroId == "nixos"; in { NAME = "${cfg.distroName}"; ID = "${cfg.distroId}"; VERSION = "${cfg.release} (${cfg.codeName})"; Loading @@ -24,12 +28,13 @@ let BUILD_ID = cfg.version; PRETTY_NAME = "${cfg.distroName} ${cfg.release} (${cfg.codeName})"; LOGO = "nix-snowflake"; HOME_URL = lib.optionalString (cfg.distroId == "nixos") "https://nixos.org/"; DOCUMENTATION_URL = lib.optionalString (cfg.distroId == "nixos") "https://nixos.org/learn.html"; SUPPORT_URL = lib.optionalString (cfg.distroId == "nixos") "https://nixos.org/community.html"; BUG_REPORT_URL = lib.optionalString (cfg.distroId == "nixos") "https://github.com/NixOS/nixpkgs/issues"; IMAGE_ID = lib.optionalString (config.system.image.id != null) config.system.image.id; IMAGE_VERSION = lib.optionalString (config.system.image.version != null) config.system.image.version; HOME_URL = optionalString isNixos "https://nixos.org/"; 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"; IMAGE_ID = optionalString (config.system.image.id != null) config.system.image.id; IMAGE_VERSION = optionalString (config.system.image.version != null) config.system.image.version; } // lib.optionalAttrs (cfg.variant_id != null) { VARIANT_ID = cfg.variant_id; }; Loading @@ -56,61 +61,62 @@ in }; options.system = { nixos.version = mkOption { nixos = { version = mkOption { internal = true; type = types.str; description = lib.mdDoc "The full NixOS version (e.g. `16.03.1160.f2d4ee1`)."; }; nixos.release = mkOption { release = mkOption { readOnly = true; type = types.str; default = trivial.release; description = lib.mdDoc "The NixOS release (e.g. `16.03`)."; }; nixos.versionSuffix = mkOption { versionSuffix = mkOption { internal = true; type = types.str; default = trivial.versionSuffix; description = lib.mdDoc "The NixOS version suffix (e.g. `1160.f2d4ee1`)."; }; nixos.revision = mkOption { revision = mkOption { internal = true; type = types.nullOr types.str; default = trivial.revisionWithDefault null; description = lib.mdDoc "The Git revision from which this NixOS configuration was built."; }; nixos.codeName = mkOption { codeName = mkOption { readOnly = true; type = types.str; default = trivial.codeName; description = lib.mdDoc "The NixOS release code name (e.g. `Emu`)."; }; nixos.distroId = mkOption { distroId = mkOption { internal = true; type = types.str; default = "nixos"; description = lib.mdDoc "The id of the operating system"; }; nixos.distroName = mkOption { distroName = mkOption { internal = true; type = types.str; default = "NixOS"; description = lib.mdDoc "The name of the operating system"; }; nixos.variant_id = mkOption { 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"; }; }; image = { Loading Loading
nixos/modules/misc/version.nix +76 −70 Original line number Diff line number Diff line Loading @@ -5,17 +5,21 @@ let opt = options.system.nixos; inherit (lib) concatStringsSep mapAttrsToList toLower concatStringsSep mapAttrsToList toLower optionalString literalExpression mkRenamedOptionModule mkDefault mkOption trivial types; needsEscaping = s: null != builtins.match "[a-zA-Z0-9]+" s; escapeIfNecessary = s: if needsEscaping s then s else ''"${lib.escape [ "\$" "\"" "\\" "\`" ] s}"''; attrsToText = attrs: concatStringsSep "\n" ( mapAttrsToList (n: v: ''${n}=${escapeIfNecessary (toString v)}'') attrs ) + "\n"; concatStringsSep "\n" (mapAttrsToList (n: v: ''${n}=${escapeIfNecessary (toString v)}'') attrs) + "\n"; osReleaseContents = { osReleaseContents = let isNixos = cfg.distroId == "nixos"; in { NAME = "${cfg.distroName}"; ID = "${cfg.distroId}"; VERSION = "${cfg.release} (${cfg.codeName})"; Loading @@ -24,12 +28,13 @@ let BUILD_ID = cfg.version; PRETTY_NAME = "${cfg.distroName} ${cfg.release} (${cfg.codeName})"; LOGO = "nix-snowflake"; HOME_URL = lib.optionalString (cfg.distroId == "nixos") "https://nixos.org/"; DOCUMENTATION_URL = lib.optionalString (cfg.distroId == "nixos") "https://nixos.org/learn.html"; SUPPORT_URL = lib.optionalString (cfg.distroId == "nixos") "https://nixos.org/community.html"; BUG_REPORT_URL = lib.optionalString (cfg.distroId == "nixos") "https://github.com/NixOS/nixpkgs/issues"; IMAGE_ID = lib.optionalString (config.system.image.id != null) config.system.image.id; IMAGE_VERSION = lib.optionalString (config.system.image.version != null) config.system.image.version; HOME_URL = optionalString isNixos "https://nixos.org/"; 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"; IMAGE_ID = optionalString (config.system.image.id != null) config.system.image.id; IMAGE_VERSION = optionalString (config.system.image.version != null) config.system.image.version; } // lib.optionalAttrs (cfg.variant_id != null) { VARIANT_ID = cfg.variant_id; }; Loading @@ -56,61 +61,62 @@ in }; options.system = { nixos.version = mkOption { nixos = { version = mkOption { internal = true; type = types.str; description = lib.mdDoc "The full NixOS version (e.g. `16.03.1160.f2d4ee1`)."; }; nixos.release = mkOption { release = mkOption { readOnly = true; type = types.str; default = trivial.release; description = lib.mdDoc "The NixOS release (e.g. `16.03`)."; }; nixos.versionSuffix = mkOption { versionSuffix = mkOption { internal = true; type = types.str; default = trivial.versionSuffix; description = lib.mdDoc "The NixOS version suffix (e.g. `1160.f2d4ee1`)."; }; nixos.revision = mkOption { revision = mkOption { internal = true; type = types.nullOr types.str; default = trivial.revisionWithDefault null; description = lib.mdDoc "The Git revision from which this NixOS configuration was built."; }; nixos.codeName = mkOption { codeName = mkOption { readOnly = true; type = types.str; default = trivial.codeName; description = lib.mdDoc "The NixOS release code name (e.g. `Emu`)."; }; nixos.distroId = mkOption { distroId = mkOption { internal = true; type = types.str; default = "nixos"; description = lib.mdDoc "The id of the operating system"; }; nixos.distroName = mkOption { distroName = mkOption { internal = true; type = types.str; default = "NixOS"; description = lib.mdDoc "The name of the operating system"; }; nixos.variant_id = mkOption { 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"; }; }; image = { Loading