Merge pull request #51966 from Twey/automatic-static-glibc
makeStaticBinaries: add a static glibc when performing a mkDerivation
This commit is contained in:
commit
ca00533887
@ -31,11 +31,18 @@ rec {
|
|||||||
|
|
||||||
# Return a modified stdenv that tries to build statically linked
|
# Return a modified stdenv that tries to build statically linked
|
||||||
# binaries.
|
# 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:
|
{ mkDerivation = args:
|
||||||
if stdenv.hostPlatform.isDarwin
|
if stdenv'.hostPlatform.isDarwin
|
||||||
then throw "Cannot build fully static binaries on Darwin/macOS"
|
then throw "Cannot build fully static binaries on Darwin/macOS"
|
||||||
else stdenv.mkDerivation (args // {
|
else stdenv'.mkDerivation (args // {
|
||||||
NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "") + " -static";
|
NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "") + " -static";
|
||||||
configureFlags = (args.configureFlags or []) ++ [
|
configureFlags = (args.configureFlags or []) ++ [
|
||||||
"--disable-shared" # brrr...
|
"--disable-shared" # brrr...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user