1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-25 07:00:43 +00:00

Merge pull request #51966 from Twey/automatic-static-glibc

makeStaticBinaries: add a static glibc when performing a mkDerivation
This commit is contained in:
Matthew Bauer 2018-12-14 19:03:37 -06:00 committed by GitHub
commit ca00533887
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,12 +31,19 @@ rec {
# Return a modified stdenv that tries to build statically linked
# binaries.
makeStaticBinaries = stdenv: stdenv //
makeStaticBinaries = stdenv:
let stdenv' = if stdenv.hostPlatform.libc != "glibc" then stdenv else
stdenv.override (prev: {
extraBuildInputs = prev.extraBuildInputs or [] ++ [
stdenv.glibc.static
];
});
in stdenv' //
{ mkDerivation = args:
if stdenv.hostPlatform.isDarwin
if stdenv'.hostPlatform.isDarwin
then throw "Cannot build fully static binaries on Darwin/macOS"
else stdenv.mkDerivation (args // {
NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "") + "-static";
else stdenv'.mkDerivation (args // {
NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "") + " -static";
configureFlags = (args.configureFlags or []) ++ [
"--disable-shared" # brrr...
];