From 1a3ae9e128ebde245c4b5a1bf9bf772438d654d6 Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 4 Nov 2024 16:38:37 -0500 Subject: nix: remove references to openssl in static build --- nix/package.nix | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'nix/package.nix') 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; -- cgit v1.2.3