Skip to content

feat: add lon and niv writers on a shared pin engine (#95) - #143

Merged
vic merged 1 commit into
mainfrom
feat/lon-niv-writers
Oct 12, 2026
Merged

vic merged 1 commit into
mainfrom
feat/lon-niv-writers

Conversation

@sini

@sini sini commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #95. Adds lon and niv writers, so flake-file now writes lock files for every with-inputs loader except nixtamal (see below).

  • flakeModules.lon exposes write-lon, which writes lon.nix and lon.lock.
  • flakeModules.niv exposes write-niv, which writes nix/sources.json and nix/sources.nix, created with niv init --no-nixpkgs.
  • Both are wired into write-lock (detected by lon.lock / nix/sources.json) and into the bootstrap app.

Shared engine instead of a copy. The npins writer's logic (URL scheme parsing, branch fallback, transitive discovery from GitHub flake.nix, the follows skip set from #141, and pruning unreached pins) moved to modules/pins/. It now has a queue.bash and a flake-file.pinWriter builder. A backend is a small script defining pin_init, pin_names, pin_exists, pin_remove, pin_github, pin_gitlab, pin_git, pin_channel and pin_tarball. npins, lon and niv are each about ten lines (modules/{npins,lon,niv}/*.bash). lon and niv have no channel or gitlab kinds, so they map channels and plain URLs to tarball sources and gitlab to git.

npins behaviour is unchanged, except that a bare git URL now gets the same main/master fallback as git+ URLs.

nixtamal is not included. It has no add command; its manifest is KDL edited by hand. A writer would need a manifest serializer like tack's pins.toml, so it would be a follow-up.

Validation

  • New bootstrap tests, all passing locally:
    • test-lon and test-niv (pin a declared input; niv adds no default nixpkgs)
    • test-lon-follows-other and test-niv-follows-other (the writer downloads nixpkgs-lib ignoring follows #140 shape: flake-parts' nixpkgs-lib follows nixpkgs and is not pinned)
    • test-write-lock-lon and test-write-lock-niv
  • Existing npins tests pass against the refactored engine: test-npins, -follows, -follows-other, -skip, -transitive, -schemes, test-write-lock-npins.
  • with-inputs reads the generated pins: from.lon and from.niv on the *-follows-other outputs both resolve inputs [ flake-parts nixpkgs ] with real sources.
  • nix run ./dev#fmt -- --ci is clean.
  • The rest of test-all was not run locally.

Move the npins writer's URL parsing, transitive discovery, follows skip
set and pruning into modules/pins (queue.bash + flake-file.pinWriter).
npins, lon and niv become small backends. Add flakeModules.lon and
flakeModules.niv (write-lon, write-niv), wire both into write-lock and
bootstrap, document them, and add bootstrap tests.
@vic

vic commented Oct 12, 2026

Copy link
Copy Markdown
Member

Amazing, @sini, thanks for updating also the docs.

@vic

vic commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Smart move on making the script re-usable across *pin libs.

@vic
vic merged commit 24d3716 into main Oct 12, 2026
12 checks passed
@vic
vic deleted the feat/lon-niv-writers branch October 12, 2026 19:29
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 Lon backend

2 participants