Skip to content

Is in-expression generation possible? #188

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

Open
Fuuzetsu opened this issue Apr 28, 2021 · 4 comments
Open

Is in-expression generation possible? #188

Fuuzetsu opened this issue Apr 28, 2021 · 4 comments

Comments

@Fuuzetsu
Copy link
Contributor

Currently whenever Cargo.lock changes, developer has to notice and run crate2nix manually.

This is annoying but I can't think of simple way to automate this away that's consistent for developers across. The simplest (but not simple enough) way would be to start some file-watching thing in nix shell hook and run crate2nix when Cargo.lock changes.

For now we'll probably just check in CI that Cargo.nix is up to date but it sucks to have failed CI because there was a manual step one forgot to do.

If it was possible to say something like

cargoNix = crate2nix ./Cargo.lock;

That'd be cool. We let nix deal with re-running crate2nix when lock file changes.

Is this doable in a pure expression (nix flake)? I am guessing that no but I haven't checked through the source.

@Fuuzetsu
Copy link
Contributor Author

I tired this today. First, I tried runCommand but then realised I should be using tools.nix.

Sadly, even with populated crate-hashes.json, it seems that when crate2nix invokes cargo metadata, that tries to fetch a git dependency (one already specified in crate-hashes.json) and that obviously fails.

As per #102, I think this is supposed to just work?

@NickHu
Copy link

NickHu commented Mar 7, 2022

I believe this is fixed in this branch: https://github.com/yusdacra/crate2nix/tree/feat/builtinfetchgit

@yusdacra, would you be willing to upstream your changes?

@Ericson2314
Copy link
Collaborator

@Fuuzetsu how is this now for you? I added the ability in #257 to put in a plain path in the config file. I then create the config file in IFD, and it just works.

I don't think teaching crate2nix everything that, say, niv can do is a good separation of concerns long term, so this feels like a good low-level feature to avoid that.

@Fuuzetsu
Copy link
Contributor Author

@Ericson2314 Not sure what you're asking me to verify w.r.t. #257. As long as crate metadata is being invoked, IFD and similar approaches don't come into the picture, no?

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

3 participants