From b590735a227facbdc61cf8925ca61798366fe48f Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman Date: Sat, 12 Sep 2026 21:47:55 +0300 Subject: [PATCH] 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 --- .../nix/modular/packaging/components.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkgs/tools/package-management/nix/modular/packaging/components.nix b/pkgs/tools/package-management/nix/modular/packaging/components.nix index fb6970ce68c0..8e2b749cbb9c 100644 --- a/pkgs/tools/package-management/nix/modular/packaging/components.nix +++ b/pkgs/tools/package-management/nix/modular/packaging/components.nix @@ -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 + # + 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 ];