2018-12-05 03:17:22 +00:00
|
|
|
|
# Overlay that builds static packages.
|
|
|
|
|
|
|
|
|
|
# Not all packages will build but support is done on a
|
|
|
|
|
# best effort basic.
|
|
|
|
|
#
|
|
|
|
|
# Note on Darwin/macOS: Apple does not provide a static libc
|
|
|
|
|
# so any attempts at static binaries are going to be very
|
|
|
|
|
# unsupported.
|
|
|
|
|
#
|
|
|
|
|
# Basic things like pkgsStatic.hello should work out of the box. More
|
|
|
|
|
# complicated things will need to be fixed with overrides.
|
|
|
|
|
|
|
|
|
|
self: super: let
|
|
|
|
|
inherit (super.stdenvAdapters) makeStaticBinaries
|
2019-07-24 14:04:51 +00:00
|
|
|
|
makeStaticLibraries
|
2021-08-19 17:56:53 +00:00
|
|
|
|
propagateBuildInputs
|
|
|
|
|
makeStaticDarwin;
|
|
|
|
|
inherit (super.lib) foldl optional flip id composeExtensions;
|
2018-12-05 03:17:22 +00:00
|
|
|
|
|
2020-12-06 23:09:07 +00:00
|
|
|
|
staticAdapters =
|
|
|
|
|
optional super.stdenv.hostPlatform.isDarwin makeStaticDarwin
|
|
|
|
|
|
|
|
|
|
++ [ makeStaticLibraries propagateBuildInputs ]
|
2018-12-05 03:17:22 +00:00
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
|
|
# Glibc doesn’t come with static runtimes by default.
|
|
|
|
|
# ++ optional (super.stdenv.hostPlatform.libc == "glibc") ((flip overrideInStdenv) [ self.stdenv.glibc.static ])
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
in {
|
2021-08-19 17:56:53 +00:00
|
|
|
|
# Do not add new packages here! Instead use `stdenv.hostPlatform.isStatic` to
|
|
|
|
|
# write conditional code in the original package.
|
2021-03-23 05:19:50 +00:00
|
|
|
|
|
2021-08-19 17:56:53 +00:00
|
|
|
|
stdenv = foldl (flip id) super.stdenv staticAdapters;
|
2018-12-05 03:17:22 +00:00
|
|
|
|
}
|