mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-05 23:43:07 +00:00
nix: add libwaku target, fix compiling Nim using NBS
Use Nim built by NBS otherwise it doesn't work for both libwaku and wakucanary. Referenced issue: * https://github.com/status-im/status-go/issues/7152
This commit is contained in:
parent
dafdee9f5f
commit
9a458c2fd4
13
flake.nix
13
flake.nix
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
description = "NWaku build flake";
|
description = "Logos Messaging Nim build flake";
|
||||||
|
|
||||||
nixConfig = {
|
nixConfig = {
|
||||||
extra-substituters = [ "https://nix-cache.status.im/" ];
|
extra-substituters = [ "https://nix-cache.status.im/" ];
|
||||||
@ -54,10 +54,21 @@
|
|||||||
zerokitRln = zerokit.packages.${system}.rln-android-arm64;
|
zerokitRln = zerokit.packages.${system}.rln-android-arm64;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
libwaku= pkgs.callPackage ./nix/default.nix {
|
||||||
|
inherit stableSystems;
|
||||||
|
src = self;
|
||||||
|
targets = ["libwaku"];
|
||||||
|
# We are not able to compile the code with nim-unwrapped-2_0
|
||||||
|
useSystemNim = false;
|
||||||
|
zerokitRln = zerokit.packages.${system}.rln;
|
||||||
|
};
|
||||||
|
|
||||||
wakucanary = pkgs.callPackage ./nix/default.nix {
|
wakucanary = pkgs.callPackage ./nix/default.nix {
|
||||||
inherit stableSystems;
|
inherit stableSystems;
|
||||||
src = self;
|
src = self;
|
||||||
targets = ["wakucanary"];
|
targets = ["wakucanary"];
|
||||||
|
# We are not able to compile the code with nim-unwrapped-2_0
|
||||||
|
useSystemNim = false;
|
||||||
zerokitRln = zerokit.packages.${system}.rln;
|
zerokitRln = zerokit.packages.${system}.rln;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -8,5 +8,5 @@ in pkgs.fetchFromGitHub {
|
|||||||
repo = "checksums";
|
repo = "checksums";
|
||||||
rev = tools.findKeyValue "^ +ChecksumsStableCommit = \"([a-f0-9]+)\".*$" sourceFile;
|
rev = tools.findKeyValue "^ +ChecksumsStableCommit = \"([a-f0-9]+)\".*$" sourceFile;
|
||||||
# WARNING: Requires manual updates when Nim compiler version changes.
|
# WARNING: Requires manual updates when Nim compiler version changes.
|
||||||
hash = "sha256-Bm5iJoT2kAvcTexiLMFBa9oU5gf7d4rWjo3OiN7obWQ=";
|
hash = "sha256-JZhWqn4SrAgNw/HLzBK0rrj3WzvJ3Tv1nuDMn83KoYY=";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ let
|
|||||||
|
|
||||||
in stdenv.mkDerivation rec {
|
in stdenv.mkDerivation rec {
|
||||||
|
|
||||||
pname = "nwaku";
|
pname = "logos-messaging-nim";
|
||||||
|
|
||||||
version = "1.0.0-${revision}";
|
version = "1.0.0-${revision}";
|
||||||
|
|
||||||
@ -72,6 +72,19 @@ in stdenv.mkDerivation rec {
|
|||||||
"USE_SYSTEM_NIM=${if useSystemNim then "1" else "0"}"
|
"USE_SYSTEM_NIM=${if useSystemNim then "1" else "0"}"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
cat > scripts/build_rln.sh << 'EOF'
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
build_dir=$1
|
||||||
|
rln_version=$2
|
||||||
|
output_filename=$3
|
||||||
|
# Just copy the library we already have
|
||||||
|
cp ${zerokitRln}/target/release/librln.a "$output_filename"
|
||||||
|
EOF
|
||||||
|
chmod +x scripts/build_rln.sh
|
||||||
|
'';
|
||||||
|
|
||||||
configurePhase = ''
|
configurePhase = ''
|
||||||
patchShebangs . vendor/nimbus-build-system > /dev/null
|
patchShebangs . vendor/nimbus-build-system > /dev/null
|
||||||
make nimbus-build-system-paths
|
make nimbus-build-system-paths
|
||||||
@ -80,17 +93,25 @@ in stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
preBuild = ''
|
preBuild = ''
|
||||||
ln -s waku.nimble waku.nims
|
ln -s waku.nimble waku.nims
|
||||||
|
|
||||||
|
${lib.optionalString (!useSystemNim) ''
|
||||||
pushd vendor/nimbus-build-system/vendor/Nim
|
pushd vendor/nimbus-build-system/vendor/Nim
|
||||||
|
|
||||||
mkdir dist
|
mkdir dist
|
||||||
cp -r ${callPackage ./nimble.nix {}} dist/nimble
|
mkdir -p dist/nimble/vendor/sat
|
||||||
cp -r ${callPackage ./checksums.nix {}} dist/checksums
|
mkdir -p dist/nimble/vendor/checksums
|
||||||
cp -r ${callPackage ./csources.nix {}} csources_v2
|
mkdir -p dist/nimble/vendor/zippy
|
||||||
|
|
||||||
|
cp -r ${callPackage ./nimble.nix {}}/. dist/nimble
|
||||||
|
cp -r ${callPackage ./checksums.nix {}}/. dist/checksums
|
||||||
|
cp -r ${callPackage ./csources.nix {}}/. csources_v2
|
||||||
|
cp -r ${callPackage ./sat.nix {}}/. dist/nimble/vendor/sat
|
||||||
|
cp -r ${callPackage ./checksums.nix {}}/. dist/nimble/vendor/checksums
|
||||||
|
cp -r ${callPackage ./zippy.nix {}}/. dist/nimble/vendor/zippy
|
||||||
chmod 777 -R dist/nimble csources_v2
|
chmod 777 -R dist/nimble csources_v2
|
||||||
|
|
||||||
popd
|
popd
|
||||||
cp -r ${zerokitRln}/target vendor/zerokit/
|
''}
|
||||||
find vendor/zerokit/target
|
|
||||||
# FIXME
|
|
||||||
cp vendor/zerokit/target/*/release/librln.a librln_v${zerokitRln.version}.a
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = if abidir != null then ''
|
installPhase = if abidir != null then ''
|
||||||
@ -99,8 +120,15 @@ in stdenv.mkDerivation rec {
|
|||||||
echo '${androidManifest}' > $out/jni/AndroidManifest.xml
|
echo '${androidManifest}' > $out/jni/AndroidManifest.xml
|
||||||
cd $out && zip -r libwaku.aar *
|
cd $out && zip -r libwaku.aar *
|
||||||
'' else ''
|
'' else ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin $out/include
|
||||||
cp -r build/* $out/bin
|
|
||||||
|
# Copy library files
|
||||||
|
cp build/*.so $out/bin/ 2>/dev/null || true
|
||||||
|
cp build/*.a $out/bin/ 2>/dev/null || true
|
||||||
|
cp build/*.dylib $out/bin/ 2>/dev/null || true
|
||||||
|
|
||||||
|
# Copy the header file
|
||||||
|
cp library/libwaku.h $out/include/
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with pkgs.lib; {
|
meta = with pkgs.lib; {
|
||||||
|
|||||||
@ -8,5 +8,5 @@ in pkgs.fetchFromGitHub {
|
|||||||
repo = "nimble";
|
repo = "nimble";
|
||||||
rev = tools.findKeyValue "^ +NimbleStableCommit = \"([a-f0-9]+)\".*$" sourceFile;
|
rev = tools.findKeyValue "^ +NimbleStableCommit = \"([a-f0-9]+)\".*$" sourceFile;
|
||||||
# WARNING: Requires manual updates when Nim compiler version changes.
|
# WARNING: Requires manual updates when Nim compiler version changes.
|
||||||
hash = "sha256-MVHf19UbOWk8Zba2scj06PxdYYOJA6OXrVyDQ9Ku6Us=";
|
hash = "sha256-8iutVgNzDtttZ7V+7S11KfLEuwhKA9TsgS51mlUI08k=";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ pkgs.mkShell {
|
|||||||
git
|
git
|
||||||
cargo
|
cargo
|
||||||
rustup
|
rustup
|
||||||
|
rustc
|
||||||
cmake
|
cmake
|
||||||
nim-unwrapped-2_0
|
nim-unwrapped-2_0
|
||||||
];
|
];
|
||||||
|
|||||||
9
nix/zippy.nix
Normal file
9
nix/zippy.nix
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{ pkgs }:
|
||||||
|
|
||||||
|
pkgs.fetchFromGitHub {
|
||||||
|
owner = "guzba";
|
||||||
|
repo = "zippy";
|
||||||
|
rev = "a99f6a7d8a8e3e0213b3cad0daf0ea974bf58e3f";
|
||||||
|
# WARNING: Requires manual updates when Nim compiler version changes.
|
||||||
|
hash = "sha256-e2ma2Oyp0dlNx8pJsdZl5o5KnaoAX87tqfY0RLG3DZs=";
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user