Skip to content

Commit

Permalink
pkgsStatic: Finally obviate overlay!
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 committed Aug 20, 2021
1 parent 9046258 commit 3edba5e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 44 deletions.
14 changes: 14 additions & 0 deletions pkgs/stdenv/adapters.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions pkgs/stdenv/cross/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -83,7 +87,7 @@ in lib.init bootStages ++ [
# to recognize 64-bit DLLs
++ lib.optional (hostPlatform.config == "x86_64-w64-mingw32") buildPackages.file
;
});
}));
})

]
1 change: 0 additions & 1 deletion pkgs/top-level/stage.nix
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ let
overlays = [ (self': super': {
pkgsStatic = super';
})] ++ overlays;
crossOverlays = [ (import ./static.nix) ];
} // lib.optionalAttrs stdenv.hostPlatform.isLinux {
crossSystem = {
isStatic = true;
Expand Down
38 changes: 0 additions & 38 deletions pkgs/top-level/static.nix

This file was deleted.

0 comments on commit 3edba5e

Please sign in to comment.