pkgsStatic: Inline more of static overlay
This commit is contained in:
parent
a17fc03375
commit
904625852d
|
@ -189,6 +189,8 @@ stdenv.mkDerivation {
|
|||
|
||||
configureScript = "./bootstrap.sh";
|
||||
configurePlatforms = [];
|
||||
dontDisableStatic = true;
|
||||
dontAddStaticConfigureFlags = true;
|
||||
configureFlags = [
|
||||
"--includedir=$(dev)/include"
|
||||
"--libdir=$(out)/lib"
|
||||
|
|
|
@ -57,11 +57,13 @@ stdenv.mkDerivation (rec {
|
|||
# and giving nothing builds both.
|
||||
# So we have 3 possible ways to build both:
|
||||
# `--static --shared`, `--shared` and giving nothing.
|
||||
# Of these, we choose `--shared`, only because that's
|
||||
# what we did in the past and we can avoid mass rebuilds this way.
|
||||
# As a result, we pass `--static` only when we want just static.
|
||||
configureFlags = lib.optional (static && !shared) "--static"
|
||||
# Of these, we choose `--static --shared`, for clarity and simpler
|
||||
# conditions.
|
||||
configureFlags = lib.optional static "--static"
|
||||
++ lib.optional shared "--shared";
|
||||
# We do the right thing manually, above, so don't need these.
|
||||
dontDisableStatic = true;
|
||||
dontAddStaticConfigureFlags = true;
|
||||
|
||||
# Note we don't need to set `dontDisableStatic`, because static-disabling
|
||||
# works by grepping for `enable-static` in the `./configure` script
|
||||
|
|
|
@ -90,6 +90,24 @@ rec {
|
|||
});
|
||||
});
|
||||
|
||||
# Best effort static binaries. Will still be linked to libSystem,
|
||||
# but more portable than Nix store binaries.
|
||||
makeStaticDarwin = stdenv: stdenv.override (old: {
|
||||
# extraBuildInputs are dropped in cross.nix, but darwin still needs them
|
||||
extraBuildInputs = [ pkgs.buildPackages.darwin.CF ];
|
||||
mkDerivationFromStdenv = extendMkDerivationArgs old (args: {
|
||||
NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "")
|
||||
+ lib.optionalString (stdenv.cc.isGNU or false) " -static-libgcc";
|
||||
nativeBuildInputs = (args.nativeBuildInputs or []) ++ [
|
||||
(pkgs.buildPackages.makeSetupHook {
|
||||
substitutions = {
|
||||
libsystem = "${stdenv.cc.libc}/lib/libSystem.B.dylib";
|
||||
};
|
||||
} ./darwin/portable-libsystem.sh)
|
||||
];
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/* Modify a stdenv so that all buildInputs are implicitly propagated to
|
||||
consuming derivations
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
, scpSupport ? zlibSupport && !stdenv.isSunOS && !stdenv.isCygwin, libssh2 ? null
|
||||
, gssSupport ? with stdenv.hostPlatform; (
|
||||
!isWindows &&
|
||||
# disable gss becuase of: undefined reference to `k5_bcmp'
|
||||
# a very sad story re static: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439039
|
||||
!isStatic &&
|
||||
# the "mig" tool does not configure its compiler correctly. This could be
|
||||
|
@ -95,15 +96,15 @@ stdenv.mkDerivation rec {
|
|||
"--without-ca-bundle"
|
||||
"--without-ca-path"
|
||||
# The build fails when using wolfssl with --with-ca-fallback
|
||||
( if wolfsslSupport then "--without-ca-fallback" else "--with-ca-fallback")
|
||||
(lib.withFeature wolfsslSupport "ca-fallback")
|
||||
"--disable-manual"
|
||||
( if sslSupport then "--with-ssl=${openssl.dev}" else "--without-ssl" )
|
||||
( if gnutlsSupport then "--with-gnutls=${gnutls.dev}" else "--without-gnutls" )
|
||||
( if scpSupport then "--with-libssh2=${libssh2.dev}" else "--without-libssh2" )
|
||||
( if ldapSupport then "--enable-ldap" else "--disable-ldap" )
|
||||
( if ldapSupport then "--enable-ldaps" else "--disable-ldaps" )
|
||||
( if idnSupport then "--with-libidn=${libidn.dev}" else "--without-libidn" )
|
||||
( if brotliSupport then "--with-brotli" else "--without-brotli" )
|
||||
(lib.withFeatureAs sslSupport "ssl" openssl.dev)
|
||||
(lib.withFeatureAs gnutlsSupport "gnutls" gnutls.dev)
|
||||
(lib.withFeatureAs scpSupport "libssh2" libssh2.dev)
|
||||
(lib.enableFeature ldapSupport "ldap")
|
||||
(lib.enableFeature ldapSupport "ldaps")
|
||||
(lib.withFeatureAs idnSupport "libidn" libidn.dev)
|
||||
(lib.withFeature brotliSupport "brotli")
|
||||
]
|
||||
++ lib.optional wolfsslSupport "--with-wolfssl=${wolfssl.dev}"
|
||||
++ lib.optional c-aresSupport "--enable-ares=${c-ares}"
|
||||
|
|
|
@ -13,26 +13,9 @@
|
|||
self: super: let
|
||||
inherit (super.stdenvAdapters) makeStaticBinaries
|
||||
makeStaticLibraries
|
||||
propagateBuildInputs;
|
||||
inherit (super.lib) foldl optional flip id composeExtensions optionalAttrs optionalString;
|
||||
inherit (super) makeSetupHook;
|
||||
|
||||
# Best effort static binaries. Will still be linked to libSystem,
|
||||
# but more portable than Nix store binaries.
|
||||
makeStaticDarwin = stdenv_: let stdenv = stdenv_.override {
|
||||
# extraBuildInputs are dropped in cross.nix, but darwin still needs them
|
||||
extraBuildInputs = [ self.buildPackages.darwin.CF ];
|
||||
}; in stdenv // {
|
||||
mkDerivation = args: stdenv.mkDerivation (args // {
|
||||
NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "")
|
||||
+ optionalString (stdenv_.cc.isGNU or false) " -static-libgcc";
|
||||
nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ (makeSetupHook {
|
||||
substitutions = {
|
||||
libsystem = "${stdenv.cc.libc}/lib/libSystem.B.dylib";
|
||||
};
|
||||
} ../stdenv/darwin/portable-libsystem.sh) ];
|
||||
});
|
||||
};
|
||||
propagateBuildInputs
|
||||
makeStaticDarwin;
|
||||
inherit (super.lib) foldl optional flip id composeExtensions;
|
||||
|
||||
staticAdapters =
|
||||
optional super.stdenv.hostPlatform.isDarwin makeStaticDarwin
|
||||
|
@ -48,24 +31,8 @@ self: super: let
|
|||
;
|
||||
|
||||
in {
|
||||
# Do not add new packages here! Instead use `stdenv.hostPlatform.isStatic` to
|
||||
# write conditional code in the original package.
|
||||
|
||||
stdenv = foldl (flip id) super.stdenv staticAdapters;
|
||||
|
||||
boost = super.boost.override {
|
||||
# Don’t use new stdenv for boost because it doesn’t like the
|
||||
# --disable-shared flag
|
||||
stdenv = super.stdenv;
|
||||
};
|
||||
|
||||
curl = super.curl.override {
|
||||
# brotli doesn't build static (Mar. 2021)
|
||||
brotliSupport = false;
|
||||
# disable gss becuase of: undefined reference to `k5_bcmp'
|
||||
gssSupport = false;
|
||||
};
|
||||
|
||||
zlib = super.zlib.override {
|
||||
# Don’t use new stdenv zlib because
|
||||
# it doesn’t like the --disable-shared flag
|
||||
stdenv = super.stdenv;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue