Skip to content

fix(pins): reconcile changed inputs, fail on unpinnable ones, keep URL attributes - #145

Merged
vic merged 2 commits into
mainfrom
fix/pin-engine
Oct 12, 2026
Merged

vic merged 2 commits into
mainfrom
fix/pin-engine

Conversation

@sini

@sini sini commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes three defects in the shared pin engine from #143 (modules/pins/queue.bash), which backs write-npins, write-lon and write-niv.

  • Changed inputs now re-pin. Before, the writer only added a pin when none existed, so changing foo.url left the old source in place. The writer now records each pin's declared URL in a sidecar file next to the lock (npins/flake-file-urls.tsv, nix/flake-file-urls.tsv, lon-flake-file-urls.tsv). When a pin's URL changes, the writer removes it and adds it again. When the URL is unchanged, the pin and its locked revision are left alone. A pin that exists but has no sidecar entry, such as one from a lock written before this change, is kept as it is and recorded.
  • Failed pins fail the run. add_url … || true is gone. The writer collects the names that failed, still writes every other pin, then lists the failed names on stderr and exits 1. The with_branch default/main/master fallback still works.
  • URL attributes are kept.
    • The query string of git+, github:, gitlab: and sourcehut: URLs is parsed. ref= sets the branch and rev= pins that revision (npins --at, lon -r, niv --rev). host= selects the server for gitlab and sourcehut.
    • Attrset inputs now carry rev, host, dir and similar attributes in that query string.
    • Attributes the writer cannot pin fail loudly and name the input: dir, narHash, submodules=1, lfs=1, and a github host other than github.com. Before this change they were silently dropped.

Validation

New bootstrap tests in dev/_bootstrap-tests.nix: test-{npins,lon,niv}-repin, test-npins-missing, test-{npins,lon,niv}-url-attrs and test-npins-unrepresentable. All 8 fail on main and pass on this branch. test-npins-repin also checks that an unchanged URL keeps a hand-edited revision, so the pin is not churned. nix-shell dev/bootstrap-tests.nix --run test-all passes, apart from the niv tests in that run, which hit GitHub's unauthenticated API rate limit. Rerun with GITHUB_TOKEN set, all niv tests pass. nix run ./dev#fmt -- --ci is clean.

@vic

vic commented Oct 12, 2026

Copy link
Copy Markdown
Member

Does the new lon-flake-file-urls.tsv file is created on the user repo ? If so, document about what it is being used for and if people should keep it in version control. Perhaps maybe having an option for not keeping it (does that make sense?).

sini added 2 commits October 12, 2026 13:21
…L attributes

- Record each pin's declared URL in a sidecar next to the lock
  (npins/flake-file-urls.tsv, nix/flake-file-urls.tsv, lon-flake-file-urls.tsv);
  a pin whose URL changed is removed and re-added, an unchanged one is left alone.
- Collect failed pins instead of `|| true`, keep writing the rest, then name the
  failures on stderr and exit 1.
- Parse the query string of git+/github:/gitlab:/sourcehut: URLs: ref= is the
  branch, rev= is pinned via each backend's revision flag, host= selects the
  gitlab server. Attrset inputs carry rev, host, dir, etc. into that query.
  dir=, narHash=, submodules=1, lfs=1 and a non-github.com github host fail
  loudly, naming the input.
@vic
vic merged commit 06362a1 into main Oct 12, 2026
12 checks passed
@vic
vic deleted the fix/pin-engine branch October 12, 2026 20:29
@vic

vic commented Oct 12, 2026

Copy link
Copy Markdown
Member

Thanks

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.

2 participants