Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
71dd208
docs: plan the fix for lock failing on an untracked lock dir
myuron Oct 10, 2026
44e8a38
fix(lock): lock with a path: ref so an untracked lock dir works
myuron Oct 10, 2026
55400a3
docs(lock): explain path: locking and the git add note
myuron Oct 10, 2026
3d0f5fc
docs(lock): fix three inaccurate comments and doc lines
myuron Oct 10, 2026
44e0488
docs(lock): show the path: ref on the update flow's lock step
myuron Oct 10, 2026
0eb5441
docs(lock): show the path: ref in the readme's update command
myuron Oct 10, 2026
a52ecac
docs(lock): separate lock time from build time in the migrating steps
myuron Oct 10, 2026
18ceb51
docs: sync plan 71 with the readme and architecture edits
myuron Oct 10, 2026
e287abf
docs(lock): disambiguate two readme sentences about tracking
myuron Oct 10, 2026
6c4c6c8
docs(lock): say which lock files the build actually reads
myuron Oct 10, 2026
ed5f113
docs: keep plan 71's line numbers on the main baseline
myuron Oct 10, 2026
27ecf74
docs(lock): name errexit as what turns the && form into exit 1
myuron Oct 10, 2026
6175128
docs: fix nested code spans in plan 71
myuron Oct 10, 2026
97cf0bd
docs: fix the remaining nested code spans and the errexit note in pla…
myuron Oct 10, 2026
921df50
docs: escape a table pipe and spell out the submodule row in plan 71
myuron Oct 10, 2026
71118db
docs(lock): place the import report after nix's output in the readme
myuron Oct 10, 2026
b078698
docs: list every readme paragraph plan 71 ended up touching
myuron Oct 10, 2026
09fe426
fix(lock): stop the note and the failure line from overstating
myuron Oct 10, 2026
848ab83
docs(lock): say which exits reach the signal line
myuron Oct 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ nvimx is a home-manager module. You integrate it into your dotfiles to use it.
## Usage

1. Write your Lua config using the same definition method as lazy.nvim, then `git add` it.
Nix only sees git-tracked files, so an untracked Lua file is silently skipped during extraction.
`nvimx-lock` reads your working tree, so it locks an untracked Lua file just the same — but a
flake only sees git-tracked files, so home-manager would then deploy your config without it.

2. Lock the plugins.

Expand All @@ -94,6 +95,11 @@ nvimx is a home-manager module. You integrate it into your dotfiles to use it.
home-manager switch --flake .
```

Do not skip the `git add`. A flake only sees git-tracked files, so an untracked lock
directory is invisible to home-manager and the build degrades exactly as if you had never
locked. `nvimx-lock` prints a note when the lock it just wrote is not tracked yet. Locking
itself does not need the directory to be tracked.

The order is not actually rigid. Switching without a lock does not fail: the build *degrades* to a
lazy.nvim-only Neovim and warns you, while still installing the `nvimx-lock` command. Running
`nvimx-lock` → commit → switching again gets you to the full state either way.
Expand All @@ -107,9 +113,11 @@ Either form prints a summary of what moved, what was skipped because it is pinne
added or removed. `--update` with no names is the most expensive form: it re-resolves every
plugin's version constraint, so it is worth reserving for when you actually mean "update
everything" rather than running it out of habit. `--update <name>...` moves the named inputs with
`nix flake update <inputName>...` — the input name derived from the plugin's, not the name you
type — whose positional-argument form needs Nix ≥ 2.19; older Nix would need
`nix flake lock --update-input <name>` by hand instead.
`nix flake update --flake path:. <inputName>...` — the input name derived from the plugin's, not
the name you type — whose positional-argument form needs Nix ≥ 2.19; older Nix would need
`nix flake lock --update-input <name>` by hand instead — and inside a git repository that bare form
fails while the lock directory is untracked, so track it first or pass `path:.` as the flake
reference.

## Migrating from lazy.nvim

Expand All @@ -119,7 +127,9 @@ migration does not move a single plugin: you get the plugin set you are running
and you decide when to move forward.

1. Copy your existing config into the repo — `init.lua`, the `lua/` tree, **and `lazy-lock.json`** —
and `git add` all of it. Nix only sees git-tracked files.
and `git add` all of it. `nvimx-lock` and the import read your working tree either way, but a
flake only sees git-tracked files, so anything you leave untracked would be missing from the
config home-manager deploys.

2. Lock with the import. `lazy-lock.json` sits inside your config directory, so the path can be
omitted:
Expand All @@ -133,8 +143,8 @@ and you decide when to move forward.
fallback — a fallback would move every plugin to today's HEAD, which is what this flag exists
to prevent.

3. Read the import report before committing. It is printed at the very end of the run and accounts
for every entry in `lazy-lock.json`:
3. Read the import report before committing. It is printed at the end of the run, after
`nix flake lock`'s output, and accounts for every entry in `lazy-lock.json`:

- `import: pinned <name> to <sha>` — locked to exactly the commit lazy recorded
- `import: <name> is not in lazy-lock.json; it will resolve normally` — the only plugins that
Expand All @@ -156,6 +166,9 @@ and you decide when to move forward.
Each `resolvedRef` should be the commit `lazy-lock.json` has under the same name, and each
`locked.rev` in `nvim/nvimx-lock/flake.lock` should be that same commit again.

Until the lock directory is tracked, home-manager cannot see it and builds the degraded
Neovim; `nvimx-lock` reminds you if it is not.

5. From here on, run plain `nvimx-lock`. `--import-lazy-lock` is a one-shot migration: once
`plugins.json` exists, every decision in it wins over the imported file, so a second import is a
no-op that only prints `import: skipped N entries already decided by the existing lock`. When
Expand Down
19 changes: 11 additions & 8 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ sequenceDiagram
G-->>L: tags
Note over L: resolve.lua: resolve with lazy.manage.semver<br/>lock mode: keep existing pins, resolve new ones only
L->>L: genflake.lua: plugins.json → flake.nix + nixfmt
L->>F: cd lockDir && nix flake lock
L->>F: cd lockDir && nix flake lock path:.
F-->>L: flake.lock updated (fetch new inputs only)
L-->>U: plugins.json / flake.nix / flake.lock<br/>→ git add & commit
```
Expand Down Expand Up @@ -153,8 +153,10 @@ flowchart LR
[4] Generation: nvim -l genflake.lua
→ lockDir/flake.nix (inputs.<name> = { url = ...; flake = false; }, outputs = _: {})
→ formatted with nixfmt
[5] Place it in lockDir and run (cd lockDir && nix flake lock)
[5] Place it in lockDir and run (cd lockDir && nix flake lock "path:.")
→ generate/update flake.lock (in lock mode existing nodes stay untouched, only new ones are fetched)
`path:.` ignores git tracking: lockDir usually sits inside the user's git repository, where a bare
`nix flake lock` would resolve it as a git+file flake and not see the just-generated, untracked flake.nix (#71)
[6] Resolve once more against the fresh flake.lock, to freeze the pins that had no rev in [3].
Only if that changes plugins.json are [4] and [5] redone; the pass after it is a no-op.
```
Expand Down Expand Up @@ -284,8 +286,8 @@ github.com over ssh or the scp shorthand (`git@github.com:owner/repo.git`) is de
- Removing `pin` thaws the plugin: the frozen rev is dropped and it goes back to following its branch/tag. It has to be, because the frozen rev is part of the input URL, so `nix flake update` cannot undo a freeze on its own
- `pin` also beats a `version` constraint: the frozen rev is whatever the lock held, and it is never checked against the range. `nvimx-lock` warns about this on every run rather than freezing silently
- `nvimx-lock` runs the resolver twice, on either side of `nix flake lock`. A plugin pinned for the first time has no rev in `flake.lock` yet, so the second pass is what freezes it; the flake is regenerated and re-locked only if that pass changed anything. One retry always suffices, because the third pass would read the same `flake.lock` back
- `nvimx-lock --update [name...]` (#24): no names re-resolves every plugin that is not `pin = true` (pinned ones are skipped, and say so in the summary); one or more names re-resolves only those, pinned or not -- naming a plugin explicitly is what overrides `pin` and a `commit`-fixed spec is named harmlessly, since its URL cannot move either way. Either form discards the named plugins' `resolvedRef` (the same `force` mechanism #18 built in), then runs `nix flake lock` (which moves anything whose URL changed, e.g. a freshly-thawed pin) followed by `nix flake update <inputName...>` for exactly those plugins (which moves anything whose URL did not change, e.g. a branch/tag tracker). `lazy.nvim` is a valid name too: it moves the `lazy-nvim` input, and is included automatically by a no-names update -- except when the spec lists lazy.nvim itself with `pin = true` (#49), in which case a no-names update respects that pin exactly like it would for an ordinary plugin, and only naming `lazy.nvim` explicitly moves it. When the spec lists lazy.nvim itself (and it is not `dev`/`dir`), the `lazyNvim` entry itself is what gets re-resolved -- the same `force` mechanism, applied to the one entry that lives outside `plugins`. When the spec's lazy.nvim is `dev`/`dir` (a local checkout), `--update lazy.nvim` is still accepted and still moves the synthetic seed input, unlike an ordinary `dev`/`dir` plugin (which `--update <name>` refuses outright, since there is nothing to lock or update) -- the synthetic seed input still exists to move, independent of the local checkout. Needs Nix ≥ 2.19 for `nix flake update <input>`'s positional-argument form. A summary of what moved, what was skipped, and what was added/removed is printed at the end (`nvimx-lock: update summary`); in named mode it also warns if an unnamed input moved for no reason the summary can account for (a version constraint resolving for the first time, or an edited spec, do not count -- both are normal lock behavior). A no-names update is the most expensive thing nvimx does: every plugin's version constraint is re-resolved, which means one `git ls-remote` per constrained plugin, up to twice over because of the two resolver passes -- a constraint that resolves to `refs/tags/...` on the first pass carries that ref into the second pass unchanged and is not re-queried; only `defaults.version` fallback plugins (whose constraint matched no tag) are queried on both passes, which also happens on every plain lock, `--update` or not
- Back door: plain `nix flake update <inputName>` in lockDir also works (same as twist), but it cannot move a pinned plugin -- a frozen rev is part of the input URL, not just of `flake.lock`
- `nvimx-lock --update [name...]` (#24): no names re-resolves every plugin that is not `pin = true` (pinned ones are skipped, and say so in the summary); one or more names re-resolves only those, pinned or not -- naming a plugin explicitly is what overrides `pin` and a `commit`-fixed spec is named harmlessly, since its URL cannot move either way. Either form discards the named plugins' `resolvedRef` (the same `force` mechanism #18 built in), then runs `nix flake lock "path:."` (which moves anything whose URL changed, e.g. a freshly-thawed pin) followed by `nix flake update --flake path:. <inputName...>` for exactly those plugins (which moves anything whose URL did not change, e.g. a branch/tag tracker). `lazy.nvim` is a valid name too: it moves the `lazy-nvim` input, and is included automatically by a no-names update -- except when the spec lists lazy.nvim itself with `pin = true` (#49), in which case a no-names update respects that pin exactly like it would for an ordinary plugin, and only naming `lazy.nvim` explicitly moves it. When the spec lists lazy.nvim itself (and it is not `dev`/`dir`), the `lazyNvim` entry itself is what gets re-resolved -- the same `force` mechanism, applied to the one entry that lives outside `plugins`. When the spec's lazy.nvim is `dev`/`dir` (a local checkout), `--update lazy.nvim` is still accepted and still moves the synthetic seed input, unlike an ordinary `dev`/`dir` plugin (which `--update <name>` refuses outright, since there is nothing to lock or update) -- the synthetic seed input still exists to move, independent of the local checkout. Needs Nix ≥ 2.19 for `nix flake update <input>`'s positional-argument form. A summary of what moved, what was skipped, and what was added/removed is printed at the end (`nvimx-lock: update summary`); in named mode it also warns if an unnamed input moved for no reason the summary can account for (a version constraint resolving for the first time, or an edited spec, do not count -- both are normal lock behavior). A no-names update is the most expensive thing nvimx does: every plugin's version constraint is re-resolved, which means one `git ls-remote` per constrained plugin, up to twice over because of the two resolver passes -- a constraint that resolves to `refs/tags/...` on the first pass carries that ref into the second pass unchanged and is not re-queried; only `defaults.version` fallback plugins (whose constraint matched no tag) are queried on both passes, which also happens on every plain lock, `--update` or not
- Back door: plain `nix flake update <inputName>` in lockDir also works (same as twist) once lockDir is tracked by git -- an untracked lockDir makes the bare form fail (#71), so add `--flake path:.` there -- but it cannot move a pinned plugin -- a frozen rev is part of the input URL, not just of `flake.lock`
- `nvimx-lock --import-lazy-lock [path]` (#25): seeds each plugin's `resolvedRef` from the `commit` an existing lazy-lock.json records (defaulting to `<configDir>/lazy-lock.json`), so a migration from plain lazy.nvim pins exactly the plugin set the user is already running. Only plugins the previous lock has no decision about at all are seeded -- an existing `plugins.json` entry always wins, so a second import is a no-op. The seed goes into `resolvedRef`, never into `commit`/`branch`: those are part of the spec identity, so a seed written there would be discarded by the very next lock. A seeded `resolvedRef` also closes the semver gate, which is what makes a `defaults.version` migration need no network at all -- the constraint is not validated on that run, and the report says so. Cannot be combined with `--update`. Returns to normal tracking at `--update` time

### Plugin derivations (1 plugin = 1 derivation)
Expand Down Expand Up @@ -467,7 +469,7 @@ Since the lock command itself is a product of the hm build, failing evaluation w
(coming from an existing lazy setup, add `--import-lazy-lock`; the path defaults to
`<configDir>/lazy-lock.json`, so it only needs spelling out -- e.g.
`--import-lazy-lock ~/.config/nvim/lazy-lock.json` -- when the file lives somewhere else)
→ `git add` → `home-manager switch`. Switching first (degraded) and running `nvimx-lock` afterwards also works
→ `git add` (`nvimx-lock` says so when the lock it wrote is still untracked) → `home-manager switch`. Switching first (degraded) and running `nvimx-lock` afterwards also works
- **Adding a plugin**: write the spec in lua → `git add` → `nvimx-lock` (fetches only the new inputs) → commit → switch.
Even if you forget to lock and switch anyway, nvim still starts and only that plugin shows as not installed (safe failure)
- **Updating**: `nvimx-lock --update` (everything) / `nvimx-lock --update telescope.nvim` (individual) → switch.
Expand Down Expand Up @@ -514,7 +516,7 @@ flake outputs:
- `homeModules.nvimx`
- `apps.x86_64-linux.lock` (standalone, for bootstrapping and CI)
- `packages.x86_64-linux.demo` (for smoke testing and dogfooding with the fixtures)
- `checks.<system>.{extractor-snapshot, extractor-no-setup, extractor-defaults-version, extractor-local-dir, semver-select, source-parse, resolve-merge, resolve-semver, resolve-sources, resolve-golden, genflake-golden, resolve-lazy-self, resolve-update, update-summary, resolve-import-lazy-lock, resolve-build-warnings, build-shell, plugin-drv-phases, build-network-detect, build-registry, treesitter-grammars, dev-plugins, hm-module, hm-module-degrade, hm-module-plugins, hm-module-treesitter, hm-module-dev, hm-module-lua-packages, hm-module-default-editor, plugins-overrides, plugins-nixpkgs-fallback, plugins-escape-hatch, wrapper-aliases, extra-lua-packages}`
- `checks.<system>.{extractor-snapshot, extractor-no-setup, extractor-defaults-version, extractor-local-dir, semver-select, source-parse, resolve-merge, resolve-semver, resolve-sources, resolve-golden, genflake-golden, resolve-lazy-self, resolve-update, update-summary, resolve-import-lazy-lock, lock-app, resolve-build-warnings, build-shell, plugin-drv-phases, build-network-detect, build-registry, treesitter-grammars, dev-plugins, hm-module, hm-module-degrade, hm-module-plugins, hm-module-treesitter, hm-module-dev, hm-module-lua-packages, hm-module-default-editor, plugins-overrides, plugins-nixpkgs-fallback, plugins-escape-hatch, wrapper-aliases, extra-lua-packages}`
- planned, not yet implemented: `e2e-offline` (#30)
(e2e-offline is a network-free E2E using a fixture lock with path-type inputs)
- `templates.default`
Expand All @@ -525,7 +527,8 @@ flake outputs:
|---|---|
| First bootstrap (no lock) | degraded build + warning. `--impure` not needed |
| Adding a plugin to lua after locking, then switching | evaluation succeeds, only that plugin shows as not installed. A warning prompts you to re-run lock |
| lua files not tracked by git | they are not part of the flake source, so they are missed during extraction → the lock app detects working-tree differences and warns |
| lua files not tracked by git | `nvimx-lock` reads `--config` straight from the working tree, so they *are* extracted and locked. The build is where they go missing: `configDir` is a flake path, so the copy home-manager deploys (`manageConfig = true`) leaves them out. Nothing detects this today -- `git add` before switching |
| lockDir not tracked by git (every first lock) | locking works regardless: `nix flake lock "path:."` ignores git tracking (#71). The build cannot see an untracked `plugins.json` / `flake.lock`, so it degrades until they are added; `nvimx-lock` ends with a note naming the `git add` to run (`checks.lock-app`) |
| Non-GitHub / explicit git URL | validated at lock time (#28, `lua/nvimx/source.lua`): `https://` / `http://` / `ssh://` / `git://` with a host and path, or `file://` with an empty authority and an absolute path (`file:///...`), and the scp shorthand `user@host:path` (normalized to `ssh://user@host/path`), all lock to a `git+...` input; anything else -- a local path, an unknown scheme, a query string / fragment / `${`, a non-numeric port or grammar-invalid character in the authority, a `https://github.com/<owner>/<repo>/...` path with more than the two segments the github type can express -- fails the lock naming the plugin and the URL, before `plugins.json` is written. A github.com path with *fewer* than two segments (`https://github.com/<owner>`, no repo at all) does not match the github type in the first place and is instead accepted as a generic git URL, unchanged from before this validation existed |
| Plugin name collision | surfaces during lazy's Spec normalization (same behavior as lazy). Two plugins whose derived flake input names collide with each other fail the lock at lock time, naming both plugins (`checks.resolve-lazy-self`, #49); `lazy-nvim` is additionally a reserved input name (lazy.nvim itself always claims it), so any other plugin whose name normalizes to it also fails the lock the same way, naming that plugin. This is unrelated to a spec listing lazy.nvim itself, which is not a collision at all -- see the plugins.json schema section above |
| build is a Lua function / excmd / rockspec / a `*.lua` file, or `false` | cannot be run automatically (`false` is lazy's own "do not build" and warns about nothing). Warns at lock time and points to registry / overrides / nixpkgsFallback -- and, for a `rockspec`, to `extraLuaPackages` (see the luarocks row below) |
Expand All @@ -552,7 +555,7 @@ Each phase ends with an artifact you can actually try out:

## How to verify

- Phase 1-2: run `nvim --headless --cmd "luafile extract.lua"` against the fixture config → inspect the JSON → turn it into a snapshot check. After `nix run .#lock`, `cd lockDir && nix flake lock` must succeed
- Phase 1-2: run `nvim --headless --cmd "luafile extract.lua"` against the fixture config → inspect the JSON → turn it into a snapshot check. After `nix run .#lock`, `cd lockDir && nix flake lock "path:."` must succeed
- Phase 3 onward: `nix build .#demo && ./result/bin/nvim`, open `:Lazy` and confirm every plugin is loaded/local (no git operations) and that `:h telescope` works
- Phase 4: against real dotfiles, `nvimx-lock` → commit → `home-manager switch` → switching again with flake.lock unchanged must give the same result
- CI: `nix flake check` (offline checks) + confirming `nix fmt` has been applied.
Expand Down
Loading
Loading