From 924c4ebc08e270431664925c42da998d5d7a2616 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sun, 6 Dec 2020 17:04:36 -0600 Subject: [PATCH 1/3] =?UTF-8?q?top-level/static.nix:=20Don=E2=80=99t=20add?= =?UTF-8?q?=20-static=20LDFLAGS=20in=20darwin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can’t do fully static here, like "static" flag in libev does. I’m not 100% sure if this is necessary for Linux (makeStaticBinaries should set -static flag automatically), but leaving as is to avoid breaking anything. --- pkgs/top-level/static.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/static.nix b/pkgs/top-level/static.nix index b3851ba20f0..caea8040620 100644 --- a/pkgs/top-level/static.nix +++ b/pkgs/top-level/static.nix @@ -281,8 +281,8 @@ in { python39 = super.python39.override { static = true; }; python3Minimal = super.python3Minimal.override { static = true; }; - - libev = super.libev.override { static = true; }; + # Note: -static doesn’t work on darwin + libev = super.libev.override { static = !super.stdenv.hostPlatform.isDarwin; }; libexecinfo = super.libexecinfo.override { enableShared = false; }; From 399ac47521d80182668ecbb2360b13ff41e119de Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sun, 6 Dec 2020 17:06:50 -0600 Subject: [PATCH 2/3] top-level/static.nix: also enable static for nixUnstable --- pkgs/top-level/static.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/top-level/static.nix b/pkgs/top-level/static.nix index caea8040620..82708d112f1 100644 --- a/pkgs/top-level/static.nix +++ b/pkgs/top-level/static.nix @@ -163,6 +163,7 @@ in { }; mkl = super.mkl.override { enableStatic = true; }; nix = super.nix.override { enableStatic = true; }; + nixUnstable = super.nixUnstable.override { enableStatic = true; }; openssl = (super.openssl_1_1.override { static = true; }).overrideAttrs (o: { # OpenSSL doesn't like the `--enable-static` / `--disable-shared` flags. configureFlags = (removeUnknownConfigureFlags o.configureFlags); From 805c9d4847b565784d6d00f4379ce6661fea7619 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sun, 6 Dec 2020 17:09:07 -0600 Subject: [PATCH 3/3] top-level/static.nix: put makeStaticDarwin first in staticAdapters This needs to go first since the .override will reset the mkDerivation function, removing any other customisations done afterwards. Kind of hacky, but seems to work correctly right now. --- pkgs/top-level/static.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/top-level/static.nix b/pkgs/top-level/static.nix index 82708d112f1..b8d0d16e97b 100644 --- a/pkgs/top-level/static.nix +++ b/pkgs/top-level/static.nix @@ -34,14 +34,18 @@ self: super: let }); }; - staticAdapters = [ makeStaticLibraries propagateBuildInputs ] + 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 ] # 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 - ++ optional super.stdenv.hostPlatform.isDarwin makeStaticDarwin - # Glibc doesn’t come with static runtimes by default. # ++ optional (super.stdenv.hostPlatform.libc == "glibc") ((flip overrideInStdenv) [ self.stdenv.glibc.static ]) ;