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": {
"flake": false,
"locked": {
"lastModified": 1661875961,
"narHash": "sha256-f1h/2c6Teeu1ofAHWzrS8TwBPcnN+EEu+z1sRVmMQTk=",
"lastModified": 1670284777,
"narHash": "sha256-JF0pc0s4z/X+Iy+lNHOwUQ8I5bz+q7uX4HrKTNIEj24=",
"owner": "ipetkov",
"repo": "crane",
"rev": "d9f394e4e20e97c2a60c3ad82c2b6ef99be19e24",
"rev": "2243fb9c872de25cb564a02d324ea6a5b9853052",
"type": "github"
},
"original": {

View File

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

View File

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

View File

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