diff --git a/modules/dream2nix/rust-crane/crane.nix b/modules/dream2nix/rust-crane/crane.nix deleted file mode 100644 index 5d7ab53ff3..0000000000 --- a/modules/dream2nix/rust-crane/crane.nix +++ /dev/null @@ -1,112 +0,0 @@ -{ - lib, - craneSource, - # nixpkgs - cargo, - makeSetupHook, - runCommand, - writeText, - stdenv, - zstd, - jq, - remarshal, - darwin, -}: let - importLibFile = name: import "${craneSource}/lib/${name}.nix"; - - makeHook = attrs: name: - makeSetupHook - ({inherit name;} // attrs) - "${craneSource}/lib/setupHooks/${name}.sh"; - genHooks = names: attrs: lib.genAttrs names (makeHook attrs); - - crane = rec { - dummyHook = makeSetupHook {name = "dummyHook";} (writeText "dummyHook.sh" ":"); - otherHooks = - genHooks [ - "cargoHelperFunctionsHook" - "configureCargoCommonVarsHook" - "configureCargoVendoredDepsHook" - ] - {}; - installHooks = - genHooks [ - "inheritCargoArtifactsHook" - "installCargoArtifactsHook" - ] - { - substitutions = { - zstd = "${zstd}/bin/zstd"; - }; - }; - installLogHook = genHooks ["installFromCargoBuildLogHook"] { - substitutions = { - cargo = "${cargo}/bin/cargo"; - jq = "${jq}/bin/jq"; - }; - }; - removeReferencesHook = import "${craneSource}/lib/setupHooks/removeReferencesToVendoredSources.nix" { - inherit lib makeSetupHook stdenv; - pkgsBuildBuild = {inherit darwin;}; - }; - - # These aren't used by dream2nix - crateNameFromCargoToml = null; - vendorCargoDeps = null; - - writeTOML = importLibFile "writeTOML" { - inherit runCommand; - pkgsBuildBuild = {inherit remarshal;}; - }; - cleanCargoToml = importLibFile "cleanCargoToml" {}; - findCargoFiles = importLibFile "findCargoFiles" { - inherit lib; - }; - mkDummySrc = importLibFile "mkDummySrc" { - inherit writeText runCommand lib; - inherit writeTOML cleanCargoToml findCargoFiles; - }; - - mkCargoDerivation = importLibFile "mkCargoDerivation" { - inherit stdenv zstd cargo lib writeText writeTOML; - # the code path that triggers rsync doesn't get used in dream2nix - rsync = zstd; - inherit - (installHooks) - inheritCargoArtifactsHook - installCargoArtifactsHook - ; - inherit - (otherHooks) - configureCargoCommonVarsHook - configureCargoVendoredDepsHook - cargoHelperFunctionsHook - ; - # this hook doesn't matter in our case because we want to do this ourselves in d2n - replaceCargoLockHook = dummyHook; - inherit crateNameFromCargoToml vendorCargoDeps; - }; - buildDepsOnly = importLibFile "buildDepsOnly" { - inherit lib; - inherit - mkCargoDerivation - crateNameFromCargoToml - vendorCargoDeps - mkDummySrc - ; - }; - buildPackage = importLibFile "buildPackage" { - inherit lib jq; - inherit (installLogHook) installFromCargoBuildLogHook; - inherit - buildDepsOnly - crateNameFromCargoToml - vendorCargoDeps - mkCargoDerivation - ; - removeReferencesToVendoredSourcesHook = removeReferencesHook; - }; - }; -in { - inherit (crane) buildPackage buildDepsOnly; -} diff --git a/modules/dream2nix/rust-crane/default.nix b/modules/dream2nix/rust-crane/default.nix index 049d068b66..08493907ab 100644 --- a/modules/dream2nix/rust-crane/default.nix +++ b/modules/dream2nix/rust-crane/default.nix @@ -77,21 +77,12 @@ ; }; - crane = import ./crane.nix { - inherit lib; - inherit - (config.deps) - stdenv - cargo - craneSource - jq - zstd - remarshal - makeSetupHook - writeText - runCommand - darwin - ; + crane = import config.deps.craneSource { + pkgs = config.deps.cranePkgs.appendOverlays [( + final: prev: { + cargo = config.deps.cargo; + } + )]; }; vendoring = import ./vendor.nix { @@ -191,14 +182,14 @@ in { rust-crane.depsDrv = { inherit version; name = pname + depsNameSuffix; - package-func.func = config.deps.crane.buildDepsOnly; + package-func.func = crane.buildDepsOnly; package-func.args = l.mkMerge [ common depsArgs ]; }; - package-func.func = config.deps.crane.buildPackage; + package-func.func = crane.buildPackage; package-func.args = l.mkMerge [common buildArgs]; public = { @@ -216,39 +207,30 @@ in { deps = {nixpkgs, ...}: l.mkMerge [ (l.mapAttrs (_: l.mkDefault) { - inherit crane; cargo = nixpkgs.cargo; craneSource = config.deps.fetchFromGitHub { owner = "ipetkov"; repo = "crane"; - rev = "v0.15.0"; - sha256 = "sha256-xpW3VFUG7yE6UE6Wl0dhqencuENSkV7qpnpe9I8VbPw="; + rev = "v0.19.0"; + sha256 = "sha256-/mumx8AQ5xFuCJqxCIOFCHTVlxHkMT21idpbgbm/TIE="; }; + cranePkgs = nixpkgs.pkgs; }) # maybe it would be better to put these under `options.rust-crane.deps` instead of this `deps` # since it conflicts with a lot of stuff? (l.mapAttrs (_: l.mkOverride 999) { inherit (nixpkgs) - stdenv fetchurl jq - zstd - remarshal moreutils python3Packages - makeSetupHook runCommandLocal - runCommand writeText fetchFromGitHub libiconv mkShell ; - inherit - (nixpkgs.pkgsBuildBuild) - darwin - ; inherit (nixpkgs.writers) writePython3