diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix index c67ede82003..b9f1820df3e 100644 --- a/pkgs/development/interpreters/python/cpython/default.nix +++ b/pkgs/development/interpreters/python/cpython/default.nix @@ -35,7 +35,7 @@ , rebuildBytecode ? true , stripBytecode ? false , includeSiteCustomize ? true -, static ? false +, static ? stdenv.hostPlatform.isStatic # Not using optimizations on Darwin # configure: error: llvm-profdata is required for a --enable-optimizations build but could not be found. , enableOptimizations ? (!stdenv.isDarwin) diff --git a/pkgs/development/libraries/cdo/default.nix b/pkgs/development/libraries/cdo/default.nix index f582be81e86..10e145b34ea 100644 --- a/pkgs/development/libraries/cdo/default.nix +++ b/pkgs/development/libraries/cdo/default.nix @@ -1,7 +1,10 @@ { stdenv, fetchurl, curl, hdf5, netcdf -, enable_cdi_lib ? false # build, install and link to a CDI library [default=no] -, enable_all_static ? false # build a completely statically linked CDO binary [default=no] -, enable_cxx ? false # Use CXX as default compiler [default=no] +, # build, install and link to a CDI library [default=no] + enable_cdi_lib ? false +, # build a completely statically linked CDO binary + enable_all_static ? stdenv.hostPlatform.isStatic +, # Use CXX as default compiler [default=no] + enable_cxx ? false }: stdenv.mkDerivation rec { diff --git a/pkgs/development/libraries/crc32c/default.nix b/pkgs/development/libraries/crc32c/default.nix index b9c12b1889c..c10d218ea42 100644 --- a/pkgs/development/libraries/crc32c/default.nix +++ b/pkgs/development/libraries/crc32c/default.nix @@ -1,5 +1,6 @@ { stdenv, lib, fetchFromGitHub, cmake, gflags -, staticOnly ? false }: +, staticOnly ? stdenv.hostPlatform.isStatic +}: stdenv.mkDerivation rec { pname = "crc32c"; diff --git a/pkgs/development/libraries/gsm/default.nix b/pkgs/development/libraries/gsm/default.nix index 30cffa89938..7214aa6f6b9 100644 --- a/pkgs/development/libraries/gsm/default.nix +++ b/pkgs/development/libraries/gsm/default.nix @@ -1,5 +1,6 @@ { stdenv, fetchurl -, staticSupport ? false # Compile statically (support for packages that look for the static object) +, # Compile statically (support for packages that look for the static object) + staticSupport ? stdenv.hostPlatform.isStatic }: let diff --git a/pkgs/development/libraries/libev/default.nix b/pkgs/development/libraries/libev/default.nix index 1ea0615dc23..9f950ebb09c 100644 --- a/pkgs/development/libraries/libev/default.nix +++ b/pkgs/development/libraries/libev/default.nix @@ -1,4 +1,7 @@ -{ stdenv, fetchurl, static ? false }: +{ stdenv, fetchurl +, # Note: -static hasn’t work on darwin + static ? with stdenv.hostPlatform; isStatic && !isDarwin +}: # Note: this package is used for bootstrapping fetchurl, and thus # cannot use fetchpatch! All mutable patches (generated by GitHub or diff --git a/pkgs/development/libraries/libressl/default.nix b/pkgs/development/libraries/libressl/default.nix index 1f6313d8caa..ae0b63f5577 100644 --- a/pkgs/development/libraries/libressl/default.nix +++ b/pkgs/development/libraries/libressl/default.nix @@ -1,4 +1,6 @@ -{ stdenv, fetchurl, lib, cmake, cacert, fetchpatch, buildShared ? true }: +{ stdenv, fetchurl, lib, cmake, cacert, fetchpatch +, buildShared ? !stdenv.hostPlatform.isStatic +}: let diff --git a/pkgs/development/libraries/nghttp2/default.nix b/pkgs/development/libraries/nghttp2/default.nix index c9ccf63f889..7bcdf8feb30 100644 --- a/pkgs/development/libraries/nghttp2/default.nix +++ b/pkgs/development/libraries/nghttp2/default.nix @@ -8,7 +8,7 @@ , enableAsioLib ? false, boost ? null , enableGetAssets ? false, libxml2 ? null , enableJemalloc ? false, jemalloc ? null -, enableApp ? !stdenv.hostPlatform.isWindows +, enableApp ? with stdenv.hostPlatform; !isWindows && !isStatic , enablePython ? false, python ? null, cython ? null, ncurses ? null, setuptools ? null }: diff --git a/pkgs/development/libraries/snappy/default.nix b/pkgs/development/libraries/snappy/default.nix index e626db8efb7..0880df7ef2f 100644 --- a/pkgs/development/libraries/snappy/default.nix +++ b/pkgs/development/libraries/snappy/default.nix @@ -1,4 +1,6 @@ -{ stdenv, fetchFromGitHub, cmake, static ? false }: +{ stdenv, fetchFromGitHub, cmake +, static ? stdenv.hostPlatform.isStatic +}: stdenv.mkDerivation rec { pname = "snappy"; diff --git a/pkgs/development/web/woff2/default.nix b/pkgs/development/web/woff2/default.nix index d770fb62753..aadeb3cd043 100644 --- a/pkgs/development/web/woff2/default.nix +++ b/pkgs/development/web/woff2/default.nix @@ -1,4 +1,6 @@ -{ brotli, cmake, pkgconfig, fetchFromGitHub, stdenv, static ? false }: +{ brotli, cmake, pkgconfig, fetchFromGitHub, stdenv +, static ? stdenv.hostPlatform.isStatic +}: stdenv.mkDerivation rec { pname = "woff2"; diff --git a/pkgs/os-specific/linux/kmod/default.nix b/pkgs/os-specific/linux/kmod/default.nix index 805b8a32aed..56fd4c353d9 100644 --- a/pkgs/os-specific/linux/kmod/default.nix +++ b/pkgs/os-specific/linux/kmod/default.nix @@ -1,6 +1,7 @@ { stdenv, lib, fetchurl, autoreconfHook, pkgconfig , libxslt, xz, elf-header -, withStatic ? false }: +, withStatic ? stdenv.hostPlatform.isStatic +}: let systems = [ "/run/current-system/kernel-modules" "/run/booted-system/kernel-modules" "" ]; diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix index ddf0aacdf07..e31d1ab707c 100644 --- a/pkgs/servers/x11/xorg/overrides.nix +++ b/pkgs/servers/x11/xorg/overrides.nix @@ -74,7 +74,8 @@ self: super: mkfontdir = self.mkfontscale; libxcb = super.libxcb.overrideAttrs (attrs: { - configureFlags = [ "--enable-xkb" "--enable-xinput" ]; + configureFlags = [ "--enable-xkb" "--enable-xinput" ] + ++ stdenv.lib.optional stdenv.hostPlatform.isStatic "--disable-shared"; outputs = [ "out" "dev" "man" "doc" ]; }); @@ -82,15 +83,18 @@ self: super: outputs = [ "out" "dev" "man" ]; configureFlags = attrs.configureFlags or [] ++ malloc0ReturnsNullCrossFlag; - depsBuildBuild = [ buildPackages.stdenv.cc ]; + depsBuildBuild = [ + buildPackages.stdenv.cc + ] ++ stdenv.lib.optionals stdenv.hostPlatform.isStatic [ + (self.buildPackages.stdenv.cc.libc.static or null) + ]; preConfigure = '' sed 's,^as_dummy.*,as_dummy="\$PATH",' -i configure ''; - postInstall = - '' - # Remove useless DocBook XML files. - rm -rf $out/share/doc - ''; + postInstall = '' + # Remove useless DocBook XML files. + rm -rf $out/share/doc + ''; CPP = stdenv.lib.optionalString stdenv.isDarwin "clang -E -"; propagatedBuildInputs = attrs.propagatedBuildInputs or [] ++ [ self.xorgproto ]; }); @@ -138,6 +142,11 @@ self: super: xdpyinfo = super.xdpyinfo.overrideAttrs (attrs: { configureFlags = attrs.configureFlags or [] ++ malloc0ReturnsNullCrossFlag; + preConfigure = attrs.preConfigure or "" + # missing transitive dependencies + + stdenv.lib.optionalString stdenv.hostPlatform.isStatic '' + export NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -lXau -lXdmcp" + ''; }); # Propagate some build inputs because of header file dependencies. @@ -223,8 +232,9 @@ self: super: libXi = super.libXi.overrideAttrs (attrs: { outputs = [ "out" "dev" "man" "doc" ]; propagatedBuildInputs = attrs.propagatedBuildInputs or [] ++ [ self.libXfixes ]; - configureFlags = stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) - "xorg_cv_malloc0_returns_null=no"; + configureFlags = stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "xorg_cv_malloc0_returns_null=no" + ] ++ stdenv.lib.optional stdenv.hostPlatform.isStatic "--disable-shared"; }); libXinerama = super.libXinerama.overrideAttrs (attrs: { @@ -745,6 +755,11 @@ self: super: xauth = super.xauth.overrideAttrs (attrs: { doCheck = false; # fails + preConfigure = attrs.preConfigure or "" + # missing transitive dependencies + + stdenv.lib.optionalString stdenv.hostPlatform.isStatic '' + export NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -lxcb -lXau -lXdmcp" + ''; }); xcursorthemes = super.xcursorthemes.overrideAttrs (attrs: { diff --git a/pkgs/tools/compression/brotli/default.nix b/pkgs/tools/compression/brotli/default.nix index f4f0ac41563..62873569aae 100644 --- a/pkgs/tools/compression/brotli/default.nix +++ b/pkgs/tools/compression/brotli/default.nix @@ -1,4 +1,6 @@ -{ stdenv, fetchFromGitHub, cmake, fetchpatch, staticOnly ? false }: +{ stdenv, fetchFromGitHub, cmake, fetchpatch +, staticOnly ? stdenv.hostPlatform.isStatic +}: # ?TODO: there's also python lib in there diff --git a/pkgs/tools/compression/zstd/default.nix b/pkgs/tools/compression/zstd/default.nix index c26ca507525..d805602e0df 100644 --- a/pkgs/tools/compression/zstd/default.nix +++ b/pkgs/tools/compression/zstd/default.nix @@ -2,7 +2,7 @@ , fixDarwinDylibNames , file , legacySupport ? false -, static ? false +, static ? stdenv.hostPlatform.isStatic }: stdenv.mkDerivation rec { diff --git a/pkgs/tools/filesystems/e2fsprogs/default.nix b/pkgs/tools/filesystems/e2fsprogs/default.nix index f846bf1f200..f26a41ce142 100644 --- a/pkgs/tools/filesystems/e2fsprogs/default.nix +++ b/pkgs/tools/filesystems/e2fsprogs/default.nix @@ -1,4 +1,6 @@ -{ stdenv, buildPackages, fetchurl, fetchpatch, pkgconfig, libuuid, gettext, texinfo, shared ? true }: +{ stdenv, buildPackages, fetchurl, fetchpatch, pkgconfig, libuuid, gettext, texinfo +, shared ? !stdenv.hostPlatform.isStatic +}: stdenv.mkDerivation rec { pname = "e2fsprogs"; diff --git a/pkgs/tools/graphics/gifsicle/default.nix b/pkgs/tools/graphics/gifsicle/default.nix index 007ba0f9972..72220fab480 100644 --- a/pkgs/tools/graphics/gifsicle/default.nix +++ b/pkgs/tools/graphics/gifsicle/default.nix @@ -1,4 +1,7 @@ -{ stdenv, fetchurl, xorgproto, libXt, libX11, gifview ? false, static ? false }: +{ stdenv, fetchurl, xorgproto, libXt, libX11 +, gifview ? false +, static ? stdenv.hostPlatform.isStatic +}: with stdenv.lib; diff --git a/pkgs/tools/networking/curl/default.nix b/pkgs/tools/networking/curl/default.nix index 82245f4cd26..6f1c202a91c 100644 --- a/pkgs/tools/networking/curl/default.nix +++ b/pkgs/tools/networking/curl/default.nix @@ -7,7 +7,8 @@ , gnutlsSupport ? false, gnutls ? null , wolfsslSupport ? false, wolfssl ? null , scpSupport ? zlibSupport && !stdenv.isSunOS && !stdenv.isCygwin, libssh2 ? null -, gssSupport ? !stdenv.hostPlatform.isWindows, libkrb5 ? null +, # a very sad story re static: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439039 + gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic, libkrb5 ? null , c-aresSupport ? false, c-ares ? null , brotliSupport ? false, brotli ? null }: diff --git a/pkgs/top-level/static.nix b/pkgs/top-level/static.nix index f1d3ea2a159..48e4618762a 100644 --- a/pkgs/top-level/static.nix +++ b/pkgs/top-level/static.nix @@ -108,18 +108,11 @@ in { haskellStaticAdapter; }; - nghttp2 = super.nghttp2.override { - enableApp = false; - }; - zlib = super.zlib.override { # Don’t use new stdenv zlib because # it doesn’t like the --disable-shared flag stdenv = super.stdenv; }; - gifsicle = super.gifsicle.override { - static = true; - }; openssl = super.openssl_1_1.overrideAttrs (o: { # OpenSSL doesn't like the `--enable-static` / `--disable-shared` flags. configureFlags = (removeUnknownConfigureFlags o.configureFlags); @@ -129,86 +122,13 @@ in { # --disable-shared flag stdenv = super.stdenv; }; - cdo = super.cdo.override { - enable_all_static = true; - }; - gsm = super.gsm.override { - staticSupport = true; - }; - crc32c = super.crc32c.override { - staticOnly = true; - }; perl = super.perl.override { # Don’t use new stdenv zlib because # it doesn’t like the --disable-shared flag stdenv = super.stdenv; }; - woff2 = super.woff2.override { - static = true; - }; - snappy = super.snappy.override { - static = true; - }; - libressl = super.libressl.override { - buildShared = false; - }; - - kmod = super.kmod.override { - withStatic = true; - }; - - curl = super.curl.override { - # a very sad story: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439039 - gssSupport = false; - }; - - e2fsprogs = super.e2fsprogs.override { - shared = false; - }; - - brotli = super.brotli.override { - staticOnly = true; - }; - - zstd = super.zstd.override { - static = true; - }; ocaml-ng = self.lib.mapAttrs (_: set: if set ? overrideScope' then set.overrideScope' ocamlStaticAdapter else set ) super.ocaml-ng; - - python27 = super.python27.override { static = true; }; - 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; }; - - # Note: -static doesn’t work on darwin - libev = super.libev.override { static = !super.stdenv.hostPlatform.isDarwin; }; - - 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" ]; - }); - }); }