mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-02 13:00:23 +00:00
nix: remove propagated-build-inputs when static
Ports d07852b5f33b4ef2bd19d7f542575502898f9f97 from the nix tree. This reduces the closure of pkgsStatic.nix down to several packages. The closure size drops down from 430.7 MiB -> 39.4 Mib. Ideally of course we would have the nix-cli component not be allowed to reference any store paths at all, since that's the whole point of static builds (i.e to be self-contained). Co-authored-by: Tristan Ross <tristan.ross@midstall.com>
This commit is contained in:
@@ -174,6 +174,17 @@ let
|
||||
outputs = prevAttrs.outputs or [ "out" ] ++ [ "dev" ];
|
||||
};
|
||||
|
||||
fixupStaticLayer = finalAttrs: prevAttrs: {
|
||||
postFixup =
|
||||
prevAttrs.postFixup or ""
|
||||
+ lib.optionalString (stdenv.hostPlatform.isStatic) ''
|
||||
# HACK: Otherwise the result will have the entire buildInputs closure
|
||||
# injected by the pkgsStatic stdenv
|
||||
# <https://github.com/NixOS/nixpkgs/issues/83667>
|
||||
rm -f $out/nix-support/propagated-build-inputs
|
||||
'';
|
||||
};
|
||||
|
||||
# Work around weird `--as-needed` linker behavior with BSD, see
|
||||
# https://github.com/mesonbuild/meson/issues/3593
|
||||
bsdNoLinkAsNeeded =
|
||||
@@ -323,6 +334,7 @@ in
|
||||
scope.sourceLayer
|
||||
setVersionLayer
|
||||
mesonLayer
|
||||
fixupStaticLayer
|
||||
scope.mesonComponentOverrides
|
||||
];
|
||||
mkMesonExecutable = mkPackageBuilder [
|
||||
@@ -332,6 +344,7 @@ in
|
||||
setVersionLayer
|
||||
mesonLayer
|
||||
mesonBuildLayer
|
||||
fixupStaticLayer
|
||||
scope.mesonComponentOverrides
|
||||
];
|
||||
mkMesonLibrary = mkPackageBuilder [
|
||||
@@ -342,6 +355,7 @@ in
|
||||
setVersionLayer
|
||||
mesonBuildLayer
|
||||
mesonLibraryLayer
|
||||
fixupStaticLayer
|
||||
scope.mesonComponentOverrides
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user