Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ability to override lockfile from tools.nix #276

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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