Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkgs/development/libraries/libexecinfo/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, fetchurl, fetchpatch }:
{ stdenv, fetchurl, fetchpatch, enableStatic ? true, enableShared ? true }:

stdenv.mkDerivation rec {
pname = "libexecinfo";
Expand Down Expand Up @@ -29,12 +29,19 @@ stdenv.mkDerivation rec {

makeFlags = [ "CC:=$(CC)" "AR:=$(AR)" ];

buildFlags =
stdenv.lib.optional enableStatic "static"
++ stdenv.lib.optional enableShared "dynamic";

patchFlags = [ "-p0" ];

installPhase = ''
install -Dm644 execinfo.h stacktraverse.h -t $out/include
install -Dm755 libexecinfo.{a,so.1} -t $out/lib
'' + stdenv.lib.optionalString enableShared ''
install -Dm755 libexecinfo.so.1 -t $out/lib
ln -s $out/lib/libexecinfo.so{.1,}
'' + stdenv.lib.optionalString enableStatic ''
install -Dm755 libexecinfo.a -t $out/lib
'';

meta = with stdenv.lib; {
Expand Down
17 changes: 13 additions & 4 deletions pkgs/tools/package-management/nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ common =
, stateDir
, confDir
, withLibseccomp ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) libseccomp.meta.platforms, libseccomp
, withAWS ? stdenv.isLinux || stdenv.isDarwin, aws-sdk-cpp

, withAWS ? !enableStatic && (stdenv.isLinux || stdenv.isDarwin), aws-sdk-cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably best to keep these options separate. There’s no reason for aws to not work statically, but it is broken currently.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it can't compile it seems better to do it in the package rather than at call time.

, enableStatic ? false
, name, suffix ? "", src, crates ? null

}:
Expand Down Expand Up @@ -65,12 +65,21 @@ common =
propagatedBuildInputs = [ boehmgc ];

# Seems to be required when using std::atomic with 64-bit types
NIX_LDFLAGS = lib.optionalString (stdenv.hostPlatform.system == "armv5tel-linux" || stdenv.hostPlatform.system == "armv6l-linux") "-latomic";
NIX_LDFLAGS =
# need to list libraries individually until
# https://github.com/NixOS/nix/commit/3e85c57a6cbf46d5f0fe8a89b368a43abd26daba
# is in a release
lib.optionalString enableStatic "-lssl -lbrotlicommon -lssh2 -lz -lnghttp2 -lcrypto"

# need to detect it here until
# https://github.com/NixOS/nix/commits/74b4737d8f0e1922ef5314a158271acf81cd79f8
# is in a release
+ lib.optionalString (stdenv.hostPlatform.system == "armv5tel-linux" || stdenv.hostPlatform.system == "armv6l-linux") "-latomic";

preConfigure =
# Copy libboost_context so we don't get all of Boost in our closure.
# https://github.com/NixOS/nixpkgs/issues/45462
''
lib.optionalString (!enableStatic) ''
mkdir -p $out/lib
cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib
rm -f $out/lib/*.a
Expand Down
4 changes: 3 additions & 1 deletion pkgs/top-level/static.nix
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ in {
enableShared = false;
};
mkl = super.mkl.override { enableStatic = true; };
nix = super.nix.override { withAWS = false; };
nix = super.nix.override { enableStatic = true; };
openssl = (super.openssl_1_1.override { static = true; }).overrideAttrs (o: {
# OpenSSL doesn't like the `--enable-static` / `--disable-shared` flags.
configureFlags = (removeUnknownConfigureFlags o.configureFlags);
Expand Down Expand Up @@ -274,4 +274,6 @@ in {


libev = super.libev.override { static = true; };

libexecinfo = super.libexecinfo.override { enableShared = false; };
}