Skip to content

Commit bb543f0

Browse files
KtorZyvan-sraka
andauthored
Add missing libblst to GHC options of wrapped-cabal in static mode. (#125)
* Add missing libblst to GHC options of wrapped-cabal in static mode. * comment out post-fixup * Overwrite buildPhase for libblst static The current buildPhase in NixOS/nixpkgs does something like this: ``` ./build.sh ${lib.optionalString stdenv.hostPlatform.isWindows "flavour=mingw64"} ./build.sh -shared ${lib.optionalString stdenv.hostPlatform.isWindows "flavour=mingw64"} ``` So we do build both a dynamic and static version, for convenience, which is then correctly visible in the nix store (both `.a` and `.dylib` are present). BUT, it seems that because of the presence of the dynamic lib, cabal or GHC (?) still chose to bundle the library dynamically despite the static flags. Removing the `.dylib` from the nix store recover the expected behavior (libblst being statically linked). This is odd, but the current fix is to not build the `-shared` version of the library at all when in the static shell. Co-authored-by: yvan-sraka <yvan@sraka.xyz> * Enforce the use of static libraries in `-static` devshell --------- Co-authored-by: Yvan Sraka <yvan@sraka.xyz>
1 parent 8dcb4f0 commit bb543f0

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

flake.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@
2323
static-openssl = (final.openssl.override { static = true; });
2424
static-zlib = final.zlib.override { shared = false; };
2525
static-pcre = final.pcre.override { shared = false; };
26+
static-libblst = final.libblst.overrideDerivation (old: {
27+
configureFlags = old.configureFlags ++ [ "--enable-static" "--disable-shared" ];
28+
buildPhase = ''
29+
runHook preBuild
30+
./build.sh
31+
runHook postBuild
32+
'';
33+
postFixup = "";
34+
});
2635
});
2736
# the haskell inline-r package depends on internals of the R
2837
# project that have been hidden in R 4.2+. See

static.nix

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ let tool-version-map = import ./tool-map.nix;
3939
--ghc-option=-L${lib.getLib static-gmp}/lib \
4040
--ghc-option=-L${lib.getLib static-libsodium-vrf}/lib \
4141
--ghc-option=-L${lib.getLib static-secp256k1}/lib \
42+
--ghc-option=-L${lib.getLib static-libblst}/lib \
4243
--ghc-option=-L${lib.getLib static-openssl}/lib
4344
;;
4445
clean|unpack)
@@ -105,15 +106,14 @@ pkgs.mkShell (rec {
105106
# it _should_ probably call out to a g++ or clang++ but doesn't.
106107
stdenv.cc.cc.lib
107108
]) ++ map lib.getDev ([
108-
static-gmp
109-
110-
zlib
111109
pcre
112-
openssl
110+
static-gmp
111+
static-openssl
112+
static-zlib
113113
] ++ lib.optionals withIOG [
114-
libblst
115-
libsodium-vrf
116-
secp256k1
114+
static-libblst
115+
static-libsodium-vrf
116+
static-secp256k1
117117
#R_4_1_3 # for plutus
118118
postgresql # for db-sync
119119
icu # for cardano-cli

0 commit comments

Comments
 (0)