diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix index 23b9e232c64d..65caee745124 100644 --- a/nixos/modules/system/boot/systemd/initrd.nix +++ b/nixos/modules/system/boot/systemd/initrd.nix @@ -132,13 +132,20 @@ let initialRamdisk = pkgs.makeInitrdNG { name = "initrd-${kernel-name}"; inherit (config.boot.initrd) compressor compressorArgs prepend; - inherit (cfg) strip; contents = lib.filter ({ source, ... }: !lib.elem source cfg.suppressedStorePaths) cfg.storePaths; }; in { + imports = [ + (lib.mkRemovedOptionModule [ "boot" "initrd" "systemd" "strip" ] '' + The option to strip ELF files in initrd has been removed. + It only saved ~1MiB of initramfs size, but caused a few issues + like unloadable kernel modules. + '') + ]; + options.boot.initrd.systemd = { enable = mkEnableOption "systemd in initrd" // { description = '' @@ -208,19 +215,6 @@ in default = [ ]; }; - strip = mkOption { - description = '' - Whether to completely strip executables and libraries copied to the initramfs. - - Setting this to false may save on the order of 30MiB on the - machine building the system (by avoiding a binutils - reference), at the cost of ~1MiB of initramfs size. This puts - this option firmly in the territory of micro-optimisation. - ''; - type = types.bool; - default = true; - }; - extraBin = mkOption { description = '' Tools to add to /bin diff --git a/pkgs/build-support/kernel/make-initrd-ng-tool.nix b/pkgs/build-support/kernel/make-initrd-ng-tool.nix index 9097728fe7a9..c373530285c7 100644 --- a/pkgs/build-support/kernel/make-initrd-ng-tool.nix +++ b/pkgs/build-support/kernel/make-initrd-ng-tool.nix @@ -1,10 +1,6 @@ { rustPlatform, lib, - makeWrapper, - patchelf, - glibc, - binutils, }: rustPlatform.buildRustPackage { diff --git a/pkgs/build-support/kernel/make-initrd-ng.nix b/pkgs/build-support/kernel/make-initrd-ng.nix index 4d2ad14a023b..da2941cdd6f2 100644 --- a/pkgs/build-support/kernel/make-initrd-ng.nix +++ b/pkgs/build-support/kernel/make-initrd-ng.nix @@ -20,8 +20,6 @@ in # 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"`. @@ -95,15 +93,10 @@ runCommand name passAsFile = [ "contents" ]; contents = builtins.toJSON contents; - nativeBuildInputs = - [ - makeInitrdNGTool - cpio - ] - ++ lib.optional makeUInitrd ubootTools - ++ lib.optional strip binutils; - - STRIP = if strip then "${pkgsBuildHost.binutils.targetPrefix}strip" else null; + nativeBuildInputs = [ + makeInitrdNGTool + cpio + ] ++ lib.optional makeUInitrd ubootTools; }) '' mkdir -p ./root/var/empty 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 149c5393e35a..85449c7eb027 100644 --- a/pkgs/build-support/kernel/make-initrd-ng/src/main.rs +++ b/pkgs/build-support/kernel/make-initrd-ng/src/main.rs @@ -189,32 +189,6 @@ fn copy_file< if let Ok(Object::Elf(e)) = Object::parse(&contents) { add_dependencies(source, e, &contents, &dlopen, queue)?; - - // Make file writable to strip it - let mut permissions = fs::metadata(&target) - .wrap_err_with(|| format!("failed to get metadata for {:?}", target))? - .permissions(); - permissions.set_mode(permissions.mode() | 0o200); - fs::set_permissions(&target, permissions.clone()) - .wrap_err_with(|| format!("failed to set read-write permissions for {:?}", target))?; - - // Strip further than normal - 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)); - } - } - - // Remove writable permissions - permissions.set_mode(permissions.mode() & 0o555); - fs::set_permissions(&target, permissions) - .wrap_err_with(|| format!("failed to remove writable permissions for {:?}", target))?; }; Ok(())