1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 03:30:45 +00:00

Merge pull request #331964 from adisbladis/stdenv-adapters-env-cflags-link

stdenv: Take nested env.NIX_CFLAGS_LINK into account when making static binaries
This commit is contained in:
Marcus Ramberg 2024-08-03 18:08:32 +02:00 committed by GitHub
commit 36f51bc719
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -99,8 +99,12 @@ 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 (args: {
NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "") + " -static";
else (mkDerivationSuper args).overrideAttrs (args: if args ? env.NIX_CFLAGS_LINK then {
env = args.env // {
NIX_CFLAGS_LINK = toString args.env.NIX_CFLAGS_LINK + " -static";
};
} else {
NIX_CFLAGS_LINK = toString (args.env.NIX_CFLAGS_LINK or "") + " -static";
} // lib.optionalAttrs (!(args.dontAddStaticConfigureFlags or false)) {
configureFlags = (args.configureFlags or []) ++ [
"--disable-shared" # brrr...