Skip to content

stack: accept the modern snapshot: key as well as resolver:#2532

Open
hamishmack wants to merge 1 commit into
masterfrom
hkm/stack-snapshot-key
Open

stack: accept the modern snapshot: key as well as resolver:#2532
hamishmack wants to merge 1 commit into
masterfrom
hkm/stack-snapshot-key

Conversation

@hamishmack

Copy link
Copy Markdown
Collaborator

Stack 2.15.1 renamed the top-level resolver: key in stack.yaml to snapshot: (both remain accepted, and stack new now emits snapshot:). haskell.nix only recognised resolver:, so a project with a snapshot:-only stack.yaml fails during project evaluation with:

stack-repos: AesonException "Error in $: key \"resolver\" not found"
CallStack (from HasCallStack):
  error, called at lib/StackRepos.hs:36:15 ...

(see #2506).

Changes

  • nix-tools/nix-tools/lib/Stack2nix/Stack.hs — accept snapshot as a synonym for resolver in both the FromJSON Stack and FromJSON StackSnapshot instances (s .: "resolver" <|> s .: "snapshot"). <|> is already imported and used by the Location instance.
  • lib/fetch-resolver.nix — match ^snapshot: as well as ^resolver: when locating a resolver that points to another file.

Verification

  • lib/fetch-resolver.nix: evaluated on a snapshot: lts-22.0 stack.yaml returns "lts-22.0"; a resolver: lts-21.0 one still returns "lts-21.0".
  • Built stack-repos from this source and ran it:
    • snapshot: lts-22.0 → succeeds (repos.json produced) — previously crashed with key "resolver" not found.
    • resolver: lts-21.0 → still succeeds (no regression).

Fixes #2506.

Stack >= 2.15.1 renamed the `resolver:` stack.yaml key to `snapshot:`
(both are accepted; `stack new` now emits `snapshot:`).  haskell.nix
only recognised `resolver:`, so a project with a `snapshot:`-only
stack.yaml failed with:

    stack-repos: AesonException "Error in $: key \"resolver\" not found"

- nix-tools Stack2nix/Stack.hs: accept `snapshot` as a synonym in both
  the `FromJSON Stack` and `FromJSON StackSnapshot` instances.
- lib/fetch-resolver.nix: match `snapshot:` as well as `resolver:` when
  locating a resolver that points to another file.

Fixes #2506.
@hamishmack hamishmack mentioned this pull request Jul 6, 2026
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.

error in flake.

1 participant