about summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2021-08-20 06:03:45 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2021-08-20 06:09:48 +0000
commit3edba5edfceef20c613c37967685f5eb04d1877d (patch)
tree88120499a4c8cf26e6e10f2899ee13f016da5e7c /pkgs/stdenv
parent904625852d535bbe53cadb006c9e1137ab481818 (diff)
pkgsStatic: Finally obviate overlay!
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/adapters.nix14
-rw-r--r--pkgs/stdenv/cross/default.nix14
2 files changed, 23 insertions, 5 deletions
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix
index 9e1c73a57db14..971be95e935d7 100644
--- a/pkgs/stdenv/adapters.nix
+++ b/pkgs/stdenv/adapters.nix
@@ -108,6 +108,20 @@ rec {
     });
   });
 
+  # Puts all the other ones together
+  makeStatic = stdenv: lib.foldl (lib.flip lib.id) stdenv (
+    lib.optional 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.
+    ++ lib.optional (!stdenv.hostPlatform.isDarwin) makeStaticBinaries
+
+    # Glibc doesn’t come with static runtimes by default.
+    # ++ lib.optional (stdenv.hostPlatform.libc == "glibc") ((lib.flip overrideInStdenv) [ self.stdenv.glibc.static ])
+  );
+
 
   /* Modify a stdenv so that all buildInputs are implicitly propagated to
      consuming derivations
diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix
index 18a6e2a473727..613b8d5304c01 100644
--- a/pkgs/stdenv/cross/default.nix
+++ b/pkgs/stdenv/cross/default.nix
@@ -35,12 +35,16 @@ in lib.init bootStages ++ [
   })
 
   # Run Packages
-  (buildPackages: {
+  (buildPackages: let
+    adaptStdenv =
+      if crossSystem.isStatic
+      then buildPackages.stdenvAdapters.makeStatic
+      else lib.id;
+  in {
     inherit config;
-    overlays = overlays ++ crossOverlays
-      ++ (if (with crossSystem; isWasm || isRedox) then [(import ../../top-level/static.nix)] else []);
+    overlays = overlays ++ crossOverlays;
     selfBuild = false;
-    stdenv = buildPackages.stdenv.override (old: rec {
+    stdenv = adaptStdenv (buildPackages.stdenv.override (old: rec {
       buildPlatform = localSystem;
       hostPlatform = crossSystem;
       targetPlatform = crossSystem;
@@ -83,7 +87,7 @@ in lib.init bootStages ++ [
            # to recognize 64-bit DLLs
         ++ lib.optional (hostPlatform.config == "x86_64-w64-mingw32") buildPackages.file
         ;
-    });
+    }));
   })
 
 ]