-
-
Notifications
You must be signed in to change notification settings - Fork 123
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
callPackage, | ||
... | ||
}: | ||
rec { | ||
defaultFetcher = callPackage ./default-fetcher.nix {}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
externals, | ||
translatorName, | ||
utils, | ||
lib, | ||
runCommandNoCC, | ||
... | ||
}: | ||
|
||
let | ||
translate = | ||
{ | ||
inputPaths, | ||
... | ||
}: | ||
let | ||
cargoLock = builtins.fromTOML (builtins.readFile (builtins.elemAt inputPaths 0)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
parsed = builtins.listToAttrs (map (p: lib.nameValuePair p.name p) cargoLock.package); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
in | ||
{ | ||
sources = builtins.mapAttrs (pname: pdata: | ||
if pdata ? source && pdata ? checksum then | ||
{ | ||
url = "https://crates.io/api/v1/crates/${pdata.name}/${pdata.version}/download"; | ||
type = "fetchurl"; | ||
hash = pdata.checksum; | ||
} | ||
else | ||
{ | ||
path = ./.; | ||
type = "path"; | ||
} | ||
) parsed; | ||
|
||
generic = { | ||
buildSystem = "rust"; | ||
buildSystemFormatVersion = 1; | ||
producedBy = translatorName; | ||
dependencyGraph = null; | ||
sourcesCombinedHash = null; | ||
}; | ||
}; | ||
|
||
compatiblePaths = paths: utils.compatibleTopLevelPaths ".*(Cargo\\.lock)" paths; | ||
|
||
in | ||
|
||
{ | ||
inherit translate compatiblePaths; | ||
} |
There was a problem hiding this comment.
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