Unverified Commit d3528cdc authored by Victor Fuentes's avatar Victor Fuentes
Browse files

nixos/version: add config.system.nixos.distroName and config.system.nixos.distroId

parent c9c4aea7
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ let
  buildMenuAdditionalParamsGrub2 = additional:
  let
    finalCfg = {
      name = "NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel}";
      name = "${config.system.nixos.distroName} ${config.system.nixos.label}${config.isoImage.appendToMenuLabel}";
      params = "init=${config.system.build.toplevel}/init ${additional} ${toString config.boot.kernelParams}";
      image = "/boot/${config.system.boot.loader.kernelFile}";
      initrd = "/boot/initrd";
@@ -109,35 +109,35 @@ let
    DEFAULT boot

    LABEL boot
    MENU LABEL NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel}
    MENU LABEL ${config.system.nixos.distroName} ${config.system.nixos.label}${config.isoImage.appendToMenuLabel}
    LINUX /boot/${config.system.boot.loader.kernelFile}
    APPEND init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}
    INITRD /boot/${config.system.boot.loader.initrdFile}

    # A variant to boot with 'nomodeset'
    LABEL boot-nomodeset
    MENU LABEL NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel} (nomodeset)
    MENU LABEL ${config.system.nixos.distroName} ${config.system.nixos.label}${config.isoImage.appendToMenuLabel} (nomodeset)
    LINUX /boot/${config.system.boot.loader.kernelFile}
    APPEND init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} nomodeset
    INITRD /boot/${config.system.boot.loader.initrdFile}

    # A variant to boot with 'copytoram'
    LABEL boot-copytoram
    MENU LABEL NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel} (copytoram)
    MENU LABEL ${config.system.nixos.distroName} ${config.system.nixos.label}${config.isoImage.appendToMenuLabel} (copytoram)
    LINUX /boot/${config.system.boot.loader.kernelFile}
    APPEND init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} copytoram
    INITRD /boot/${config.system.boot.loader.initrdFile}

    # A variant to boot with verbose logging to the console
    LABEL boot-debug
    MENU LABEL NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel} (debug)
    MENU LABEL ${config.system.nixos.distroName} ${config.system.nixos.label}${config.isoImage.appendToMenuLabel} (debug)
    LINUX /boot/${config.system.boot.loader.kernelFile}
    APPEND init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} loglevel=7
    INITRD /boot/${config.system.boot.loader.initrdFile}

    # A variant to boot with a serial console enabled
    LABEL boot-serial
    MENU LABEL NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel} (serial console=ttyS0,115200n8)
    MENU LABEL ${config.system.nixos.distroName} ${config.system.nixos.label}${config.isoImage.appendToMenuLabel} (serial console=ttyS0,115200n8)
    LINUX /boot/${config.system.boot.loader.kernelFile}
    APPEND init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} console=ttyS0,115200n8
    INITRD /boot/${config.system.boot.loader.initrdFile}
@@ -458,7 +458,7 @@ in
    };

    isoImage.isoBaseName = mkOption {
      default = "nixos";
      default = config.system.nixos.distroId;
      description = lib.mdDoc ''
        Prefix of the name of the generated ISO image file.
      '';
@@ -579,7 +579,7 @@ in

    isoImage.syslinuxTheme = mkOption {
      default = ''
        MENU TITLE NixOS
        MENU TITLE ${config.system.nixos.distroName}
        MENU RESOLUTION 800 600
        MENU CLEAR
        MENU ROWS 6
+23 −9
Original line number Diff line number Diff line
@@ -16,18 +16,18 @@ let
    ) + "\n";

  osReleaseContents = {
    NAME = "NixOS";
    ID = "nixos";
    NAME = "${cfg.distroName}";
    ID = "${cfg.distroId}";
    VERSION = "${cfg.release} (${cfg.codeName})";
    VERSION_CODENAME = toLower cfg.codeName;
    VERSION_ID = cfg.release;
    BUILD_ID = cfg.version;
    PRETTY_NAME = "NixOS ${cfg.release} (${cfg.codeName})";
    PRETTY_NAME = "${cfg.distroName} ${cfg.release} (${cfg.codeName})";
    LOGO = "nix-snowflake";
    HOME_URL = "https://nixos.org/";
    DOCUMENTATION_URL = "https://nixos.org/learn.html";
    SUPPORT_URL = "https://nixos.org/community.html";
    BUG_REPORT_URL = "https://github.com/NixOS/nixpkgs/issues";
    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";
  } // lib.optionalAttrs (cfg.variant_id != null) {
    VARIANT_ID = cfg.variant_id;
  };
@@ -89,6 +89,20 @@ in
      description = lib.mdDoc "The NixOS release code name (e.g. `Emu`).";
    };

    nixos.distroId = mkOption {
      internal = true;
      type = types.str;
      default = "nixos";
      description = lib.mdDoc "The id of the operating system";
    };

    nixos.distroName = mkOption {
      internal = true;
      type = types.str;
      default = "NixOS";
      description = lib.mdDoc "The name of the operating system";
    };

    nixos.variant_id = mkOption {
      type = types.nullOr (types.strMatching "^[a-z0-9._-]+$");
      default = null;
@@ -155,10 +169,10 @@ in
    environment.etc = {
      "lsb-release".text = attrsToText {
        LSB_VERSION = "${cfg.release} (${cfg.codeName})";
        DISTRIB_ID = "nixos";
        DISTRIB_ID = "${cfg.distroId}";
        DISTRIB_RELEASE = cfg.release;
        DISTRIB_CODENAME = toLower cfg.codeName;
        DISTRIB_DESCRIPTION = "NixOS ${cfg.release} (${cfg.codeName})";
        DISTRIB_DESCRIPTION = "${cfg.distroName} ${cfg.release} (${cfg.codeName})";
      };

      "os-release".text = attrsToText osReleaseContents;
+2 −1
Original line number Diff line number Diff line
@@ -94,7 +94,8 @@ in
      };

      ssid = mkOption {
        default = "nixos";
        default = config.system.nixos.distroId;
        defaultText = literalExpression "config.system.nixos.distroId";
        example = "mySpecialSSID";
        type = types.str;
        description = lib.mdDoc "SSID to be used in IEEE 802.11 management frames.";
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ let
              system = config.boot.kernelPackages.stdenv.hostPlatform.system;
              kernel = "${config.boot.kernelPackages.kernel}/${config.system.boot.loader.kernelFile}";
              kernelParams = config.boot.kernelParams;
              label = "NixOS ${config.system.nixos.codeName} ${config.system.nixos.label} (Linux ${config.boot.kernelPackages.kernel.modDirVersion})";
              label = "${config.system.nixos.distroName} ${config.system.nixos.codeName} ${config.system.nixos.label} (Linux ${config.boot.kernelPackages.kernel.modDirVersion})";

              inherit (cfg) extensions;
            } // lib.optionalAttrs config.boot.initrd.enable {
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ EOF

# This is a NixOS installation if it has /etc/NIXOS or a proper
# /etc/os-release.
if (!-f "/etc/NIXOS" && (read_file("/etc/os-release", err_mode => "quiet") // "") !~ /^ID="?nixos"?/msx) {
if (!-f "/etc/NIXOS" && (read_file("/etc/os-release", err_mode => "quiet") // "") !~ /^ID="?@distroId@"?/msx) {
    die("This is not a NixOS installation!\n");
}

Loading