2018-12-05 04:17:22 +01:00
|
|
|
|
# Overlay that builds static packages.
|
|
|
|
|
|
|
|
|
|
# Not all packages will build but support is done on a
|
|
|
|
|
# best effort basic.
|
|
|
|
|
#
|
|
|
|
|
# Note on Darwin/macOS: Apple does not provide a static libc
|
|
|
|
|
# so any attempts at static binaries are going to be very
|
|
|
|
|
# unsupported.
|
|
|
|
|
#
|
|
|
|
|
# Basic things like pkgsStatic.hello should work out of the box. More
|
|
|
|
|
# complicated things will need to be fixed with overrides.
|
|
|
|
|
|
|
|
|
|
self: super: let
|
|
|
|
|
inherit (super.stdenvAdapters) makeStaticBinaries
|
2019-07-24 16:04:51 +02:00
|
|
|
|
makeStaticLibraries
|
|
|
|
|
propagateBuildInputs;
|
2020-04-28 16:51:39 +02:00
|
|
|
|
inherit (super.lib) foldl optional flip id composeExtensions optionalAttrs optionalString;
|
2018-12-05 04:17:22 +01:00
|
|
|
|
inherit (super) makeSetupHook;
|
|
|
|
|
|
|
|
|
|
# Best effort static binaries. Will still be linked to libSystem,
|
|
|
|
|
# but more portable than Nix store binaries.
|
2020-04-28 16:51:39 +02:00
|
|
|
|
makeStaticDarwin = stdenv_: let stdenv = stdenv_.override {
|
|
|
|
|
# extraBuildInputs are dropped in cross.nix, but darwin still needs them
|
|
|
|
|
extraBuildInputs = [ self.buildPackages.darwin.CF ];
|
|
|
|
|
}; in stdenv // {
|
2018-12-05 04:17:22 +01:00
|
|
|
|
mkDerivation = args: stdenv.mkDerivation (args // {
|
|
|
|
|
NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "")
|
2020-04-28 16:51:39 +02:00
|
|
|
|
+ optionalString stdenv.cc.isGNU " -static-libgcc";
|
2018-12-05 04:17:22 +01:00
|
|
|
|
nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ (makeSetupHook {
|
|
|
|
|
substitutions = {
|
|
|
|
|
libsystem = "${stdenv.cc.libc}/lib/libSystem.B.dylib";
|
|
|
|
|
};
|
|
|
|
|
} ../stdenv/darwin/portable-libsystem.sh) ];
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2020-12-07 00:09:07 +01:00
|
|
|
|
staticAdapters =
|
|
|
|
|
# makeStaticDarwin must go first so that the extraBuildInputs
|
|
|
|
|
# override does not recreate mkDerivation, removing subsequent
|
|
|
|
|
# adapters.
|
|
|
|
|
optional super.stdenv.hostPlatform.isDarwin makeStaticDarwin
|
|
|
|
|
|
|
|
|
|
++ [ makeStaticLibraries propagateBuildInputs ]
|
2018-12-05 04:17:22 +01:00
|
|
|
|
|
|
|
|
|
# Apple does not provide a static version of libSystem or crt0.o
|
|
|
|
|
# So we can’t build static binaries without extensive hacks.
|
|
|
|
|
++ optional (!super.stdenv.hostPlatform.isDarwin) makeStaticBinaries
|
|
|
|
|
|
|
|
|
|
# Glibc doesn’t come with static runtimes by default.
|
|
|
|
|
# ++ optional (super.stdenv.hostPlatform.libc == "glibc") ((flip overrideInStdenv) [ self.stdenv.glibc.static ])
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
# Force everything to link statically.
|
|
|
|
|
haskellStaticAdapter = self: super: {
|
|
|
|
|
mkDerivation = attrs: super.mkDerivation (attrs // {
|
|
|
|
|
enableSharedLibraries = false;
|
|
|
|
|
enableSharedExecutables = false;
|
|
|
|
|
enableStaticLibraries = true;
|
|
|
|
|
});
|
|
|
|
|
};
|
2019-11-20 16:46:18 +01:00
|
|
|
|
|
|
|
|
|
removeUnknownConfigureFlags = f: with self.lib;
|
|
|
|
|
remove "--disable-shared"
|
|
|
|
|
(remove "--enable-static" f);
|
2019-12-16 13:39:21 +01:00
|
|
|
|
|
2019-11-20 16:46:18 +01:00
|
|
|
|
ocamlFixPackage = b:
|
|
|
|
|
b.overrideAttrs (o: {
|
|
|
|
|
configurePlatforms = [ ];
|
|
|
|
|
configureFlags = removeUnknownConfigureFlags (o.configureFlags or [ ]);
|
|
|
|
|
buildInputs = o.buildInputs ++ o.nativeBuildInputs or [ ];
|
|
|
|
|
propagatedNativeBuildInputs = o.propagatedBuildInputs or [ ];
|
|
|
|
|
});
|
2019-12-16 13:39:21 +01:00
|
|
|
|
|
2019-11-20 16:46:18 +01:00
|
|
|
|
ocamlStaticAdapter = _: super:
|
|
|
|
|
self.lib.mapAttrs
|
|
|
|
|
(_: p: if p ? overrideAttrs then ocamlFixPackage p else p)
|
|
|
|
|
super
|
|
|
|
|
// {
|
|
|
|
|
lablgtk = null; # Currently xlibs cause infinite recursion
|
|
|
|
|
ocaml = ((super.ocaml.override { useX11 = false; }).overrideAttrs (o: {
|
|
|
|
|
configurePlatforms = [ ];
|
|
|
|
|
dontUpdateAutotoolsGnuConfigScripts = true;
|
|
|
|
|
})).overrideDerivation (o: {
|
|
|
|
|
preConfigure = ''
|
|
|
|
|
configureFlagsArray+=("-cc" "$CC" "-as" "$AS" "-partialld" "$LD -r")
|
|
|
|
|
'';
|
|
|
|
|
configureFlags = (removeUnknownConfigureFlags o.configureFlags) ++ [
|
|
|
|
|
"--no-shared-libs"
|
|
|
|
|
"-host ${o.stdenv.hostPlatform.config}"
|
|
|
|
|
"-target ${o.stdenv.targetPlatform.config}"
|
|
|
|
|
];
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2018-12-05 04:17:22 +01:00
|
|
|
|
in {
|
|
|
|
|
stdenv = foldl (flip id) super.stdenv staticAdapters;
|
2019-07-21 07:36:44 +02:00
|
|
|
|
gcc49Stdenv = foldl (flip id) super.gcc49Stdenv 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;
|
2018-12-05 04:17:22 +01:00
|
|
|
|
|
|
|
|
|
haskell = super.haskell // {
|
|
|
|
|
packageOverrides = composeExtensions
|
|
|
|
|
(super.haskell.packageOverrides or (_: _: {}))
|
|
|
|
|
haskellStaticAdapter;
|
|
|
|
|
};
|
|
|
|
|
|
2019-09-29 12:20:28 +02:00
|
|
|
|
nghttp2 = super.nghttp2.override {
|
|
|
|
|
enableApp = false;
|
|
|
|
|
};
|
|
|
|
|
|
2018-12-05 04:17:22 +01:00
|
|
|
|
ncurses = super.ncurses.override {
|
|
|
|
|
enableStatic = true;
|
|
|
|
|
};
|
2019-09-10 04:42:03 +02:00
|
|
|
|
libxml2 = super.libxml2.override ({
|
2018-12-05 04:17:22 +01:00
|
|
|
|
enableShared = false;
|
|
|
|
|
enableStatic = true;
|
2019-09-10 04:42:03 +02:00
|
|
|
|
} // optionalAttrs super.stdenv.hostPlatform.isDarwin {
|
|
|
|
|
pythonSupport = false;
|
|
|
|
|
});
|
2019-11-28 13:57:27 +01:00
|
|
|
|
zlib = super.zlib.override {
|
2018-12-05 04:17:22 +01:00
|
|
|
|
static = true;
|
|
|
|
|
shared = false;
|
2019-11-28 13:57:27 +01:00
|
|
|
|
splitStaticOutput = false;
|
2018-12-05 04:17:22 +01:00
|
|
|
|
|
|
|
|
|
# Don’t use new stdenv zlib because
|
|
|
|
|
# it doesn’t like the --disable-shared flag
|
|
|
|
|
stdenv = super.stdenv;
|
2019-11-28 13:57:27 +01:00
|
|
|
|
};
|
2018-12-05 04:17:22 +01:00
|
|
|
|
xz = super.xz.override {
|
|
|
|
|
enableStatic = true;
|
|
|
|
|
};
|
|
|
|
|
busybox = super.busybox.override {
|
|
|
|
|
enableStatic = true;
|
|
|
|
|
};
|
|
|
|
|
libiberty = super.libiberty.override {
|
|
|
|
|
staticBuild = true;
|
|
|
|
|
};
|
2019-09-26 10:31:21 +02:00
|
|
|
|
libpfm = super.libpfm.override {
|
|
|
|
|
enableShared = false;
|
|
|
|
|
};
|
2018-12-05 04:17:22 +01:00
|
|
|
|
ipmitool = super.ipmitool.override {
|
|
|
|
|
static = true;
|
|
|
|
|
};
|
|
|
|
|
neon = super.neon.override {
|
|
|
|
|
static = true;
|
|
|
|
|
shared = false;
|
|
|
|
|
};
|
2020-01-03 11:41:52 +01:00
|
|
|
|
fmt = super.fmt.override {
|
|
|
|
|
enableShared = false;
|
|
|
|
|
};
|
2018-12-05 04:17:22 +01:00
|
|
|
|
gifsicle = super.gifsicle.override {
|
|
|
|
|
static = true;
|
|
|
|
|
};
|
|
|
|
|
bzip2 = super.bzip2.override {
|
|
|
|
|
linkStatic = true;
|
|
|
|
|
};
|
|
|
|
|
optipng = super.optipng.override {
|
|
|
|
|
static = true;
|
|
|
|
|
};
|
2020-01-02 18:53:00 +01:00
|
|
|
|
openblas = super.openblas.override {
|
|
|
|
|
enableStatic = true;
|
|
|
|
|
enableShared = false;
|
|
|
|
|
};
|
2019-12-15 22:43:23 +01:00
|
|
|
|
mkl = super.mkl.override { enableStatic = true; };
|
2019-09-29 16:32:56 +02:00
|
|
|
|
nix = super.nix.override { enableStatic = true; };
|
2020-12-07 00:06:50 +01:00
|
|
|
|
nixUnstable = super.nixUnstable.override { enableStatic = true; };
|
2020-01-16 20:02:38 +01:00
|
|
|
|
openssl = (super.openssl_1_1.override { static = true; }).overrideAttrs (o: {
|
|
|
|
|
# OpenSSL doesn't like the `--enable-static` / `--disable-shared` flags.
|
|
|
|
|
configureFlags = (removeUnknownConfigureFlags o.configureFlags);
|
|
|
|
|
});
|
2019-12-16 13:22:20 +01:00
|
|
|
|
arrow-cpp = super.arrow-cpp.override {
|
|
|
|
|
enableShared = false;
|
|
|
|
|
};
|
2018-12-05 04:17:22 +01:00
|
|
|
|
boost = super.boost.override {
|
|
|
|
|
enableStatic = true;
|
|
|
|
|
enableShared = false;
|
2019-09-29 12:01:21 +02:00
|
|
|
|
|
|
|
|
|
# Don’t use new stdenv for boost because it doesn’t like the
|
|
|
|
|
# --disable-shared flag
|
|
|
|
|
stdenv = super.stdenv;
|
2018-12-05 04:17:22 +01:00
|
|
|
|
};
|
2019-12-16 13:39:21 +01:00
|
|
|
|
thrift = super.thrift.override {
|
|
|
|
|
static = true;
|
|
|
|
|
twisted = null;
|
|
|
|
|
};
|
2018-12-05 04:17:22 +01:00
|
|
|
|
gmp = super.gmp.override {
|
|
|
|
|
withStatic = true;
|
|
|
|
|
};
|
2019-12-16 13:05:48 +01:00
|
|
|
|
gflags = super.gflags.override {
|
|
|
|
|
enableShared = false;
|
|
|
|
|
};
|
2018-12-05 04:17:22 +01:00
|
|
|
|
cdo = super.cdo.override {
|
|
|
|
|
enable_all_static = true;
|
|
|
|
|
};
|
|
|
|
|
gsm = super.gsm.override {
|
|
|
|
|
staticSupport = true;
|
|
|
|
|
};
|
2020-09-21 15:09:15 +02:00
|
|
|
|
crc32c = super.crc32c.override {
|
|
|
|
|
staticOnly = true;
|
|
|
|
|
};
|
2018-12-05 04:17:22 +01:00
|
|
|
|
parted = super.parted.override {
|
|
|
|
|
enableStatic = true;
|
|
|
|
|
};
|
|
|
|
|
libiconvReal = super.libiconvReal.override {
|
|
|
|
|
enableShared = false;
|
|
|
|
|
enableStatic = true;
|
|
|
|
|
};
|
|
|
|
|
perl = super.perl.override {
|
|
|
|
|
# Don’t use new stdenv zlib because
|
|
|
|
|
# it doesn’t like the --disable-shared flag
|
|
|
|
|
stdenv = super.stdenv;
|
|
|
|
|
};
|
2019-12-16 13:12:48 +01:00
|
|
|
|
woff2 = super.woff2.override {
|
|
|
|
|
static = true;
|
|
|
|
|
};
|
2019-12-16 13:16:38 +01:00
|
|
|
|
snappy = super.snappy.override {
|
|
|
|
|
static = true;
|
|
|
|
|
};
|
2018-12-13 21:39:04 +01:00
|
|
|
|
lz4 = super.lz4.override {
|
|
|
|
|
enableShared = false;
|
|
|
|
|
enableStatic = true;
|
|
|
|
|
};
|
2019-09-19 18:37:34 +02:00
|
|
|
|
libressl = super.libressl.override {
|
|
|
|
|
buildShared = false;
|
|
|
|
|
};
|
2020-07-01 23:30:31 +02:00
|
|
|
|
libjpeg_turbo = super.libjpeg_turbo.override {
|
|
|
|
|
enableStatic = true;
|
|
|
|
|
enableShared = false;
|
|
|
|
|
};
|
2018-12-05 04:17:22 +01:00
|
|
|
|
|
|
|
|
|
darwin = super.darwin // {
|
|
|
|
|
libiconv = super.darwin.libiconv.override {
|
|
|
|
|
enableShared = false;
|
|
|
|
|
enableStatic = true;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2019-11-20 15:56:47 +01:00
|
|
|
|
kmod = super.kmod.override {
|
|
|
|
|
withStatic = true;
|
|
|
|
|
};
|
2019-12-16 13:39:21 +01:00
|
|
|
|
|
2019-09-29 12:01:21 +02:00
|
|
|
|
curl = super.curl.override {
|
|
|
|
|
# a very sad story: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439039
|
|
|
|
|
gssSupport = false;
|
|
|
|
|
};
|
|
|
|
|
|
2019-11-28 13:57:27 +01:00
|
|
|
|
e2fsprogs = super.e2fsprogs.override {
|
|
|
|
|
shared = false;
|
|
|
|
|
};
|
|
|
|
|
|
2019-02-13 06:07:13 +01:00
|
|
|
|
brotli = super.brotli.override {
|
|
|
|
|
staticOnly = true;
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-11 22:58:47 +02:00
|
|
|
|
zstd = super.zstd.override {
|
2020-07-02 04:29:42 +02:00
|
|
|
|
static = true;
|
2019-10-11 22:58:47 +02:00
|
|
|
|
};
|
|
|
|
|
|
2019-01-30 03:01:24 +01:00
|
|
|
|
llvmPackages_8 = super.llvmPackages_8 // {
|
|
|
|
|
libraries = super.llvmPackages_8.libraries // rec {
|
|
|
|
|
libcxxabi = super.llvmPackages_8.libraries.libcxxabi.override {
|
|
|
|
|
enableShared = false;
|
|
|
|
|
};
|
|
|
|
|
libcxx = super.llvmPackages_8.libraries.libcxx.override {
|
|
|
|
|
enableShared = false;
|
|
|
|
|
inherit libcxxabi;
|
|
|
|
|
};
|
2019-07-29 02:04:05 +02:00
|
|
|
|
libunwind = super.llvmPackages_8.libraries.libunwind.override {
|
|
|
|
|
enableShared = false;
|
|
|
|
|
};
|
2019-01-30 03:01:24 +01:00
|
|
|
|
};
|
|
|
|
|
};
|
2019-11-20 16:46:18 +01:00
|
|
|
|
|
|
|
|
|
ocaml-ng = self.lib.mapAttrs (_: set:
|
|
|
|
|
if set ? overrideScope' then set.overrideScope' ocamlStaticAdapter else set
|
|
|
|
|
) super.ocaml-ng;
|
2019-12-16 13:39:21 +01:00
|
|
|
|
|
2019-06-03 18:22:40 +02:00
|
|
|
|
python27 = super.python27.override { static = true; };
|
2020-03-29 11:27:09 +02:00
|
|
|
|
python36 = super.python36.override { static = true; };
|
|
|
|
|
python37 = super.python37.override { static = true; };
|
|
|
|
|
python38 = super.python38.override { static = true; };
|
|
|
|
|
python39 = super.python39.override { static = true; };
|
|
|
|
|
python3Minimal = super.python3Minimal.override { static = true; };
|
|
|
|
|
|
2020-12-07 00:04:36 +01:00
|
|
|
|
# Note: -static doesn’t work on darwin
|
|
|
|
|
libev = super.libev.override { static = !super.stdenv.hostPlatform.isDarwin; };
|
2020-06-09 00:16:42 +02:00
|
|
|
|
|
|
|
|
|
libexecinfo = super.libexecinfo.override { enableShared = false; };
|
2020-07-01 23:31:14 +02:00
|
|
|
|
|
2020-11-09 19:41:20 +01:00
|
|
|
|
tree-sitter = super.tree-sitter.override {
|
|
|
|
|
enableShared = false;
|
|
|
|
|
enableStatic = true;
|
|
|
|
|
};
|
|
|
|
|
|
2020-07-01 23:31:14 +02:00
|
|
|
|
xorg = super.xorg.overrideScope' (xorgself: xorgsuper: {
|
|
|
|
|
libX11 = xorgsuper.libX11.overrideAttrs (attrs: {
|
|
|
|
|
depsBuildBuild = attrs.depsBuildBuild ++ [ (self.buildPackages.stdenv.cc.libc.static or null) ];
|
|
|
|
|
});
|
|
|
|
|
xauth = xorgsuper.xauth.overrideAttrs (attrs: {
|
|
|
|
|
# missing transitive dependencies
|
|
|
|
|
preConfigure = attrs.preConfigure or "" + ''
|
|
|
|
|
export NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -lxcb -lXau -lXdmcp"
|
|
|
|
|
'';
|
|
|
|
|
});
|
|
|
|
|
xdpyinfo = xorgsuper.xdpyinfo.overrideAttrs (attrs: {
|
|
|
|
|
# missing transitive dependencies
|
|
|
|
|
preConfigure = attrs.preConfigure or "" + ''
|
|
|
|
|
export NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -lXau -lXdmcp"
|
|
|
|
|
'';
|
|
|
|
|
});
|
|
|
|
|
libxcb = xorgsuper.libxcb.overrideAttrs (attrs: {
|
|
|
|
|
configureFlags = attrs.configureFlags ++ [ "--disable-shared" ];
|
|
|
|
|
});
|
|
|
|
|
libXi= xorgsuper.libXi.overrideAttrs (attrs: {
|
|
|
|
|
configureFlags = attrs.configureFlags ++ [ "--disable-shared" ];
|
|
|
|
|
});
|
|
|
|
|
});
|
2018-12-05 04:17:22 +01:00
|
|
|
|
}
|