diff options
author | Victor Fuentes <vmfuentes64@gmail.com> | 2022-12-17 18:00:58 -0500 |
---|---|---|
committer | Victor Fuentes <vmfuentes64@gmail.com> | 2023-01-14 16:19:06 -0500 |
commit | d3528cdc3dbe82a0551707fe869aec02bba72956 (patch) | |
tree | a7d859d287043b45ccf110cb8eb79a30749d01e3 /nixos/modules/system | |
parent | c9c4aea7ab0d137c62e09300d874be8a9a6820fc (diff) | |
download | nixpkgs-d3528cdc3dbe82a0551707fe869aec02bba72956.tar nixpkgs-d3528cdc3dbe82a0551707fe869aec02bba72956.tar.gz nixpkgs-d3528cdc3dbe82a0551707fe869aec02bba72956.tar.bz2 nixpkgs-d3528cdc3dbe82a0551707fe869aec02bba72956.tar.lz nixpkgs-d3528cdc3dbe82a0551707fe869aec02bba72956.tar.xz nixpkgs-d3528cdc3dbe82a0551707fe869aec02bba72956.tar.zst nixpkgs-d3528cdc3dbe82a0551707fe869aec02bba72956.zip |
nixos/version: add config.system.nixos.distroName and config.system.nixos.distroId
Diffstat (limited to 'nixos/modules/system')
13 files changed, 26 insertions, 18 deletions
diff --git a/nixos/modules/system/activation/bootspec.nix b/nixos/modules/system/activation/bootspec.nix index 61407ab6755..1055ed1dda9 100644 --- a/nixos/modules/system/activation/bootspec.nix +++ b/nixos/modules/system/activation/bootspec.nix @@ -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 { diff --git a/nixos/modules/system/activation/switch-to-configuration.pl b/nixos/modules/system/activation/switch-to-configuration.pl index 9a4c635402d..de6e43dd30d 100755 --- a/nixos/modules/system/activation/switch-to-configuration.pl +++ b/nixos/modules/system/activation/switch-to-configuration.pl @@ -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"); } diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index 00b11471e1c..240e2095917 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -65,6 +65,7 @@ let mkdir $out/bin export localeArchive="${config.i18n.glibcLocales}/lib/locale/locale-archive" + export distroId=${config.system.nixos.distroId}; substituteAll ${./switch-to-configuration.pl} $out/bin/switch-to-configuration chmod +x $out/bin/switch-to-configuration ${optionalString (pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform) '' diff --git a/nixos/modules/system/boot/loader/grub/grub.nix b/nixos/modules/system/boot/loader/grub/grub.nix index 1d266b5a37d..121d7e88e74 100644 --- a/nixos/modules/system/boot/loader/grub/grub.nix +++ b/nixos/modules/system/boot/loader/grub/grub.nix @@ -55,7 +55,7 @@ let grubTargetEfi = if cfg.efiSupport && (cfg.version == 2) then f (grubEfi.grubTarget or "") else ""; bootPath = args.path; storePath = config.boot.loader.grub.storePath; - bootloaderId = if args.efiBootloaderId == null then "NixOS${efiSysMountPoint'}" else args.efiBootloaderId; + bootloaderId = if args.efiBootloaderId == null then "${config.system.nixos.distroName}${efiSysMountPoint'}" else args.efiBootloaderId; timeout = if config.boot.loader.timeout == null then -1 else config.boot.loader.timeout; users = if cfg.users == {} || cfg.version != 1 then cfg.users else throw "GRUB version 1 does not support user accounts."; theme = f cfg.theme; @@ -759,6 +759,7 @@ in src = ./install-grub.pl; utillinux = pkgs.util-linux; btrfsprogs = pkgs.btrfs-progs; + inherit (config.system.nixos) distroName; }; perl = pkgs.perl.withPackages (p: with p; [ FileSlurp FileCopyRecursive diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl index d5f019423b6..20d48cde4ca 100644 --- a/nixos/modules/system/boot/loader/grub/install-grub.pl +++ b/nixos/modules/system/boot/loader/grub/install-grub.pl @@ -511,7 +511,7 @@ sub addEntry { # Add default entries. $conf .= "$extraEntries\n" if $extraEntriesBeforeNixOS; -addEntry("NixOS - Default", $defaultConfig, $entryOptions); +addEntry("@distroName@ - Default", $defaultConfig, $entryOptions); $conf .= "$extraEntries\n" unless $extraEntriesBeforeNixOS; @@ -536,7 +536,7 @@ foreach my $link (@links) { my $linkname = basename($link); $entryName = "($linkname - $date - $version)"; } - addEntry("NixOS - $entryName", $link); + addEntry("@distroName@ - $entryName", $link); } my $grubBootPath = $grubBoot->path; @@ -568,19 +568,19 @@ sub addProfile { -e "$link/nixos-version" ? readFile("$link/nixos-version") : basename((glob(dirname(Cwd::abs_path("$link/kernel")) . "/lib/modules/*"))[0]); - addEntry("NixOS - Configuration " . nrFromGen($link) . " ($date - $version)", $link, $subEntryOptions); + addEntry("@distroName@ - Configuration " . nrFromGen($link) . " ($date - $version)", $link, $subEntryOptions); } $conf .= "}\n" if $grubVersion == 2; } -addProfile "/nix/var/nix/profiles/system", "NixOS - All configurations"; +addProfile "/nix/var/nix/profiles/system", "@distroName@ - All configurations"; if ($grubVersion == 2) { for my $profile (glob "/nix/var/nix/profiles/system-profiles/*") { my $name = basename($profile); next unless $name =~ /^\w+$/; - addProfile $profile, "NixOS - Profile '$name'"; + addProfile $profile, "@distroName@ - Profile '$name'"; } } diff --git a/nixos/modules/system/boot/loader/init-script/init-script-builder.sh b/nixos/modules/system/boot/loader/init-script/init-script-builder.sh index bd3fc64999d..755ea259c42 100644 --- a/nixos/modules/system/boot/loader/init-script/init-script-builder.sh +++ b/nixos/modules/system/boot/loader/init-script/init-script-builder.sh @@ -64,13 +64,13 @@ addEntry() { mkdir -p /boot /sbin -addEntry "NixOS - Default" $defaultConfig "" +addEntry "@distroName@ - Default" $defaultConfig "" # Add all generations of the system profile to the menu, in reverse # (most recent to least recent) order. for link in $((ls -d $defaultConfig/specialisation/* ) | sort -n); do date=$(stat --printf="%y\n" $link | sed 's/\..*//') - addEntry "NixOS - variation" $link "" + addEntry "@distroName@ - variation" $link "" done for generation in $( @@ -85,7 +85,7 @@ for generation in $( else suffix="($date)" fi - addEntry "NixOS - Configuration $generation $suffix" $link "$generation ($date)" + addEntry "@distroName@ - Configuration $generation $suffix" $link "$generation ($date)" done mv $tmpOther $targetOther diff --git a/nixos/modules/system/boot/loader/init-script/init-script.nix b/nixos/modules/system/boot/loader/init-script/init-script.nix index 8287131d321..908f8b8e8c4 100644 --- a/nixos/modules/system/boot/loader/init-script/init-script.nix +++ b/nixos/modules/system/boot/loader/init-script/init-script.nix @@ -8,6 +8,7 @@ let src = ./init-script-builder.sh; isExecutable = true; inherit (pkgs) bash; + inherit (config.nixos.system) distroName; path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep]; }; diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py index ad7e2184d2a..ea3577f138c 100755 --- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py +++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py @@ -42,7 +42,7 @@ def system_dir(profile: Optional[str], generation: int, specialisation: Optional else: return d -BOOT_ENTRY = """title NixOS{profile}{specialisation} +BOOT_ENTRY = """title @distroName@{profile}{specialisation} version Generation {generation} {description} linux {kernel} initrd {initrd} @@ -99,7 +99,7 @@ def describe_generation(generation_dir: str) -> str: build_time = int(os.path.getctime(generation_dir)) build_date = datetime.datetime.fromtimestamp(build_time).strftime('%F') - description = "NixOS {}, Linux Kernel {}, Built on {}".format( + description = "@distroName@ {}, Linux Kernel {}, Built on {}".format( nixos_version, kernel_version, build_date ) @@ -206,8 +206,8 @@ def get_profiles() -> List[str]: return [] def main() -> None: - parser = argparse.ArgumentParser(description='Update NixOS-related systemd-boot files') - parser.add_argument('default_config', metavar='DEFAULT-CONFIG', help='The default NixOS config to boot') + parser = argparse.ArgumentParser(description='Update @distroName@-related systemd-boot files') + parser.add_argument('default_config', metavar='DEFAULT-CONFIG', help='The default @distroName@ config to boot') args = parser.parse_args() try: diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix index 103d6e583c3..757dc080d4b 100644 --- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix +++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix @@ -30,6 +30,8 @@ let inherit (efi) efiSysMountPoint canTouchEfiVariables; + inherit (config.system.nixos) distroName; + memtest86 = if cfg.memtest86.enable then pkgs.memtest86-efi else ""; netbootxyz = if cfg.netbootxyz.enable then pkgs.netbootxyz-efi else ""; diff --git a/nixos/modules/system/boot/stage-1-init.sh b/nixos/modules/system/boot/stage-1-init.sh index 4596c160a95..890f8c21f85 100644 --- a/nixos/modules/system/boot/stage-1-init.sh +++ b/nixos/modules/system/boot/stage-1-init.sh @@ -73,7 +73,7 @@ trap 'fail' 0 # Print a greeting. info -info "[1;32m<<< NixOS Stage 1 >>>[0m" +info "[1;32m<<< @distroName@ Stage 1 >>>[0m" info # Make several required directories. @@ -422,7 +422,7 @@ lustrateRoot () { local root="$1" echo - echo -e "\e[1;33m<<< NixOS is now lustrating the root filesystem (cruft goes to /old-root) >>>\e[0m" + echo -e "\e[1;33m<<< @distroName@ is now lustrating the root filesystem (cruft goes to /old-root) >>>\e[0m" echo mkdir -m 0755 -p "$root/old-root.tmp" diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index 95dcdfd7fbe..af26c156fd4 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -342,6 +342,8 @@ let inherit (config.boot) resumeDevice; + inherit (config.system.nixos) distroName; + inherit (config.system.build) earlyMountScript; inherit (config.boot.initrd) checkJournalingFS verbose diff --git a/nixos/modules/system/boot/stage-2-init.sh b/nixos/modules/system/boot/stage-2-init.sh index 78cc8e8d45a..f9a2084ea9e 100755 --- a/nixos/modules/system/boot/stage-2-init.sh +++ b/nixos/modules/system/boot/stage-2-init.sh @@ -19,7 +19,7 @@ if [ "${IN_NIXOS_SYSTEMD_STAGE1:-}" != true ]; then # Print a greeting. echo - echo -e "\e[1;32m<<< NixOS Stage 2 >>>\e[0m" + echo -e "\e[1;32m<<< @distroName@ Stage 2 >>>\e[0m" echo diff --git a/nixos/modules/system/boot/stage-2.nix b/nixos/modules/system/boot/stage-2.nix index 6ed915c339e..001380158d5 100644 --- a/nixos/modules/system/boot/stage-2.nix +++ b/nixos/modules/system/boot/stage-2.nix @@ -11,6 +11,7 @@ let shellDebug = "${pkgs.bashInteractive}/bin/bash"; shell = "${pkgs.bash}/bin/bash"; inherit (config.boot) readOnlyNixStore systemdExecutable extraSystemdUnitPaths; + inherit (config.system.nixos) distroName; isExecutable = true; inherit useHostResolvConf; inherit (config.system.build) earlyMountScript; |