feat(rust): update crane builder

This commit is contained in:
Yusuf Bera Ertan 2022-12-08 23:55:30 +03:00
parent 3681e0d5f5
commit 4b1ef01a87
No known key found for this signature in database
GPG Key ID: 1D8F8FAF2294D6EA
4 changed files with 20 additions and 23 deletions

View File

@ -42,11 +42,11 @@
"crane": { "crane": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1661875961, "lastModified": 1670284777,
"narHash": "sha256-f1h/2c6Teeu1ofAHWzrS8TwBPcnN+EEu+z1sRVmMQTk=", "narHash": "sha256-JF0pc0s4z/X+Iy+lNHOwUQ8I5bz+q7uX4HrKTNIEj24=",
"owner": "ipetkov", "owner": "ipetkov",
"repo": "crane", "repo": "crane",
"rev": "d9f394e4e20e97c2a60c3ad82c2b6ef99be19e24", "rev": "2243fb9c872de25cb564a02d324ea6a5b9853052",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -114,12 +114,12 @@
"lib/mkCargoDerivation.nix" "lib/mkCargoDerivation.nix"
"lib/mkDummySrc.nix" "lib/mkDummySrc.nix"
"lib/writeTOML.nix" "lib/writeTOML.nix"
"pkgs/cargoHelperFunctions.sh" "lib/setupHooks/cargoHelperFunctionsHook.sh"
"pkgs/configureCargoCommonVarsHook.sh" "lib/setupHooks/configureCargoCommonVarsHook.sh"
"pkgs/configureCargoVendoredDepsHook.sh" "lib/setupHooks/configureCargoVendoredDepsHook.sh"
"pkgs/installFromCargoBuildLogHook.sh" "lib/setupHooks/installFromCargoBuildLogHook.sh"
"pkgs/inheritCargoArtifactsHook.sh" "lib/setupHooks/inheritCargoArtifactsHook.sh"
"pkgs/installCargoArtifactsHook.sh" "lib/setupHooks/installCargoArtifactsHook.sh"
"LICENSE" "LICENSE"
]; ];
devshell = [ devshell = [

View File

@ -14,7 +14,7 @@ in {
makeHook = attrs: name: makeHook = attrs: name:
pkgs.makeSetupHook pkgs.makeSetupHook
({inherit name;} // attrs) ({inherit name;} // attrs)
"${externalSources.crane}/pkgs/${name}.sh"; "${externalSources.crane}/lib/setupHooks/${name}.sh";
genHooks = names: attrs: l.genAttrs names (makeHook attrs); genHooks = names: attrs: l.genAttrs names (makeHook attrs);
in in
{ {
@ -23,9 +23,10 @@ in {
}: rec { }: rec {
otherHooks = otherHooks =
genHooks [ genHooks [
"cargoHelperFunctions" "cargoHelperFunctionsHook"
"configureCargoCommonVarsHook" "configureCargoCommonVarsHook"
"configureCargoVendoredDepsHook" "configureCargoVendoredDepsHook"
"removeReferencesToVendoredSourcesHook"
] ]
{}; {};
installHooks = installHooks =
@ -63,7 +64,7 @@ in {
mkCargoDerivation = importLibFile "mkCargoDerivation" { mkCargoDerivation = importLibFile "mkCargoDerivation" {
cargo = cargoHostTarget; cargo = cargoHostTarget;
inherit (pkgs) stdenv lib; inherit (pkgs) stdenv zstd;
inherit inherit
(installHooks) (installHooks)
inheritCargoArtifactsHook inheritCargoArtifactsHook
@ -73,8 +74,9 @@ in {
(otherHooks) (otherHooks)
configureCargoCommonVarsHook configureCargoCommonVarsHook
configureCargoVendoredDepsHook configureCargoVendoredDepsHook
cargoHelperFunctionsHook
; ;
cargoHelperFunctionsHook = otherHooks.cargoHelperFunctions; inherit crateNameFromCargoToml vendorCargoDeps;
}; };
buildDepsOnly = importLibFile "buildDepsOnly" { buildDepsOnly = importLibFile "buildDepsOnly" {
inherit inherit
@ -84,18 +86,16 @@ in {
mkDummySrc mkDummySrc
; ;
}; };
cargoBuild = importLibFile "cargoBuild" { buildPackage = importLibFile "buildPackage" {
inherit (pkgs) lib jq;
inherit (installLogHook) installFromCargoBuildLogHook;
inherit inherit
mkCargoDerivation
buildDepsOnly buildDepsOnly
crateNameFromCargoToml crateNameFromCargoToml
vendorCargoDeps vendorCargoDeps
mkCargoDerivation
; ;
}; inherit (otherHooks) removeReferencesToVendoredSourcesHook;
buildPackage = importLibFile "buildPackage" {
inherit (pkgs) removeReferencesTo lib;
inherit (installLogHook) installFromCargoBuildLogHook;
inherit cargoBuild;
}; };
}; };
}; };

View File

@ -57,9 +57,6 @@
src = utils.getRootSource pname version; src = utils.getRootSource pname version;
cargoVendorDir = "./nix-vendor"; cargoVendorDir = "./nix-vendor";
# this is needed because remove-references-to doesn't work on non nix-store paths
doNotRemoveReferencesToVendorDir = true;
postUnpack = '' postUnpack = ''
export CARGO_HOME=$(pwd)/.cargo_home export CARGO_HOME=$(pwd)/.cargo_home
''; '';