Fixed libsodium issue for windows build

This commit is contained in:
Brian Picciano 2023-12-05 15:05:10 +01:00
parent 25f55cf24d
commit b84a60ba69

View File

@ -128,29 +128,32 @@ let
)
);
in {
# For some reason the pkgsCross.pkgsStatic build of libsodium doesn't contain
# a `.a` file when compiled to a windows target, but rather contains
# a `.dll.a` file which libsodium-sys doesn't pick up on. Copying the one to
# the be the other seems to work.
libsodium = pkgs.runCommand "libsodium-wrapped" {
libsodium = pkgsCross.pkgsStatic.libsodium;
} ''
cp -rL "$libsodium" "$out"
chmod -R +w "$out"
if [ ! -e "$out"/lib/libsodium.a ] && [ -f "$out"/lib/libsodium.dll.a ]; then
cp "$out"/lib/libsodium.dll.a "$out"/lib/libsodium.a
fi
'';
inherit pkgs;
release = naersk.buildPackage rec {
inherit release;
src = ./.;
strictDeps = true;
doCheck = false;
depsBuildBuild = (buildTarget.depsBuildBuild pkgsCross) ++ [
buildEnv = rec {
nativeBuildInputs = (buildTarget.depsBuildBuild pkgsCross) ++ [
toolchain
pkgs.protobuf
];
cargoBuildOptions = prev: prev++[
"--features=${builtins.concatStringsSep "," builtFeatures}"
];
OPENSSL_STATIC = "1";
OPENSSL_LIB_DIR = "${pkgsCross.pkgsStatic.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgsCross.pkgsStatic.openssl.dev}/include";
SODIUM_LIB_DIR = "${libsodium}/lib";
# Required because ring crate is special. This also seems to have
# fixed some issues with the x86_64-windows cross-compile :shrug:
TARGET_CC = "${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc";
@ -168,6 +171,24 @@ in {
];
};
in {
inherit pkgs pkgsCross;
release = naersk.buildPackage (rec {
inherit release;
src = ./.;
strictDeps = true;
doCheck = false;
cargoBuildOptions = prev: prev++[
"--features=${builtins.concatStringsSep "," builtFeatures}"
];
} // buildEnv);
shell = pkgsCross.mkShell buildEnv;
# TODO
#clippy = {
# amd64 = (compile {