From 806b05c39f56c4b506520b5e2c010afc02f6efe4 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Wed, 22 Feb 2023 03:39:26 +0000 Subject: [PATCH] Add ability to override lockfile from tools.nix --- tools.nix | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools.nix b/tools.nix index 5fc8d0d6..c9e08586 100644 --- a/tools.nix +++ b/tools.nix @@ -30,10 +30,14 @@ rec { , src , cargoToml ? "Cargo.toml" , additionalCargoNixArgs ? [ ] + , overrideLockFile ? null }: let crateDir = dirOf (src + "/${cargoToml}"); - vendor = internal.vendorSupport { inherit crateDir; }; + vendor = internal.vendorSupport { + inherit crateDir; + additionalLockFiles = if overrideLockFile == null then [ ] else [ overrideLockFile ]; + }; in stdenv.mkDerivation { name = "${name}-crate2nix"; @@ -52,6 +56,11 @@ rec { export CARGO_HOME="$out/cargo" export HOME="$out" + ${if overrideLockFile == null then + "" + else + "cp ${overrideLockFile} ./Cargo.lock"} + cp ${vendor.cargoConfig} $out/cargo/config crate_hashes="$out/crate-hashes.json" @@ -176,7 +185,7 @@ rec { rev = lib.last splitQuestion; }; - vendorSupport = { crateDir ? ./., ... }: + vendorSupport = { crateDir ? ./., additionalLockFiles ? [ ], ... }: rec { toPackageId = { name, version, source, ... }: "${name} ${version} (${source})"; @@ -198,7 +207,7 @@ rec { builtins.map toLockFile subdirs else [ ]; in - fromCrateDir ++ fromSources; + fromCrateDir ++ fromSources ++ additionalLockFiles; locked = let