Skip to content

stack-project: support inputMap (mirror cabalProject) - #2553

Open
hamishmack wants to merge 1 commit into
masterfrom
hkm/issue-1730-stack-inputmap
Open

stack-project: support inputMap (mirror cabalProject)#2553
hamishmack wants to merge 1 commit into
masterfrom
hkm/issue-1730-stack-inputmap

Conversation

@hamishmack

Copy link
Copy Markdown
Collaborator

Add inputMap support to stackProject

cabalProject supports an inputMap argument that maps a dependency git url to an actual flake input / local path, but stackProject only supported sha256map. As noted in the issue, inputMap is effectively the only way to make private git repositories (served over ssh/git) and fully offline builds work.

This PR adds inputMap to stackProject, mirroring the cabal side:

  • New inputMap option in modules/stack-project.nix (same nullOr attrs type / {} default / style as the cabal-project option).
  • lib/stack-cache-generator.nix now resolves inputMap before the sha256map/fetchGit fallback, using the same key semantics as lib/call-cabal-project-to-nix.nix: a "<url>/<rev>" key uses the value directly, a bare "<url>" key checks the value's .rev against the stack.yaml commit (and throws a helpful message on mismatch).
  • The resolved source is carried through the cache entry so both cache consumers in overlays/haskell.nix (mkCacheModule and mkCacheLine/mkCacheFile) use the mapped input directly instead of re-fetching.
  • Adds test/stack-inputMap, a stack project whose git extra-dep resolves via inputMap to the local test tree (no network fetch).

Default behaviour unchanged

inputMap defaults to {}. When it is omitted, inputMap ? <key> is always false, so input is null and every touched expression reduces to exactly the previous code (the extra cache field is only added when a mapping is present). Existing stack projects are byte-for-byte unaffected.

Closes #1730.

stackProject previously only supported sha256map, so private git
repositories (served over ssh/git) and fully offline builds could not
map a dependency url to a local path / flake input the way cabalProject
allows via inputMap.

Add an inputMap option to modules/stack-project.nix mirroring the
cabal-project one, thread it into lib/stack-cache-generator.nix, and
resolve it there exactly like the cabal side: a "<url>/<rev>" key uses
the value directly, a bare "<url>" key checks value.rev against the
stack.yaml commit. A resolved entry carries the mapped source through
the cache so both cache consumers (mkCacheModule and
mkCacheLine/mkCacheFile in overlays/haskell.nix) use it directly instead
of fetching.

When inputMap is omitted (default {}) every code path reduces to the
previous expression, so existing stack projects are unaffected.

Adds test/stack-inputMap exercising an extra-dep resolved via inputMap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add inputMap to stackProject

1 participant