Merge pull request #65213 from tobim/pkgsStatic/enhance

pkgsStatic: improve usability
This commit is contained in:
Matthew Bauer 2019-07-30 16:30:27 -04:00 committed by GitHub
commit c0fe97b12e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View File

@ -62,8 +62,21 @@ rec {
];
mesonFlags = (args.mesonFlags or []) ++ [ "-Ddefault_library=static" ];
});
static = true;
};
/* Modify a stdenv so that all buildInputs are implicitly propagated to
consuming derivations
*/
propagateBuildInputs = stdenv: stdenv //
{ mkDerivation = args: stdenv.mkDerivation (args // {
propagatedBuildInputs = (args.propagatedBuildInputs or []) ++ (args.buildInputs or []);
buildInputs = [];
});
};
/* Modify a stdenv so that the specified attributes are added to
every derivation returned by its mkDerivation function.

View File

@ -12,7 +12,8 @@
self: super: let
inherit (super.stdenvAdapters) makeStaticBinaries
makeStaticLibraries;
makeStaticLibraries
propagateBuildInputs;
inherit (super.lib) foldl optional flip id composeExtensions;
inherit (super) makeSetupHook;
@ -30,7 +31,7 @@ self: super: let
});
};
staticAdapters = [ makeStaticLibraries ]
staticAdapters = [ makeStaticLibraries propagateBuildInputs ]
# Apple does not provide a static version of libSystem or crt0.o
# So we cant build static binaries without extensive hacks.
@ -53,6 +54,14 @@ self: super: let
in {
stdenv = foldl (flip id) super.stdenv staticAdapters;
gcc49Stdenv = foldl (flip id) super.gcc49Stdenv staticAdapters;
gcc5Stdenv = foldl (flip id) super.gcc5Stdenv staticAdapters;
gcc6Stdenv = foldl (flip id) super.gcc6Stdenv staticAdapters;
gcc7Stdenv = foldl (flip id) super.gcc7Stdenv staticAdapters;
gcc8Stdenv = foldl (flip id) super.gcc8Stdenv staticAdapters;
gcc9Stdenv = foldl (flip id) super.gcc9Stdenv staticAdapters;
clangStdenv = foldl (flip id) super.clangStdenv staticAdapters;
libcxxStdenv = foldl (flip id) super.libcxxStdenv staticAdapters;
haskell = super.haskell // {
packageOverrides = composeExtensions