summary refs log tree commit diff
path: root/pkgs/build-support/kernel
diff options
context:
space:
mode:
authorLinus Heckemann <git@sphalerite.org>2022-07-30 15:42:22 +0200
committerK900 <me@0upti.me>2022-08-02 10:19:48 +0300
commit6fc909a1cc89b32c9bc27d69da6333b8a0d4b87e (patch)
tree411d920eb89f2fa63bda68ce8d21d83006ad0a24 /pkgs/build-support/kernel
parentdaee67dae658c4a060cda0ff885c87e3ca28c5ae (diff)
downloadnixpkgs-6fc909a1cc89b32c9bc27d69da6333b8a0d4b87e.tar
nixpkgs-6fc909a1cc89b32c9bc27d69da6333b8a0d4b87e.tar.gz
nixpkgs-6fc909a1cc89b32c9bc27d69da6333b8a0d4b87e.tar.bz2
nixpkgs-6fc909a1cc89b32c9bc27d69da6333b8a0d4b87e.tar.lz
nixpkgs-6fc909a1cc89b32c9bc27d69da6333b8a0d4b87e.tar.xz
nixpkgs-6fc909a1cc89b32c9bc27d69da6333b8a0d4b87e.tar.zst
nixpkgs-6fc909a1cc89b32c9bc27d69da6333b8a0d4b87e.zip
makeInitrdNG: make stripping fully optional
Now the tool will only strip binaries if a strip executable is passed
via the STRIP environment variable. This is exposed via the strip
option for makeInitrdNG and the NixOS option boot.initrd.systemd.strip.
Diffstat (limited to 'pkgs/build-support/kernel')
-rw-r--r--pkgs/build-support/kernel/make-initrd-ng-tool.nix7
-rw-r--r--pkgs/build-support/kernel/make-initrd-ng.nix13
-rw-r--r--pkgs/build-support/kernel/make-initrd-ng/src/main.rs18
3 files changed, 19 insertions, 19 deletions
diff --git a/pkgs/build-support/kernel/make-initrd-ng-tool.nix b/pkgs/build-support/kernel/make-initrd-ng-tool.nix
index 654b1036781..67488168cf2 100644
--- a/pkgs/build-support/kernel/make-initrd-ng-tool.nix
+++ b/pkgs/build-support/kernel/make-initrd-ng-tool.nix
@@ -6,11 +6,4 @@ rustPlatform.buildRustPackage {
 
   src = ./make-initrd-ng;
   cargoLock.lockFile = ./make-initrd-ng/Cargo.lock;
-
-  nativeBuildInputs = [ makeWrapper ];
-
-  postInstall = ''
-    wrapProgram $out/bin/make-initrd-ng \
-      --prefix PATH : ${lib.makeBinPath [ patchelf glibc binutils ]}
-  '';
 }
diff --git a/pkgs/build-support/kernel/make-initrd-ng.nix b/pkgs/build-support/kernel/make-initrd-ng.nix
index 5f0a70f8a96..23ed9f3f74e 100644
--- a/pkgs/build-support/kernel/make-initrd-ng.nix
+++ b/pkgs/build-support/kernel/make-initrd-ng.nix
@@ -8,10 +8,12 @@ let
   # compression type and filename extension.
   compressorName = fullCommand: builtins.elemAt (builtins.match "([^ ]*/)?([^ ]+).*" fullCommand) 1;
 in
-{ stdenvNoCC, perl, cpio, ubootTools, lib, pkgsBuildHost, makeInitrdNGTool, patchelf, runCommand
+{ stdenvNoCC, perl, cpio, ubootTools, lib, pkgsBuildHost, makeInitrdNGTool, patchelf, binutils, runCommand
 # Name of the derivation (not of the resulting file!)
 , name ? "initrd"
 
+, strip ? true
+
 # Program used to compress the cpio archive; use "cat" for no compression.
 # This can also be a function which takes a package set and returns the path to the compressor,
 # such as `pkgs: "${pkgs.lzop}/bin/lzop"`.
@@ -59,7 +61,7 @@ in
 # If this isn't guessed, you may want to complete the metadata above and send a PR :)
 , uInitrdCompression ? _compressorMeta.ubootName or
     (throw "Unrecognised compressor ${_compressorName}, please specify uInitrdCompression")
-}: runCommand name {
+}: runCommand name ({
   compress = "${_compressorExecutable} ${lib.escapeShellArgs _compressorArgsReal}";
   passthru = {
     compressorExecutableFunction = _compressorFunction;
@@ -72,8 +74,11 @@ in
   passAsFile = ["contents"];
   contents = lib.concatMapStringsSep "\n" ({ object, symlink, ... }: "${object}\n${if symlink == null then "" else symlink}") contents + "\n";
 
-  nativeBuildInputs = [makeInitrdNGTool patchelf cpio] ++ lib.optional makeUInitrd ubootTools;
-} ''
+  nativeBuildInputs = [makeInitrdNGTool patchelf cpio] ++ lib.optional makeUInitrd ubootTools ++ lib.optional strip binutils;
+
+} // lib.optionalAttrs strip {
+  STRIP = "${(binutils.nativeDrv or binutils).targetPrefix}strip";
+}) ''
   mkdir ./root
   make-initrd-ng "$contentsPath" ./root
   mkdir "$out"
diff --git a/pkgs/build-support/kernel/make-initrd-ng/src/main.rs b/pkgs/build-support/kernel/make-initrd-ng/src/main.rs
index de1e3ee724a..89a7c08fda7 100644
--- a/pkgs/build-support/kernel/make-initrd-ng/src/main.rs
+++ b/pkgs/build-support/kernel/make-initrd-ng/src/main.rs
@@ -104,14 +104,16 @@ fn copy_file<P: AsRef<Path> + AsRef<OsStr>, S: AsRef<Path> + AsRef<OsStr>>(
         fs::set_permissions(&target, permissions)?;
 
         // Strip further than normal
-        if !Command::new("strip")
-            .arg("--strip-all")
-            .arg(OsStr::new(&target))
-            .output()?
-            .status
-            .success()
-        {
-            println!("{:?} was not successfully stripped.", OsStr::new(&target));
+        if let Ok(strip) = env::var("STRIP") {
+            if !Command::new(strip)
+                .arg("--strip-all")
+                .arg(OsStr::new(&target))
+                .output()?
+                .status
+                .success()
+            {
+                println!("{:?} was not successfully stripped.", OsStr::new(&target));
+            }
         }
     };