diff options
author | Peter Waller <p@pwaller.net> | 2023-09-03 18:27:49 +0100 |
---|---|---|
committer | Peter Waller <p@pwaller.net> | 2023-09-03 18:30:59 +0100 |
commit | 9fdf395cc74f67644509424922815b238645fa16 (patch) | |
tree | 8f5dde9ab2e5f690c38d737defaa61c69c7c825e /pkgs/stdenv | |
parent | c2b0edbf1f74b67643402ff0ae251fe6f604d851 (diff) | |
download | nixpkgs-9fdf395cc74f67644509424922815b238645fa16.tar nixpkgs-9fdf395cc74f67644509424922815b238645fa16.tar.gz nixpkgs-9fdf395cc74f67644509424922815b238645fa16.tar.bz2 nixpkgs-9fdf395cc74f67644509424922815b238645fa16.tar.lz nixpkgs-9fdf395cc74f67644509424922815b238645fa16.tar.xz nixpkgs-9fdf395cc74f67644509424922815b238645fa16.tar.zst nixpkgs-9fdf395cc74f67644509424922815b238645fa16.zip |
makeStaticBinaries: Set -DCMAKE_SKIP_INSTALL_RPATH
Without this, you get error messages during the install phase along the lines of: "file RPATH_CHANGE could not write new RPATH:". This is unsurprising because the static binaries do not have any dynamic linker and thus, no runpath to rewrite either. Tell cmake it doesn't need to do RPATH manipulation by passing cmakeFlags. While we're here, I also renamed `finalAttrs` to `args` and fixed the indentation; this improves consistency with the surrounding code and eliminates a point of confusion: because it was named `finalAttrs` I presumed I should be able to influence it with an overrideAttrs setting dontAddStaticConfigureFlags, but this turns out not to be possible; adding prevAttrs as well doesn't work because of a limitation of overrideAttrs whereby it gives an infinite recursion if the set of attribute keys being returned depends on finalAttrs. Signed-off-by: Peter Waller <p@pwaller.net>
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r-- | pkgs/stdenv/adapters.nix | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index f29bdf671c8..000c254cf25 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -60,12 +60,13 @@ rec { mkDerivationFromStdenv = withOldMkDerivation old (stdenv: mkDerivationSuper: args: if stdenv.hostPlatform.isDarwin then throw "Cannot build fully static binaries on Darwin/macOS" - else (mkDerivationSuper args).overrideAttrs(finalAttrs: { - NIX_CFLAGS_LINK = toString (finalAttrs.NIX_CFLAGS_LINK or "") + " -static"; - } // lib.optionalAttrs (!(finalAttrs.dontAddStaticConfigureFlags or false)) { - configureFlags = (finalAttrs.configureFlags or []) ++ [ - "--disable-shared" # brrr... - ]; + else (mkDerivationSuper args).overrideAttrs (args: { + NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "") + " -static"; + } // lib.optionalAttrs (!(args.dontAddStaticConfigureFlags or false)) { + configureFlags = (args.configureFlags or []) ++ [ + "--disable-shared" # brrr... + ]; + cmakeFlags = (args.cmakeFlags or []) ++ ["-DCMAKE_SKIP_INSTALL_RPATH=On"]; })); } // lib.optionalAttrs (stdenv0.hostPlatform.libc == "glibc") { extraBuildInputs = (old.extraBuildInputs or []) ++ [ |