···108108 });
109109 });
110110111111+ # Puts all the other ones together
112112+ makeStatic = stdenv: lib.foldl (lib.flip lib.id) stdenv (
113113+ lib.optional stdenv.hostPlatform.isDarwin makeStaticDarwin
114114+115115+ ++ [ makeStaticLibraries propagateBuildInputs ]
116116+117117+ # Apple does not provide a static version of libSystem or crt0.o
118118+ # So we can’t build static binaries without extensive hacks.
119119+ ++ lib.optional (!stdenv.hostPlatform.isDarwin) makeStaticBinaries
120120+121121+ # Glibc doesn’t come with static runtimes by default.
122122+ # ++ lib.optional (stdenv.hostPlatform.libc == "glibc") ((lib.flip overrideInStdenv) [ self.stdenv.glibc.static ])
123123+ );
124124+111125112126 /* Modify a stdenv so that all buildInputs are implicitly propagated to
113127 consuming derivations
···11-# Overlay that builds static packages.
22-33-# Not all packages will build but support is done on a
44-# best effort basic.
55-#
66-# Note on Darwin/macOS: Apple does not provide a static libc
77-# so any attempts at static binaries are going to be very
88-# unsupported.
99-#
1010-# Basic things like pkgsStatic.hello should work out of the box. More
1111-# complicated things will need to be fixed with overrides.
1212-1313-self: super: let
1414- inherit (super.stdenvAdapters) makeStaticBinaries
1515- makeStaticLibraries
1616- propagateBuildInputs
1717- makeStaticDarwin;
1818- inherit (super.lib) foldl optional flip id composeExtensions;
1919-2020- staticAdapters =
2121- optional super.stdenv.hostPlatform.isDarwin makeStaticDarwin
2222-2323- ++ [ makeStaticLibraries propagateBuildInputs ]
2424-2525- # Apple does not provide a static version of libSystem or crt0.o
2626- # So we can’t build static binaries without extensive hacks.
2727- ++ optional (!super.stdenv.hostPlatform.isDarwin) makeStaticBinaries
2828-2929- # Glibc doesn’t come with static runtimes by default.
3030- # ++ optional (super.stdenv.hostPlatform.libc == "glibc") ((flip overrideInStdenv) [ self.stdenv.glibc.static ])
3131- ;
3232-3333-in {
3434- # Do not add new packages here! Instead use `stdenv.hostPlatform.isStatic` to
3535- # write conditional code in the original package.
3636-3737- stdenv = foldl (flip id) super.stdenv staticAdapters;
3838-}