Skip to content

Commit 0d2ca29

Browse files
angermancoot
authored andcommitted
dmq-node: static build
``` nix build .\#dmq-node-static ```
1 parent 5d469d9 commit 0d2ca29

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

flake.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@
5252
(import ./nix/tools.nix inputs)
5353
(import ./nix/ouroboros-network.nix inputs)
5454
(import ./nix/network-docs.nix inputs)
55+
(final: _prev: {
56+
static-libsodium-vrf = final.libsodium-vrf.overrideDerivation (old: {
57+
configureFlags = old.configureFlags ++ [ "--disable-shared" ];
58+
});
59+
static-secp256k1 = final.secp256k1.overrideDerivation (old: {
60+
configureFlags = old.configureFlags ++ [ "--enable-static" "--disable-shared" ];
61+
});
62+
static-gmp = (final.gmp.override { withStatic = true; }).overrideDerivation (old: {
63+
configureFlags = old.configureFlags ++ [ "--enable-static" "--disable-shared" ];
64+
});
65+
static-libblst = (final.libblst.override { enableShared = false; }).overrideDerivation (_old: {
66+
postFixup = "";
67+
});
68+
})
5569
];
5670
};
5771

@@ -116,6 +130,10 @@
116130
pkgs.setGitRev
117131
(inputs.self.rev or inputs.self.dirtyShortRev)
118132
flake.packages."dmq-node:exe:dmq-node";
133+
packages.dmq-node-static =
134+
pkgs.setGitRev
135+
(inputs.self.rev or inputs.self.dirtyShortRev)
136+
flake.packages."x86_64-unknown-linux-musl:dmq-node:exe:dmq-node";
119137
inherit hydraJobs legacyPackages devShells;
120138
}
121139
);

nix/ouroboros-network.nix

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ let
5555

5656
# we also want cross compilation to windows on linux (and only with default compiler).
5757
crossPlatforms =
58-
p: lib.optionals (pkgs.stdenv.hostPlatform.isLinux && config.compiler-nix-name == crossGHCVersion) [ p.ucrt64 ];
58+
p: lib.optionals (pkgs.stdenv.hostPlatform.isLinux && config.compiler-nix-name == crossGHCVersion) [ p.ucrt64 p.musl64 ];
5959

6060
#
6161
# VARIANTS
@@ -124,6 +124,14 @@ let
124124
({ pkgs, ... }: lib.mkIf pkgs.stdenv.hostPlatform.isWindows {
125125
packages.basement.configureFlags = [ "--hsc2hs-options=--cflag=-Wno-int-conversion" ];
126126
})
127+
({ pkgs, ... }: lib.mkIf pkgs.stdenv.hostPlatform.isMusl {
128+
packages.dmq-node.ghcOptions = with pkgs; [
129+
"-L${lib.getLib static-gmp}/lib"
130+
"-L${lib.getLib static-libsodium-vrf}/lib"
131+
"-L${lib.getLib static-secp256k1}/lib"
132+
"-L${lib.getLib static-libblst}/lib"
133+
];
134+
})
127135
];
128136
});
129137
in

0 commit comments

Comments
 (0)