mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-02-17 20:33:11 +00:00
refactor nix and add nimbleDeps package
This commit is contained in:
parent
cb6eb04728
commit
c242bd51f7
@ -12,9 +12,6 @@
|
||||
zerokitRln,
|
||||
}:
|
||||
|
||||
assert pkgs.lib.assertMsg ((src.submodules or true) == true)
|
||||
"Unable to build without submodules. Append '?submodules=1#' to the URI.";
|
||||
|
||||
let
|
||||
inherit (pkgs) stdenv lib writeScriptBin callPackage;
|
||||
|
||||
@ -24,13 +21,22 @@ let
|
||||
version = tools.findKeyValue "^version = \"([a-f0-9.-]+)\"$" ../waku.nimble;
|
||||
revision = lib.substring 0 8 (src.rev or src.dirtyRev or "00000000");
|
||||
|
||||
nimbleDeps = callPackage ./deps.nix {
|
||||
inherit src version revision;
|
||||
};
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
pname = "logos-messaging-nim";
|
||||
pname = "logos-message-delivery";
|
||||
inherit src;
|
||||
version = "${version}-${revision}";
|
||||
|
||||
inherit src;
|
||||
env = {
|
||||
ANDROID_SDK_ROOT="${pkgs.androidPkgs.sdk}";
|
||||
ANDROID_NDK_HOME="${pkgs.androidPkgs.ndk}";
|
||||
NIMFLAGS = "-d:disableMarchNative -d:git_revision_override=${revision}";
|
||||
XDG_CACHE_HOME = "/tmp";
|
||||
};
|
||||
|
||||
# Runtime dependencies
|
||||
buildInputs = with pkgs; [
|
||||
openssl gmp zip
|
||||
];
|
||||
@ -40,17 +46,11 @@ in stdenv.mkDerivation {
|
||||
# Fix for Nim compiler calling 'git rev-parse' and 'lsb_release'.
|
||||
fakeGit = writeScriptBin "git" "echo ${version}";
|
||||
in with pkgs; [
|
||||
cmake which zerokitRln nim-unwrapped-2_2 fakeGit
|
||||
cmake which zerokitRln nim-unwrapped-2_2 fakeGit nimbleDeps
|
||||
] ++ lib.optionals stdenv.isDarwin [
|
||||
pkgs.darwin.cctools gcc # Necessary for libbacktrace
|
||||
];
|
||||
|
||||
# Environment variables required for Android builds
|
||||
ANDROID_SDK_ROOT="${pkgs.androidPkgs.sdk}";
|
||||
ANDROID_NDK_HOME="${pkgs.androidPkgs.ndk}";
|
||||
NIMFLAGS = "-d:disableMarchNative -d:git_revision_override=${revision}";
|
||||
XDG_CACHE_HOME = "/tmp";
|
||||
|
||||
makeFlags = targets ++ [
|
||||
"V=${toString verbosity}"
|
||||
"QUICK_AND_DIRTY_COMPILER=${if quickAndDirty then "1" else "0"}"
|
||||
@ -60,27 +60,12 @@ in stdenv.mkDerivation {
|
||||
];
|
||||
|
||||
configurePhase = ''
|
||||
patchShebangs . vendor/nimbus-build-system > /dev/null
|
||||
make nimbus-build-system-paths
|
||||
make nimbus-build-system-nimble-dir
|
||||
'';
|
||||
|
||||
# For the Nim v2.2.4 built with NBS we added sat and zippy
|
||||
preBuild = lib.optionalString (!useSystemNim) ''
|
||||
pushd vendor/nimbus-build-system/vendor/Nim
|
||||
mkdir dist
|
||||
mkdir -p dist/nimble/vendor/sat
|
||||
mkdir -p dist/nimble/vendor/checksums
|
||||
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
|
||||
popd
|
||||
export NIMBLE_DIR=$NIX_BUILD_TOP/nimbledeps
|
||||
cp -r ${nimbleDeps}/nimbledeps $NIMBLE_DIR
|
||||
cp ${nimbleDeps}/nimble.paths ./
|
||||
chmod 775 -R $NIMBLE_DIR
|
||||
# Fix relative paths to absolute paths
|
||||
sed -i "s|./nimbledeps|$NIMBLE_DIR|g" nimble.paths
|
||||
'';
|
||||
|
||||
installPhase = if abidir != null then ''
|
||||
@ -99,8 +84,8 @@ in stdenv.mkDerivation {
|
||||
'';
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
description = "NWaku derivation to build libwaku for mobile targets using Android NDK and Rust.";
|
||||
homepage = "https://github.com/status-im/nwaku";
|
||||
description = "Logos-message-delivery derivation.";
|
||||
homepage = "https://github.com/logos-messaging/logos-messaging-nim";
|
||||
license = licenses.mit;
|
||||
platforms = stableSystems;
|
||||
};
|
||||
|
||||
55
nix/deps.nix
Normal file
55
nix/deps.nix
Normal file
@ -0,0 +1,55 @@
|
||||
{ pkgs, stdenv, src, version, revision }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "logos-delivery-nimble-deps";
|
||||
version = "${version}-${revision}";
|
||||
|
||||
inherit src;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
jq rsync git nimble cacert moreutils
|
||||
];
|
||||
|
||||
configurePhase = ''
|
||||
export XDG_CACHE_HOME=$TMPDIR
|
||||
export NIMBLE_DIR=$NIX_BUILD_TOP/nimbledir
|
||||
export HOME=$TMPDIR
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
nimble --version
|
||||
nimble --silent --localdeps setup
|
||||
nimble --silent --localdeps install -y --depsOnly
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/nimbledeps
|
||||
|
||||
cp nimble.paths $out/nimble.paths
|
||||
|
||||
rsync -ra \
|
||||
--prune-empty-dirs \
|
||||
--include='*/' \
|
||||
--include='*.json' \
|
||||
--include='*.nim' \
|
||||
--include='*.nimble' \
|
||||
--exclude='*' \
|
||||
$NIMBLE_DIR/pkgs2 $out/nimbledeps
|
||||
'';
|
||||
|
||||
fixupPhase = ''
|
||||
# Replace build path with deterministic $out.
|
||||
sed "s|$NIMBLE_DIR|./nimbledeps|g" $out/nimble.paths \
|
||||
| sort | sponge $out/nimble.paths
|
||||
|
||||
# Nimble does not maintain order of files list.
|
||||
for META_FILE in $(find $out -name nimblemeta.json); do
|
||||
jq '.metaData.files |= sort' $META_FILE | sponge $META_FILE
|
||||
done
|
||||
'';
|
||||
|
||||
# Make this a fixed-output derivation to allows internet access for Nimble.
|
||||
outputHash = "sha256-OnirsXLj4HMVTbk+b4fcC+1K9MSMJyae6I7JO16WDno=";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHashMode = "recursive";
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user