makeStaticBinaries
pkgs.makeStaticBinaries
Docs pulled from | This Revision | 18 days ago
Nixpkgs manual
binaries.
Noogle detected
Implementation
The following is the current implementation of this function.
makeStaticBinaries =
stdenv0:
stdenv0.override (
old:
{
mkDerivationFromStdenv = withOldMkDerivation old (
stdenv: mkDerivationSuper: args:
if stdenv.hostPlatform.isDarwin then
throw "Cannot build fully static binaries on Darwin/macOS"
else
(mkDerivationSuper args).overrideAttrs (
args:
(
if (args ? NIX_CFLAGS_LINK) then
lib.warn
(
"NIX_CFLAGS_LINK is an environment variable and should be defined inside `env`"
+ lib.optionalString (args ? pname) " for package ${args.pname}"
+ lib.optionalString (args ? version) "-${args.version}"
)
{
NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "") + " -static";
}
else
{
env = (args.env or { }) // {
NIX_CFLAGS_LINK = toString (args.env.NIX_CFLAGS_LINK or "") + " -static";
};
}
)
// lib.optionalAttrs (!(args.dontAddStaticConfigureFlags or false)) {
configureFlags = (args.configureFlags or [ ]) ++ [
"--disable-shared" # brrr...
];
cmakeFlags = (args.cmakeFlags or [ ]) ++ [ "-DCMAKE_SKIP_INSTALL_RPATH=On" ];
}
)
);
}
// lib.optionalAttrs (stdenv0.hostPlatform.libc == "glibc") {
extraBuildInputs = (old.extraBuildInputs or [ ]) ++ [
pkgs.glibc.static
];
}
);