Skip to content

feat(nvf,nixvim): keep each Neovim in a profile that its parent activates - #104

Merged
clhodapp merged 3 commits into
feat/drift-everywherefrom
feat/editor-profiles
Oct 18, 2026
Merged

clhodapp merged 3 commits into
feat/drift-everywherefrom
feat/editor-profiles

Conversation

@clhodapp

@clhodapp clhodapp commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

An nvf or nixvim configuration declared inside a machine, a home or a hjem configuration now relates to that configuration the way a home relates to its machine. It has an activation of its own, which the configuration above runs each time it is activated itself.

Stacked on #103, whose drift check every profile runs.

The profile

lib.caisson.integrations.profileOf gives the configuration the outputs activationPackage and profile. activate checks for drift against the nearest configuration above with an activation. It then points a Nix profile at the Neovim with nix-env --profile, which also registers a garbage-collector root. When the profile already points at that Neovim, it adds no generation.

Declared inside Profile Activated by
a NixOS or system-manager machine /nix/var/nix/profiles/caisson/<kind>/<name> unit caisson-profile-<kind>-<name>, as root, wanted by multi-user.target
a darwin machine the same a postActivation step, as root
a home $HOME/.local/state/caisson/profiles/<kind>/<name> a home activation step after linkGeneration
a hjem configuration inside a machine the same the machine's unit caisson-profile-<user>-<kind>-<name>, as the user, after hjem-activate@<user>
nothing (a top) the same running activate by hand

Every activation of the configuration above puts the profile back to what that configuration declares. That covers home-manager switch, a switch of the machine, and a boot, since the machine activates its homes and profiles at boot.

Choosing a profile

Each class installs profileShimsOf: nvim, plus vi and vim where the Neovims have them. Each runs the profile named by $CAISSON_NVIM_PROFILE, read every time it runs, and the configuration's default when the variable is unset. A home or a hjem configuration sets the variable to its own profile, and a shell can export another value. Where several profiles share the variable, caisson.profiles.selected names the default, and evaluation fails until it does.

Other changes (pre-1.0)

Testing

  • nix flake check passes, including the unit tests, the pinned-world suite and the eval-weight gate.
  • Pinned-world tests check the units, users, shims and session variables for a NixOS machine, a home, a system-manager machine and a hjem configuration inside one. They also check that a top's profile points at the derivation neovimConfiguration builds.
  • Run for real with a throwaway $HOME:
    • the first activate creates the profile at the right Neovim;
    • a second activate adds no generation;
    • after a hand change with nix-env --set, the next activate puts the profile back, and the history keeps all three generations;
    • the nvim shim runs the profile the variable names, and the default when it is unset.
  • nix flake check --no-build passes in all 17 workspace consumers with this branch in place of both caisson pins: ch-home-manager and ch-personal-machines on fix/activation-drift (their maint: update flake pins #17 and refactor(nixpkgs): registries are read from caisson-core by the name of the mkLib argument #59), ch-system-manager on test/system-manager-configurations (refactor: nixos-minimal as its own integration over the nixos class #15), the others on main.

Not covered yet

  • There is no VM test of the boot-time unit or of the reset through a machine. caisson has no VM tests, and the drift VM test in ch-home-manager would need nvf as a new test dependency there.
  • A hjem configuration activated standalone with hjem standalone switch doesn't activate its profiles. Inside a machine, the machine does.

Docs: nix-caisson/nix-caisson.github.io, branch docs/editor-profiles.

🤖 Generated with Claude Code

@clhodapp clhodapp self-assigned this Oct 17, 2026
@clhodapp
clhodapp added this pull request to stack #106 October 17, 2026 20:04
@clhodapp
clhodapp force-pushed the feat/editor-profiles branch 2 times, most recently from 7bb876d to c94c06c Compare October 18, 2026 06:38
@clhodapp
clhodapp force-pushed the feat/editor-profiles branch from c94c06c to df0743a Compare October 18, 2026 07:54
@clhodapp
clhodapp force-pushed the feat/editor-profiles branch 2 times, most recently from 7706bbb to 901dc7b Compare October 18, 2026 08:27
@clhodapp
clhodapp force-pushed the feat/editor-profiles branch from 901dc7b to be7d562 Compare October 18, 2026 17:35
clhodapp and others added 3 commits October 18, 2026 11:04
…ates

An nvf or nixvim configuration declared inside a machine, a home or a
hjem configuration relates to that configuration as a home relates to
its machine: it has an activation of its own, which the configuration
above runs each time it is activated itself.

`lib.caisson.integrations.profileOf` gives such a configuration the
outputs `activationPackage` and `profile`. `activate` checks for drift
against the nearest configuration above with an activation, and points
a Nix profile at the Neovim with `nix-env --profile`, which also makes
the profile a garbage-collector root; it adds no generation when the
profile already points there. Inside a machine the profile is a profile
of the system, `/nix/var/nix/profiles/caisson/<kind>/<name>`; inside a
home or a hjem configuration, or at a top, it is a profile of the user,
`$HOME/.local/state/caisson/profiles/<kind>/<name>`. The home marker
moves under `$HOME/.local/state` as well, since a unit of the machine
and a shell may see `$XDG_STATE_HOME` differently.

Each class has a `profile-activation` module in its `default` module:

- nixos and systemManager: a unit per profile wanted by
  `multi-user.target`, run as root for a profile of the system, and as
  the user after `hjem-activate@<user>` for a profile inside a hjem
  configuration, whose own activation has no step to add;
- darwin: steps of `postActivation`, the same way;
- homeManager: an activation step after the files are linked and the
  marker is written, so `home-manager switch`, a switch of the machine
  and a boot all put the profile back;
- hjem: the programs and the variable below.

Each also installs `profileShimsOf`: `nvim` (and `vi`, `vim` where the
Neovim has them) runs the profile `$CAISSON_NVIM_PROFILE` names, read
each time it runs, and the default of the configuration when it is
unset. A home or a hjem configuration sets the variable to its own
profile, and a shell can `export` another. Where several profiles share
the variable, `caisson.profiles.selected` names the default.

nvf and nixvim get a `default` module declaring `caisson.drift.warn`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hjem is pronounced with a leading "y" sound, so it takes "a".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clhodapp
clhodapp force-pushed the feat/editor-profiles branch from be7d562 to 38faaa2 Compare October 18, 2026 18:04
@clhodapp
clhodapp merged commit 825a72c into main Oct 18, 2026
4 checks passed
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.

1 participant