I’m struggling to build a rust package, most of the time these used to be very easy but starkcli is proving a little troublesome. from a very basic standpoint I tried:
{ lib
, darwin
, fetchFromGitHub
, fetchurl
, rustPlatform
, rustfmt
, stdenv
}:
rustPlatform.buildRustPackage rec {
pname = "starkli";
version = "0.1.11";
doCheck = false;
buildInputs = lib.optional stdenv.isDarwin [
darwin.apple_sdk.frameworks.CoreFoundation
];
src = fetchFromGitHub {
owner = "xJonathanLEI";
repo = pname;
rev = "v${version}";
hash = "sha256-mIcjYP3t0L7M5F6LfQrc3MYGXWItNlzOuG3X8N/eIW8=";
};
cargoLock = {
lockFile = ./Cargo.lock;
allowBuiltinFetchGit = true;
};
cargoDepsName = pname;
meta = with lib; {
description = "CLI tool for Starknet ";
homepage = "https://book.starkli.rs/";
license = licenses.mit;
maintainers = [ ];
};
}
This is failing with
Caused by:
failed to parse manifest at `/build/cargo-vendor-dir/cairo-lang-parser-2.1.0/Cargo.toml`
Caused by:
error inheriting `version` from workspace root manifest's `workspace.package.version`
I understand this is a cargo issue, but I can actually build cairo-lang
separately, its even on nixpkgs
btw I’m not on latest nixpkgs:
$ nix eval -f nix/pkgs.nix rustc.version
"1.67.1"
Now the real question is, can I use the built rust package from nixpkgs (or another derivation) instead of letting this pull it from git and fail due to the workspace issue? I’m also wondering if this is possible to override a dependency version (I understand the risks) and provide a derivation as its source instead of git since its already built
I tried a few things bellow:
newline = "\n";
prePatch = ''
substituteInPlace Cargo.toml \
--replace 'package = "cairo-lang-starknet", git = "https://github.com/starkware-libs/cairo", tag = "v2.1.0"' 'path = "${cairo-lang.src}/"'
substituteInPlace Cargo.lock \
--replace '${newline}source = "git+https://github.com/starkware-libs/cairo?tag=v2.1.0#0f77760aa2e7750b2dda7e708403584e3040b6ad"' ""
'';
even tried copying the Cargo.lock file and using cargoLock
but not much luck so far. I’m not as familiar with the rust toolchain hence any help is appriciated
upon further investigation I’m starting to believe depending on a workspace is not supported in my version of rust toolchain hence the first issue. So either will need to use a newer toolchain or override the Cargo.toml file to split our all the members of the workspace