diff --git a/pkgs/tools/networking/cjdns/default.nix b/pkgs/tools/networking/cjdns/default.nix index 45e6a33e3c8e..dfcc7a5b0ba0 100644 --- a/pkgs/tools/networking/cjdns/default.nix +++ b/pkgs/tools/networking/cjdns/default.nix @@ -8,6 +8,9 @@ , libuv , util-linux , nixosTests +, libsodium +, pkg-config +, substituteAll }: rustPlatform.buildRustPackage rec { @@ -21,20 +24,30 @@ rustPlatform.buildRustPackage rec { sha256 = "sha256-vI3uHZwmbFqxGasKqgCl0PLEEO8RNEhwkn5ZA8K7bxU="; }; + patches = [ + (substituteAll { + src = ./system-libsodium.patch; + libsodium_include_dir = "${libsodium.dev}/include"; + }) + ]; + cargoSha256 = "sha256-x3LxGOhGXrheqdke0eYiQVo/IqgWgcDrDNupdLjRPjA="; nativeBuildInputs = [ which python39 nodejs + pkg-config ] ++ # for flock lib.optional stdenv.isLinux util-linux; buildInputs = [ libuv + libsodium ]; + env.SODIUM_USE_PKG_CONFIG = 1; env.NIX_CFLAGS_COMPILE = toString ([ "-O2" "-Wno-error=array-bounds" diff --git a/pkgs/tools/networking/cjdns/system-libsodium.patch b/pkgs/tools/networking/cjdns/system-libsodium.patch new file mode 100644 index 000000000000..8b7b535b6a21 --- /dev/null +++ b/pkgs/tools/networking/cjdns/system-libsodium.patch @@ -0,0 +1,28 @@ +diff --git a/node_build/make.js b/node_build/make.js +index 1d0b0fa..b640f31 100644 +--- a/node_build/make.js ++++ b/node_build/make.js +@@ -254,21 +254,8 @@ Builder.configure({ + + }).nThen(function (waitFor) { + +- const dir = `${builder.config.buildDir}/../..`; +- Fs.readdir(dir, waitFor((err, ret) => { +- if (err) { throw err; } +- ret.forEach((f) => { +- if (!/^libsodium-sys-/.test(f)) { return; } +- const inclPath = `${dir}/${f}/out/source/libsodium/src/libsodium/include`; +- Fs.readdir(inclPath, waitFor((err, ret) => { +- if (foundSodium) { return; } +- if (err && err.code === 'ENOENT') { return; } +- if (err) { throw err; } +- builder.config.includeDirs.push(inclPath); +- foundSodium = true; +- })); +- }); +- })); ++ builder.config.includeDirs.push("@libsodium_include_dir@"); ++ foundSodium = true; + + }).nThen(function (waitFor) { +