diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 671306f6e6f..850785cd881 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -32,13 +32,15 @@ rec { # Return a modified stdenv that tries to build statically linked # binaries. makeStaticBinaries = stdenv: stdenv // - { mkDerivation = args: stdenv.mkDerivation (args // { - NIX_CFLAGS_LINK = "-static"; + { mkDerivation = args: + if stdenv.hostPlatform.isDarwin + then throw "Cannot build fully static binaries on Darwin/macOS" + else stdenv.mkDerivation (args // { + NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "") + "-static"; configureFlags = (args.configureFlags or []) ++ [ "--disable-shared" # brrr... ]; }); - isStatic = true; };