diff --git a/examples/dream2nix-packages-rust/ripgrep/default.nix b/examples/dream2nix-packages-rust/ripgrep/default.nix index e7f37f5f..0209003a 100644 --- a/examples/dream2nix-packages-rust/ripgrep/default.nix +++ b/examples/dream2nix-packages-rust/ripgrep/default.nix @@ -27,7 +27,7 @@ in { sha256 = "sha256-udEh+Re2PeO3DnX4fQThsaT1Y3MBHFfrX5Q5EN2XrF0="; }; # note: any more options defined here will be applied to both - # `rust-crane.mainDrvOptions` and `rust-crane.depsDrvOptions`. + # `config.mkDerivation` and `config.depsDrv.mkDerivation`. }; rust-crane = { diff --git a/modules/drv-parts/rust-crane/default.nix b/modules/drv-parts/rust-crane/default.nix index f2835198..d8804e26 100644 --- a/modules/drv-parts/rust-crane/default.nix +++ b/modules/drv-parts/rust-crane/default.nix @@ -165,6 +165,7 @@ # we pass cargoLock path to buildDepsOnly # so that crane's mkDummySrc adds it to the dummy source inherit (utils) cargoLock; + pname = l.mkOverride 99 pname; pnameSuffix = depsNameSuffix; # Make sure cargo only checks the package we want cargoCheckCommand = "cargo check \${cargoBuildFlags:-} --profile \${cargoBuildProfile} --package ${pname}"; @@ -183,26 +184,30 @@ ${common.preConfigure} ${utils.writeCargoLock} ''; - cargoArtifacts = packageDeps; + cargoArtifacts = cfg.depsDrv.public; }; - - packageDeps = crane.buildDepsOnly cfg.depsDrvOptions; in { imports = [ ./interface.nix dream2nix.modules.drv-parts.mkDerivation ]; - rust-crane.depsDrvOptions = l.mkMerge [ - common - depsArgs - ]; + rust-crane.depsDrv = { + inherit version; + name = pname + depsNameSuffix; + mkDerivation = builtins.removeAttrs config.mkDerivation ["src"]; + package-func.func = crane.buildDepsOnly; + package-func.args = l.mkMerge [ + common + depsArgs + ]; + }; package-func.func = crane.buildPackage; package-func.args = l.mkMerge [common buildArgs]; public = { - dependencies = packageDeps; + dependencies = cfg.depsDrv.public; meta = utils.getMeta pname version; }; diff --git a/modules/drv-parts/rust-crane/interface.nix b/modules/drv-parts/rust-crane/interface.nix index 4fd12823..a2ded8e8 100644 --- a/modules/drv-parts/rust-crane/interface.nix +++ b/modules/drv-parts/rust-crane/interface.nix @@ -1,6 +1,7 @@ { - config, lib, + dream2nix, + specialArgs, ... }: let l = lib // builtins; @@ -53,12 +54,12 @@ in { description = "Flags to add when running `cargo test`"; default = []; }; - # TODO: use mkDerivation module interface here - depsDrvOptions = { - type = t.submodule { - freeformType = t.attrsOf t.raw; + depsDrv = { + type = t.submoduleWith { + modules = [dream2nix.modules.drv-parts.mkDerivation]; + inherit specialArgs; }; - description = "Attributes to pass to the buildDepsOnly function"; + description = "A single derivation with all dependencies of the package"; default = {}; }; };