summaryrefslogtreecommitdiff
path: root/nix
diff options
context:
space:
mode:
authorseth <[email protected]>2024-11-04 16:38:37 -0500
committerseth <[email protected]>2024-11-04 16:38:52 -0500
commit1a3ae9e128ebde245c4b5a1bf9bf772438d654d6 (patch)
tree0ed1b21faee54fadc09dfedc3dbe50e2cb1ba22e /nix
parentf3256a74368e365113f1e081b8519a514a5b0ef2 (diff)
nix: remove references to openssl in static build
Diffstat (limited to 'nix')
-rw-r--r--nix/package.nix21
1 files changed, 17 insertions, 4 deletions
diff --git a/nix/package.nix b/nix/package.nix
index e1eeaef..d0d1a83 100644
--- a/nix/package.nix
+++ b/nix/package.nix
@@ -3,6 +3,7 @@
stdenv,
openssl,
pkg-config,
+ removeReferencesTo,
rustPlatform,
self,
@@ -26,14 +27,28 @@ rustPlatform.buildRustPackage {
cargoLock.lockFile = ../Cargo.lock;
- nativeBuildInputs = [ pkg-config ];
+ nativeBuildInputs = [
+ pkg-config
+ removeReferencesTo
+ ];
+
buildInputs = [ openssl ];
+ # `-C panic="abort"` breaks checks
+ doCheck = !optimizeSize;
+
+ postFixup = lib.optionalString stdenv.hostPlatform.isStatic ''
+ find "$out" \
+ -type f \
+ -exec remove-references-to -t ${stdenv.cc.libc} -t ${openssl.dev} '{}' +
+ '';
+
env =
let
rustFlags =
lib.optionalAttrs lto {
lto = "thin";
+ embed-bitcode = "yes";
}
// lib.optionalAttrs optimizeSize {
codegen-units = 1;
@@ -43,9 +58,7 @@ rustPlatform.buildRustPackage {
};
in
{
- CARGO_BUILD_RUSTFLAGS = toString (
- lib.mapAttrsToList (name: value: "-C ${name}=${toString value}") rustFlags
- );
+ RUSTFLAGS = toString (lib.mapAttrsToList (name: value: "-C ${name}=${toString value}") rustFlags);
}
// lib.optionalAttrs stdenv.hostPlatform.isStatic {
OPENSSL_STATIC = 1;