-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from yusdacra/rust/crane-builder
feat(rust): implement crane builder
- Loading branch information
Showing
14 changed files
with
382 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,61 @@ | ||
{ | ||
lib, | ||
pkgs, | ||
|
||
externals, | ||
... | ||
}: | ||
|
||
{ | ||
subsystemAttrs, | ||
defaultPackageName, | ||
defaultPackageVersion, | ||
getCyclicDependencies, | ||
getDependencies, | ||
getSource, | ||
getSourceSpec, | ||
packages, | ||
produceDerivation, | ||
|
||
... | ||
}@args: | ||
|
||
let | ||
l = lib // builtins; | ||
|
||
utils = import ../utils.nix args; | ||
vendoring = import ../vendor.nix (args // { inherit lib pkgs utils; }); | ||
|
||
crane = externals.crane; | ||
|
||
buildPackage = pname: version: | ||
let | ||
src = utils.getRootSource pname version; | ||
cargoVendorDir = vendoring.vendorDependencies pname version; | ||
preBuild = '' | ||
${vendoring.writeGitVendorEntries "nix-sources"} | ||
''; | ||
# The deps-only derivation will use this as a prefix to the `pname` | ||
depsNameSuffix = "-deps"; | ||
# Make sure cargo only builds the package we want | ||
cargoExtraArgs = "--package ${pname}"; | ||
|
||
deps = produceDerivation "${pname}${depsNameSuffix}" (crane.buildDepsOnly { | ||
inherit pname version src cargoVendorDir cargoExtraArgs preBuild; | ||
pnameSuffix = depsNameSuffix; | ||
}); | ||
in | ||
produceDerivation pname (crane.buildPackage { | ||
inherit pname version src cargoVendorDir cargoExtraArgs preBuild; | ||
cargoArtifacts = deps; | ||
}); | ||
in | ||
rec { | ||
packages = | ||
l.mapAttrs | ||
(name: version: | ||
{ "${version}" = buildPackage name version; }) | ||
args.packages; | ||
|
||
defaultPackage = packages."${defaultPackageName}"."${defaultPackageVersion}"; | ||
} |
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,12 @@ | ||
{ | ||
getSourceSpec, | ||
getSource, | ||
getRoot, | ||
|
||
... | ||
}: | ||
rec { | ||
getRootSource = pname: version: | ||
let root = getRoot pname version; in | ||
getSource root.pname root.version; | ||
} |
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
Oops, something went wrong.