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

Support unused dependencies #309

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ rec
} // (lib.optionalAttrs (! isNull branch) { inherit branch; })
// (lib.optionalAttrs (! isNull tag) { inherit tag; })
// (lib.optionalAttrs (! isNull rev) { inherit rev; });
packageLocks = builtins.map parseLock (lib.filter query cargolock.package);

usedPackageLocks =
builtins.map parseLock (lib.filter query cargolock.package);

unusedPackageLocks =
builtins.map parseLock (lib.filter query ((cargolock.patch or []).unused or []));

packageLocks = usedPackageLocks ++ unusedPackageLocks;

mkFetch = lock: {
key = lock.rev or lock.tag or lock.branch or lock.revision
Expand Down
1 change: 1 addition & 0 deletions test/fast/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ args: {
simple-dep = import ./simple-dep args;
simple-dep-patched = import ./simple-dep-patched args;
symlinks = import ./symlinks args;
unused-patch = import ./unused-patch args;
workspace = import ./workspace args;
workspace-build-rs = import ./workspace-build-rs args;
workspace-patched = import ./workspace-patched args;
Expand Down
15 changes: 15 additions & 0 deletions test/fast/unused-patch/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ naersk, pkgs, ... }:
let
app = naersk.buildPackage {
src = ./fixtures;
};

in
if builtins.compareVersions pkgs.lib.version "22.11" <= 0 then
# Executing this test requires nixpkgs > 22.11 due to changes to the TOML
# serialization function.
#
# See `writeTOML` in this repository for more details.
true
else
app
12 changes: 12 additions & 0 deletions test/fast/unused-patch/fixtures/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions test/fast/unused-patch/fixtures/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "app"
version = "0.1.0"
edition = "2018"

[patch.crates-io]
uuid = { git = "https://github.com/uuid-rs/uuid" }
3 changes: 3 additions & 0 deletions test/fast/unused-patch/fixtures/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
Loading