nix-community / crate2nix

rebuild only changed crates in CI with crate2nix and nix
https://nix-community.github.io/crate2nix/
Apache License 2.0
354 stars 83 forks source link

Renames outside of `[dependencies]` sections aren't tagged as such #223

Closed Fuuzetsu closed 2 years ago

Fuuzetsu commented 2 years ago

If you have something like

[package]
name = "repro"
version = "0.1.0"
edition = "2021"

[dependencies]

[dev-dependencies]
renamed_itoa = { version = "0.4.8", features = ["i128"], package = "itoa" }

crate2nix does not generate a renamed package, it instead generates something like

{
            name = "itoa";
            packageId = "itoa 0.4.8";
            features = [ "i128" ];
}

It does the right thing if the dependency is moved to [dependencies]

          {
            name = "itoa";
            packageId = "itoa 0.4.8";
            rename = "renamed_itoa";
            features = [ "i128" ];
          }

It seems like this is intended to work as I see this:

dependenciesWithRenames =
              lib.filter (d: d ? "rename")
                (
                  filterEnabledDependenciesForThis
                    (
                      (crateConfig.buildDependencies or [ ])
                      ++ (crateConfig.dependencies or [ ])
                      ++ devDependencies
                    )
                );

Maybe somewhere in crate2nix the rename code forgot to be plugged in for dev-dependencies and build-dependencies?

This is a problem if we have overlapping but renamed packages outside of dependencies.

Ericson2314 commented 2 years ago

That does indeed look like a bug!

Fuuzetsu commented 2 years ago

I'll try to take a look today.