From 6fc909a1cc89b32c9bc27d69da6333b8a0d4b87e Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Sat, 30 Jul 2022 15:42:22 +0200 Subject: 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. --- nixos/modules/system/boot/systemd/initrd.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'nixos') diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix index 88e2bf9ac7043..d83b67f15972a 100644 --- a/nixos/modules/system/boot/systemd/initrd.nix +++ b/nixos/modules/system/boot/systemd/initrd.nix @@ -129,6 +129,7 @@ let initialRamdisk = pkgs.makeInitrdNG { name = "initrd-${kernel-name}"; inherit (config.boot.initrd) compressor compressorArgs prepend; + inherit (cfg) strip; contents = map (path: { object = path; symlink = ""; }) (subtractLists cfg.suppressedStorePaths cfg.storePaths) ++ mapAttrsToList (_: v: { object = v.source; symlink = v.target; }) (filterAttrs (_: v: v.enable) cfg.contents); @@ -169,6 +170,19 @@ in { default = []; }; + strip = mkOption { + description = lib.mdDoc '' + 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 = lib.mdDoc '' Tools to add to /bin -- cgit 1.4.1