Skip to content

Commit c418876

Browse files
committed
build(nix): build static package in nix
Signed-off-by: Qiming Chu <cchuqiming@gmail.com>
1 parent 9481dda commit c418876

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

nix/pkgs/git-commit-generator.nix

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
11
{
22
pkgs,
3-
rustPlatform,
43
pkg-config,
5-
openssl,
6-
rustPackages,
7-
...
4+
stdenv,
5+
lib,
86
}:
9-
rustPlatform.buildRustPackage {
7+
8+
let
9+
libiconvLib = pkgs.pkgsStatic.libiconv.dev;
10+
in
11+
pkgs.pkgsStatic.rustPlatform.buildRustPackage {
1012
pname = "git-commit-generator";
1113
version = "0.1.0.0";
1214

1315
cargoLock = {
1416
lockFile = ./../../Cargo.lock;
1517
};
1618
src = ./../..;
17-
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
19+
20+
PKG_CONFIG_PATH = "${pkgs.pkgsStatic.openssl.dev}/lib/pkgconfig";
21+
1822
nativeBuildInputs = [
1923
pkg-config
2024
];
25+
2126
buildInputs = [
22-
rustPackages.clippy
23-
openssl
27+
pkgs.pkgsStatic.openssl.dev
2428
];
29+
30+
RUSTFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin ''
31+
-C link-args=-L${libiconvLib}/lib
32+
'';
33+
34+
NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin ''
35+
-L${libiconvLib}/lib -liconv -lcharset
36+
'';
2537
}

0 commit comments

Comments
 (0)