From 7ebb4ebe404a7ecf6ee9761aab7d02cd4e2a4abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Fri, 1 Apr 2022 13:54:09 +0200 Subject: [PATCH] nixos/systemd-stage-1: Append (Initrd) to /etc/initrd-release This is more in line with what dracut does (it appends "Initramfs") and makes it clear where the boot is currently at when it hangs. --- nixos/modules/misc/version.nix | 40 +++++++++++++------- nixos/modules/system/boot/systemd/initrd.nix | 2 - 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index 6c072021ed83..5411bf3bc55e 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -11,6 +11,26 @@ let attrsToText = attrs: concatStringsSep "\n" (mapAttrsToList (n: v: ''${n}="${toString v}"'') attrs); + osReleaseContents = { + NAME = "NixOS"; + ID = "nixos"; + 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})"; + 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"; + }; + + initrdReleaseContents = osReleaseContents // { + PRETTY_NAME = "${osReleaseContents.PRETTY_NAME} (Initrd)"; + }; + initrdRelease = pkgs.writeText "initrd-release" (attrsToText initrdReleaseContents); + in { imports = [ @@ -115,20 +135,12 @@ in DISTRIB_DESCRIPTION = "NixOS ${cfg.release} (${cfg.codeName})"; }; - "os-release".text = attrsToText { - NAME = "NixOS"; - ID = "nixos"; - 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})"; - 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"; - }; + "os-release".text = attrsToText osReleaseContents; + }; + + boot.initrd.systemd.contents = { + "/etc/os-release".source = initrdRelease; + "/etc/initrd-release".source = initrdRelease; }; }; diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix index 1d94f7fef8e9..30bdc9a3422c 100644 --- a/nixos/modules/system/boot/systemd/initrd.nix +++ b/nixos/modules/system/boot/systemd/initrd.nix @@ -353,8 +353,6 @@ in { DefaultEnvironment=PATH=/bin:/sbin ''; - "/etc/initrd-release".source = config.environment.etc.os-release.source; - "/etc/os-release".source = config.environment.etc.os-release.source; "/etc/fstab".source = fstab; "/lib/modules".source = "${modulesClosure}/lib/modules";