-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
142 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ lib | ||
}: | ||
|
||
toml: | ||
lib.filterAttrs (_: v: v != null) { | ||
# Now that cargo supports workspace inheritance we attempt to select a name | ||
# with the following priorities: | ||
# - choose `[package.name]` if the value is present and a string | ||
# (i.e. it isn't `[package.name] = { workspace = "true" }`) | ||
# - choose `[workspace.package.name]` if it is present (and a string for good measure) | ||
# - otherwise, fall back to a placeholder | ||
pname = | ||
let | ||
packageName = toml.package.name or null; | ||
workspacePackageName = toml.workspace.package.name or null; | ||
in | ||
if lib.isString packageName then packageName | ||
else if lib.isString workspacePackageName then workspacePackageName | ||
else null; | ||
|
||
# Now that cargo supports workspace inheritance we attempt to select a version | ||
# string with the following priorities: | ||
# - choose `[package.version]` if the value is present and a string | ||
# (i.e. it isn't `[package.version] = { workspace = "true" }`) | ||
# - choose `[workspace.package.version]` if it is present (and a string for good measure) | ||
# - otherwise, fall back to a placeholder | ||
version = | ||
let | ||
packageVersion = toml.package.version or null; | ||
workspacePackageVersion = toml.workspace.package.version or null; | ||
in | ||
if lib.isString packageVersion then packageVersion | ||
else if lib.isString workspacePackageVersion then workspacePackageVersion | ||
else null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ internalCrateNameFromCargoToml | ||
, lib | ||
}: | ||
|
||
input: | ||
let | ||
pathArgs = if lib.isAttrs input then input else { path = input; }; | ||
|
||
cargoTomlContents = | ||
let | ||
emptyToml = { }; | ||
cargoToml = pathArgs.path + "/Cargo.toml"; | ||
cargoTomlContents = builtins.readFile cargoToml; | ||
toml = builtins.tryEval (builtins.fromTOML cargoTomlContents); | ||
in | ||
if builtins.pathExists cargoToml | ||
then | ||
if toml.success then toml.value else emptyToml | ||
else | ||
emptyToml; | ||
|
||
name = (internalCrateNameFromCargoToml cargoTomlContents).pname or "source"; | ||
in | ||
builtins.path ({ inherit name; } // pathArgs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.