nix: use rust tooling from rust-overlay for builds

Noticed the builds in `nix/default.nix` were not using the tooling
from `rust-overlay` but instead using older one from `pkgs`.

This also removes the need to compile LLVM before building Zerokit.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski
2025-05-27 20:17:18 +02:00
parent 4133f1f8c3
commit 19c0f551c8
4 changed files with 28 additions and 10 deletions

2
.gitignore vendored
View File

@@ -11,7 +11,7 @@ debug/
target/
# Generated by Nix
result/
result
# These are backup files generated by rustfmt
**/*.rs.bk

6
flake.lock generated
View File

@@ -29,11 +29,11 @@
]
},
"locked": {
"lastModified": 1745289264,
"narHash": "sha256-7nt+UJ7qaIUe2J7BdnEEph9n2eKEwxUwKS/QIr091uA=",
"lastModified": 1748399823,
"narHash": "sha256-kahD8D5hOXOsGbNdoLLnqCL887cjHkx98Izc37nDjlA=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "3b7171858c20d5293360042936058fb0c4cb93a9",
"rev": "d68a69dc71bc19beb3479800392112c2f6218159",
"type": "github"
},
"original": {

View File

@@ -10,7 +10,7 @@
};
};
outputs = { self, nixpkgs, rust-overlay }:
outputs = { self, nixpkgs, rust-overlay }:
let
stableSystems = [
"x86_64-linux" "aarch64-linux"
@@ -26,7 +26,11 @@
packages = forAllSystems (system: let
pkgs = pkgsFor.${system};
in rec {
zerokit-android-arm64 = pkgs.callPackage ./nix/default.nix { target-platform="aarch64-android-prebuilt"; rust-target= "aarch64-linux-android"; };
zerokit-android-arm64 = pkgs.callPackage ./nix/default.nix {
target-platform = "aarch64-android-prebuilt";
rust-target = "aarch64-linux-android";
inherit rust-overlay;
};
default = zerokit-android-arm64;
});
@@ -52,4 +56,4 @@
};
});
};
}
}

View File

@@ -1,10 +1,24 @@
{
{
pkgs,
rust-overlay,
target-platform ? "aarch64-android-prebuilt",
rust-target ? "aarch64-linux-android",
}:
pkgs.pkgsCross.${target-platform}.rustPlatform.buildRustPackage {
let
# Use cross-compilation if target-platform is specified.
targetPlatformPkgs = if target-platform != null
then pkgs.pkgsCross.${target-platform}
else pkgs;
rust-bin = rust-overlay.lib.mkRustBin { } targetPlatformPkgs.buildPackages;
# Use Rust and Cargo versions from rust-overlay.
rustPlatform = targetPlatformPkgs.makeRustPlatform {
cargo = rust-bin.stable.latest.minimal;
rustc = rust-bin.stable.latest.minimal;
};
in rustPlatform.buildRustPackage {
pname = "zerokit";
version = "nightly";
@@ -32,4 +46,4 @@ pkgs.pkgsCross.${target-platform}.rustPlatform.buildRustPackage {
description = "Zerokit";
license = licenses.mit;
};
}
}