mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 11:45:45 +03:00
nixos/systemd-initrd: deprecate strip
It only saved ~1MiB of initramfs size, but caused a few issues like unloadable kernel modules.
This commit is contained in:
parent
c3cedc4177
commit
98313e2b81
4 changed files with 12 additions and 55 deletions
|
@ -132,13 +132,20 @@ let
|
||||||
initialRamdisk = pkgs.makeInitrdNG {
|
initialRamdisk = pkgs.makeInitrdNG {
|
||||||
name = "initrd-${kernel-name}";
|
name = "initrd-${kernel-name}";
|
||||||
inherit (config.boot.initrd) compressor compressorArgs prepend;
|
inherit (config.boot.initrd) compressor compressorArgs prepend;
|
||||||
inherit (cfg) strip;
|
|
||||||
|
|
||||||
contents = lib.filter ({ source, ... }: !lib.elem source cfg.suppressedStorePaths) cfg.storePaths;
|
contents = lib.filter ({ source, ... }: !lib.elem source cfg.suppressedStorePaths) cfg.storePaths;
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
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 = {
|
options.boot.initrd.systemd = {
|
||||||
enable = mkEnableOption "systemd in initrd" // {
|
enable = mkEnableOption "systemd in initrd" // {
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -208,19 +215,6 @@ in
|
||||||
default = [ ];
|
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 {
|
extraBin = mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
Tools to add to /bin
|
Tools to add to /bin
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
{
|
{
|
||||||
rustPlatform,
|
rustPlatform,
|
||||||
lib,
|
lib,
|
||||||
makeWrapper,
|
|
||||||
patchelf,
|
|
||||||
glibc,
|
|
||||||
binutils,
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
rustPlatform.buildRustPackage {
|
rustPlatform.buildRustPackage {
|
||||||
|
|
|
@ -20,8 +20,6 @@ in
|
||||||
# Name of the derivation (not of the resulting file!)
|
# Name of the derivation (not of the resulting file!)
|
||||||
name ? "initrd",
|
name ? "initrd",
|
||||||
|
|
||||||
strip ? true,
|
|
||||||
|
|
||||||
# Program used to compress the cpio archive; use "cat" for no compression.
|
# 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,
|
# 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"`.
|
# such as `pkgs: "${pkgs.lzop}/bin/lzop"`.
|
||||||
|
@ -95,15 +93,10 @@ runCommand name
|
||||||
passAsFile = [ "contents" ];
|
passAsFile = [ "contents" ];
|
||||||
contents = builtins.toJSON contents;
|
contents = builtins.toJSON contents;
|
||||||
|
|
||||||
nativeBuildInputs =
|
nativeBuildInputs = [
|
||||||
[
|
makeInitrdNGTool
|
||||||
makeInitrdNGTool
|
cpio
|
||||||
cpio
|
] ++ lib.optional makeUInitrd ubootTools;
|
||||||
]
|
|
||||||
++ lib.optional makeUInitrd ubootTools
|
|
||||||
++ lib.optional strip binutils;
|
|
||||||
|
|
||||||
STRIP = if strip then "${pkgsBuildHost.binutils.targetPrefix}strip" else null;
|
|
||||||
})
|
})
|
||||||
''
|
''
|
||||||
mkdir -p ./root/var/empty
|
mkdir -p ./root/var/empty
|
||||||
|
|
|
@ -189,32 +189,6 @@ fn copy_file<
|
||||||
|
|
||||||
if let Ok(Object::Elf(e)) = Object::parse(&contents) {
|
if let Ok(Object::Elf(e)) = Object::parse(&contents) {
|
||||||
add_dependencies(source, e, &contents, &dlopen, queue)?;
|
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(())
|
Ok(())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue