stack-project: support inputMap (mirror cabalProject) - #2553
Open
hamishmack wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
inputMapsupport tostackProjectcabalProjectsupports aninputMapargument that maps a dependency git url to an actual flake input / local path, butstackProjectonly supportedsha256map. As noted in the issue,inputMapis effectively the only way to make private git repositories (served over ssh/git) and fully offline builds work.This PR adds
inputMaptostackProject, mirroring the cabal side:inputMapoption inmodules/stack-project.nix(samenullOr attrstype /{}default / style as the cabal-project option).lib/stack-cache-generator.nixnow resolvesinputMapbefore thesha256map/fetchGitfallback, using the same key semantics aslib/call-cabal-project-to-nix.nix: a"<url>/<rev>"key uses the value directly, a bare"<url>"key checks the value's.revagainst the stack.yaml commit (and throws a helpful message on mismatch).overlays/haskell.nix(mkCacheModuleandmkCacheLine/mkCacheFile) use the mapped input directly instead of re-fetching.test/stack-inputMap, a stack project whose gitextra-depresolves viainputMapto the local test tree (no network fetch).Default behaviour unchanged
inputMapdefaults to{}. When it is omitted,inputMap ? <key>is always false, soinputisnulland 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.