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

Cargo.nix includes references to ./crate2nix-sources with cargo workspaces #316

Open
flokli opened this issue Dec 14, 2023 · 1 comment
Open

Comments

@flokli
Copy link
Contributor

flokli commented Dec 14, 2023

This is a continuation of #291 - I finally ran into the issue I had, and it only shows up with some crates.

The crate2nix source add git https://… --rev $rev; crate2nix generate to package an external project mostly works. However, in some cases I can not just .gitignore crate2nix-sources.nix and the crate2nix-sources symlink, as Cargo.nix refers to sources from that symlink:

❯ crate2nix source add git https://github.com/n0-computer/iroh --rev 62ac4d8bb57329bc65cf126fabace882066ddb8a
Prefetching https://github.com/n0-computer/iroh#62ac4d8bb57329bc65cf126fabace882066ddb8a: done.
Added new source: https://github.com/n0-computer/iroh#62ac4d8bb57329bc65cf126fabace882066ddb8a via git: 0f2iyj6r3ymrgdy2vqv2dqixqaqprspyr042sqwibzha18phkxwk
❯ crate2nix generate
Fetching sources.
Generated ./crate2nix-sources.nix successfully.
Fetching sources via ./crate2nix-sources.nix fetchedSources: done.
warning: Could not find configured source for workspace member "/tmp/example/crate2nix-sources/iroh/iroh-base"
warning: Could not find configured source for workspace member "/tmp/example/crate2nix-sources/iroh/iroh-bytes"
warning: Could not find configured source for workspace member "/tmp/example/crate2nix-sources/iroh/iroh-gossip"
warning: Could not find configured source for workspace member "/tmp/example/crate2nix-sources/iroh/iroh-metrics"
warning: Could not find configured source for workspace member "/tmp/example/crate2nix-sources/iroh/iroh-net"
warning: Could not find configured source for workspace member "/tmp/example/crate2nix-sources/iroh/iroh-net/bench"
warning: Could not find configured source for workspace member "/tmp/example/crate2nix-sources/iroh/iroh-sync"
warning: Could not find configured source for workspace member "/tmp/example/crate2nix-sources/iroh/iroh-test"
Generated ./Cargo.nix successfully.
❯ ag crate2nix-sources Cargo.nix
6986:          then lib.cleanSourceWith { filter = sourceFilter;  src = ./crate2nix-sources/iroh/iroh-base; }
6987:          else ./crate2nix-sources/iroh/iroh-base;
7119:          then lib.cleanSourceWith { filter = sourceFilter;  src = ./crate2nix-sources/iroh/iroh-bytes; }
7120:          else ./crate2nix-sources/iroh/iroh-bytes;
7294:          then lib.cleanSourceWith { filter = sourceFilter;  src = ./crate2nix-sources/iroh/iroh-gossip; }
7295:          else ./crate2nix-sources/iroh/iroh-gossip;
7498:          then lib.cleanSourceWith { filter = sourceFilter;  src = ./crate2nix-sources/iroh/iroh-metrics; }
7499:          else ./crate2nix-sources/iroh/iroh-metrics;
7595:          then lib.cleanSourceWith { filter = sourceFilter;  src = ./crate2nix-sources/iroh/iroh-net; }
7596:          else ./crate2nix-sources/iroh/iroh-net;
8010:          then lib.cleanSourceWith { filter = sourceFilter;  src = ./crate2nix-sources/iroh/iroh-net/bench; }
8011:          else ./crate2nix-sources/iroh/iroh-net/bench;
8074:          then lib.cleanSourceWith { filter = sourceFilter;  src = ./crate2nix-sources/iroh/iroh-sync; }
8075:          else ./crate2nix-sources/iroh/iroh-sync;
8270:          then lib.cleanSourceWith { filter = sourceFilter;  src = ./crate2nix-sources/iroh/iroh-test; }
8271:          else ./crate2nix-sources/iroh/iroh-test;

This is with crate2nix master, 252ca6b.

@flokli
Copy link
Contributor Author

flokli commented Dec 14, 2023

This seems to be the sources for the workspace members of a workspace crate themselves.

https://github.com/ClementTsang/bottom is single-crate, and doesn't provoke this issue.

I assume we need to express the fetching for workspaces inside the Cargo.nix as well, similar to how it's done with non-workspaces:

      "bottom" = rec {
        crateName = "bottom";
        version = "0.9.6";
        edition = "2021";
        crateBin = [
          {
            name = "btm";
            path = "src/bin/main.rs";
            requiredFeatures = [ ];
          }
        ];
        workspace_member = null;
        src = pkgs.fetchgit {
          url = "https://github.com/ClementTsang/bottom";
          rev = "712a0036811d1ec1f676b2ba76fff4bf5cc5fa97";
          sha256 = "1p12lay9haj4210am2f6d9mj0f7srmg7sm8pljns92a7xnrsp7zn";
        };
        authors = [
          "Clement Tsang <[email protected]>"
        ];
        # ...
      }

@flokli flokli changed the title Cargo.nix sometimes includes references to ./crate2nix-sources Cargo.nix includes references to ./crate2nix-sources with cargo workspaces Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant