version subcommand, and lib.version and lib.check in the flake #48

Closed
mikluko wants to merge 1 commit from flake-lib into main
Owner

Summary

A flake can take its version and its changelog checks from this flake.

 changelog
   append | fold | release
+  version          # newest entry's version, file only: no git, no checks
 flake.nix
   packages.changelog, overlays.default
+  lib.version pkgs ./CHANGELOG.md     # IFD through `changelog version`
+  lib.check pkgs { src; fragments; off; }   # every check needing no git history
+  checks.changelog, checks.version    # this repo, through both

A consumer states version = changelog.lib.version pkgs ./CHANGELOG.md; and so passes manifest-version by construction, with no --impure and no VERSION.

Evidence

  • go test ./... ok (with an empty global git config: a global .* ignore hides fragments from the test repositories), golangci-lint 0 issues, nix flake check passes.
  • lib.check fails on ### Nonsense (unknown-section); lib.version fails on a changelog naming no version: ... names no version.
  • In flakybin, wired from a local path: nix eval .#default.version gives 0.5.5, and 0.6.0 after changelog release folds its fragment.

Merge Danger

Door: two-way

Additions only: a subcommand and two lib attributes.

Blast Radius: none

Existing actions and flags are unchanged.

## Summary A flake can take its version and its changelog checks from this flake. ```diff changelog append | fold | release + version # newest entry's version, file only: no git, no checks flake.nix packages.changelog, overlays.default + lib.version pkgs ./CHANGELOG.md # IFD through `changelog version` + lib.check pkgs { src; fragments; off; } # every check needing no git history + checks.changelog, checks.version # this repo, through both ``` A consumer states `version = changelog.lib.version pkgs ./CHANGELOG.md;` and so passes `manifest-version` by construction, with no `--impure` and no `VERSION`. ## Evidence - `go test ./...` ok (with an empty global git config: a global `.*` ignore hides fragments from the test repositories), `golangci-lint` 0 issues, `nix flake check` passes. - `lib.check` fails on `### Nonsense` (`unknown-section`); `lib.version` fails on a changelog naming no version: `... names no version`. - In flakybin, wired from a local path: `nix eval .#default.version` gives `0.5.5`, and `0.6.0` after `changelog release` folds its fragment. ## Merge Danger **Door:** two-way Additions only: a subcommand and two `lib` attributes. **Blast Radius:** none Existing actions and flags are unchanged.
version subcommand, and lib.version and lib.check in the flake
All checks were successful
CI / lint (pull_request) Successful in 38s
CI / test (pull_request) Successful in 3m19s
1e8db3e9b8
A consumer flake reads its version from its changelog by import from
derivation through the command, rather than a regex over the Markdown or a
VERSION passed under --impure. lib.check runs only the checks that need no
git history, since a flake's source carries none.

Assisted-By: Claude <noreply@anthropic.com>
mikluko closed this pull request 2026-11-25 21:15:38 +00:00
All checks were successful
CI / lint (pull_request) Successful in 38s
CI / test (pull_request) Successful in 3m19s

Pull request closed

Sign in to join this conversation.
No description provided.