diff options
| author | tv <tv@krebsco.de> | 2026-11-30 20:20:23 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-01 00:22:40 +0000 |
| commit | cc460231e532398037514d138a0ff5a740a47140 (patch) | |
| tree | bb8806dd50c9db6bc94fff09d1b04fa75314fc63 | |
| parent | 386d8ffbbdda40f692efe7d507a7973c3a3d9036 (diff) | |
crate2nix-package: find git dependencies in their repositories
build-from-json builds a git dependency from the root of its repository,
so enstate's config, which lives in continuum's repository, got
continuum's own sources.
| -rw-r--r-- | pkgs/rust/lib/crate2nix-package.nix | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/pkgs/rust/lib/crate2nix-package.nix b/pkgs/rust/lib/crate2nix-package.nix index 2c48be2e..892d40e8 100644 --- a/pkgs/rust/lib/crate2nix-package.nix +++ b/pkgs/rust/lib/crate2nix-package.nix @@ -53,12 +53,24 @@ let workspaceMembers = builtins.attrNames cargoNix.workspaceMembers; + # build-from-json builds a git dependency from its repository's root, so a + # crate in a subdirectory there, like continuum's config, got the root's + # sources. Without a workspace_member, buildRustCrate looks for the + # crate's Cargo.toml instead. + gitCrates = lib.optionals useJson (lib.mapAttrsToList + (_: c: "${c.crateName} ${c.version}") + (lib.filterAttrs (_: c: (c.source.type or null) == "git") plan.crates)); + buildRustCrateForPkgs = pkgs: args: let + withGit = + if builtins.elem "${args.crateName} ${args.version}" gitCrates + then { workspace_member = null; } // args + else args; withWorkspace = if builtins.elem args.crateName workspaceMembers - then applyOverride workspaceOverride args - else args; + then applyOverride workspaceOverride withGit + else withGit; in pkgs.buildRustCrate (applyOverride (crateOverrides.${args.crateName} or {}) withWorkspace); |
