about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorJanne Heß <janne@hess.ooo>2022-04-01 13:54:09 +0200
committerJanne Heß <janne@hess.ooo>2022-04-01 13:54:09 +0200
commit7ebb4ebe404a7ecf6ee9761aab7d02cd4e2a4abc (patch)
tree4ebc4fac236f06b906269271f0ac3533ab625556 /nixos/modules
parent5653209ed95985034bbb43bb63e04190639477a0 (diff)
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.
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/misc/version.nix40
-rw-r--r--nixos/modules/system/boot/systemd/initrd.nix2
2 files changed, 26 insertions, 16 deletions
diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix
index 6c072021ed834..5411bf3bc55e1 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 1d94f7fef8e9b..30bdc9a3422c7 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";