From 3c12ae1d35a6f71310928aa2c752b5fdd5e96604 Mon Sep 17 00:00:00 2001 From: Tobias Mayer Date: Sun, 21 Jul 2019 06:44:50 +0200 Subject: [PATCH 1/3] Signal static build option in makeStaticLibraries This flag can replace the extra static parameter to packages that don't work automatically with this adapter. --- pkgs/stdenv/adapters.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 8ece43f87b0f..0409bf1104b2 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -62,6 +62,7 @@ rec { ]; mesonFlags = (args.mesonFlags or []) ++ [ "-Ddefault_library=static" ]; }); + static = true; }; /* Modify a stdenv so that the specified attributes are added to From e06b7d9638e7547cc43af9149348d0ebf90d2763 Mon Sep 17 00:00:00 2001 From: Tobias Mayer Date: Sun, 21 Jul 2019 07:36:44 +0200 Subject: [PATCH 2/3] Override alternative stdenvs in pkgsStatic --- pkgs/top-level/static.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/top-level/static.nix b/pkgs/top-level/static.nix index 476ad9de3e95..193356a61ece 100644 --- a/pkgs/top-level/static.nix +++ b/pkgs/top-level/static.nix @@ -53,6 +53,14 @@ self: super: let in { stdenv = foldl (flip id) super.stdenv staticAdapters; + gcc49Stdenv = foldl (flip id) super.gcc49Stdenv staticAdapters; + gcc5Stdenv = foldl (flip id) super.gcc5Stdenv 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; haskell = super.haskell // { packageOverrides = composeExtensions From bb71bb15ce30dfc453648ac8979f938b9b3aeed7 Mon Sep 17 00:00:00 2001 From: Tobias Mayer Date: Wed, 24 Jul 2019 16:04:51 +0200 Subject: [PATCH 3/3] pkgsStatic: propagate all buildInputs --- pkgs/stdenv/adapters.nix | 12 ++++++++++++ pkgs/top-level/static.nix | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 0409bf1104b2..8f62bd24dda1 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -65,6 +65,18 @@ rec { static = true; }; + + /* Modify a stdenv so that all buildInputs are implicitly propagated to + consuming derivations + */ + propagateBuildInputs = stdenv: stdenv // + { mkDerivation = args: stdenv.mkDerivation (args // { + propagatedBuildInputs = (args.propagatedBuildInputs or []) ++ (args.buildInputs or []); + buildInputs = []; + }); + }; + + /* Modify a stdenv so that the specified attributes are added to every derivation returned by its mkDerivation function. diff --git a/pkgs/top-level/static.nix b/pkgs/top-level/static.nix index 193356a61ece..108c6006fb64 100644 --- a/pkgs/top-level/static.nix +++ b/pkgs/top-level/static.nix @@ -12,7 +12,8 @@ self: super: let inherit (super.stdenvAdapters) makeStaticBinaries - makeStaticLibraries; + makeStaticLibraries + propagateBuildInputs; inherit (super.lib) foldl optional flip id composeExtensions; inherit (super) makeSetupHook; @@ -30,7 +31,7 @@ self: super: let }); }; - staticAdapters = [ makeStaticLibraries ] + staticAdapters = [ makeStaticLibraries propagateBuildInputs ] # Apple does not provide a static version of libSystem or crt0.o # So we can’t build static binaries without extensive hacks.