Skip to content

Commit

Permalink
Add ability to override lockfile from tools.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Feb 22, 2023
1 parent a40edce commit 806b05c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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"
Expand Down Expand Up @@ -176,7 +185,7 @@ rec {
rev = lib.last splitQuestion;
};

vendorSupport = { crateDir ? ./., ... }:
vendorSupport = { crateDir ? ./., additionalLockFiles ? [ ], ... }:
rec {
toPackageId = { name, version, source, ... }:
"${name} ${version} (${source})";
Expand All @@ -198,7 +207,7 @@ rec {
builtins.map toLockFile subdirs
else [ ];
in
fromCrateDir ++ fromSources;
fromCrateDir ++ fromSources ++ additionalLockFiles;

locked =
let
Expand Down

0 comments on commit 806b05c

Please sign in to comment.