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-lock [wip] #5

Closed
wants to merge 1 commit into from

Conversation

MatthewCroughan
Copy link

No description provided.

...
}:
let
cargoLock = builtins.fromTOML (builtins.readFile (builtins.elemAt inputPaths 0));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DavHau just thinking out loud here, but I'm thinking that it might make sense to have inputPaths be a dictionary with name keys ? (rather than a list). Relying on the position of an attribute could be error prone ?
Just a thought.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I'm currently thinking about removing the path list and instead only allow to pass one path.
One reason is that pure translators should be callable via nix expression, and there it is simple to specify just one source.
If the source needs extra files, then it can be patched inside the nix expression before handing it to the translator

@@ -13,7 +13,8 @@

def strip_hashes_from_lock(lock):
for source in lock['sources'].values():
del source['hash']
if 'hash' in source:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think dave just merged that bit

}:
let
cargoLock = builtins.fromTOML (builtins.readFile (builtins.elemAt inputPaths 0));
parsed = builtins.listToAttrs (map (p: lib.nameValuePair p.name p) cargoLock.package);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you are interested in some of the parsing that nixpkgs does on the cargolock, there was recently a PR about some improvements to it. You might be interested.
https://github.com/NixOS/nixpkgs/pull/137303/files

@DavHau
Copy link
Member

DavHau commented Sep 30, 2021

Taking a look at this repo here might be helpful as well: https://github.com/yusdacra/nix-cargo-integration
It might have some bits and pieces we could re-use.

@happysalada
Copy link
Contributor

in the helix project it's used. It's very well made!
it integrates nicely all the different nix methods to build rust packages.
It's using crate2nix and buildRustPackage under the hood though.

@yusdacra
Copy link
Member

yusdacra commented Oct 5, 2021

Hello, I just came across this and I must say I really like the idea! I would be glad to help with anything. Would love to utilize this in nix-cargo-integration, as I was planning to make crate2nix not use IFD, but this seems like a much better idea :)

@DavHau
Copy link
Member

DavHau commented Oct 6, 2021

@yusdacra We'd love to collaborate with you.
After working on this we discovered that there is already a parser in nixpkgs
Maybe we can re-use parts of it.
If you like we can sync up via a quick call.

@DavHau
Copy link
Member

DavHau commented Nov 18, 2021

@yusdacra Are you interested in working on this?
Maybe it is best to start this from scratch. There is now utils.simpleTranslate which should make it simpler to implement a translator.
The flake app contribute can be used to generate a template for a new translator with lots of comments inside on how to implement it.

In case this needs some more clarification, we can continue discussing in: #16

@yusdacra
Copy link
Member

@yusdacra Are you interested in working on this?
Maybe it is best to start this from scratch. There is now utils.simpleTranslate which should make it simpler to implement a translator.
The flake app contribute can be used to generate a template for a new translator with lots of comments inside on how to implement it.

In case this needs some more clarification, we can continue discussing in: #16

Yes, I would like to work on this. I have some time for this now so I can attempt building something. contribute looks nice, will try using it.

@yusdacra
Copy link
Member

yusdacra commented Dec 1, 2021

This can be closed now that there is a Cargo lock translator merged.

@MatthewCroughan
Copy link
Author

@yusdacra And a very very good one at that! Thank you.

DavHau added a commit that referenced this pull request Mar 12, 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

Successfully merging this pull request may close these issues.

None yet

4 participants