Update page: move the machine's sources and see which apps they carry #20

Merged
arne merged 5 commits from update-sources into main 2026-11-06 16:56:22 +01:00
Owner

The update page lists the machine's flake inputs and lets you move them from the drawer. Before this, it pointed at ./deploy and listed nix profile.

What's on the page

  • Sources: every root input of programs.fjordxy.settings.repo's flake.lock. Each row shows where the input comes from, whether its upstream has moved (git ls-remote against the locked ref; tarballs say "can't tell"), how old the lock is, and which declared apps it moves. The apps are matched by meta.position against each input's store paths, so on black, telegram, terminal and browser show under nixpkgs.
  • Enter on a source starts fjordxy-update@<input>. It re-locks just that input, commits flake.lock as lock: llm-agents 499fb79→baf9243, then runs fjordxy-rebuild. If the build fails, the lock commit is taken back off, and only if nothing has landed on top of it.
  • Update all and rebuild, and update fjordxy only (what ./deploy does).
  • Outside the flake: declared apps whose command isn't in the store (Rex, built by hand), and nix profile, which keeps its own upgrade-all.
  • Generation: the current one, and a switch back to the previous one. It needs Enter twice and goes through the existing fjordxy-activate@ unit.

How

  • fjordxy-sources status | update <input|all> | rollback in nix/package.nix.
  • The fjordxy-update@ user unit in nix/rebuild.nix. It gets the rebuild's environment, because the shell has the repo path but not the hostname.
  • The dirty-tree check moved into one snippet that fjordxy-rebuild and fjordxy-sources both use. An update with someone else's edit in the tree stops before re-locking anything, and the page names the file.
  • The update writes its progress to $XDG_RUNTIME_DIR/fjordxy-update.json, and Sources.qml watches that file instead of polling.
  • Declared apps carry position. The drawer IPC gains updates().
  • The design was previewed in the drawer prototype artifact first.

Tested

  • black's toplevel builds with --override-input fjordxy on this branch. The unit has the right environment, and the apps file carries positions.
  • fjordxy-sources status against black: correct sources and generations (about 4.5 s, mostly ls-remote).
  • On a scratch clone of black: the dirty-tree check refuses, a bad input name is refused, and re-lock → commit → failed rebuild → lock commit reset all happen in order.
  • Rendered in a nested session: the idle page, and the running state driven through the progress file.
  • Not yet tested: a real update and switch on black, and the rollback. Both switch the machine.

Known gap: dev/fjordxy-dev up fails on main with an infinite recursion in nix/dev-config.nix. That's unrelated to this PR, and I worked around it for testing.

🤖 Generated with Claude Code

The update page lists the machine's flake inputs and lets you move them from the drawer. Before this, it pointed at `./deploy` and listed `nix profile`. **What's on the page** - **Sources:** every root input of `programs.fjordxy.settings.repo`'s `flake.lock`. Each row shows where the input comes from, whether its upstream has moved (`git ls-remote` against the locked ref; tarballs say "can't tell"), how old the lock is, and which declared apps it moves. The apps are matched by `meta.position` against each input's store paths, so on black, telegram, terminal and browser show under nixpkgs. - **Enter on a source** starts `fjordxy-update@<input>`. It re-locks just that input, commits `flake.lock` as `lock: llm-agents 499fb79→baf9243`, then runs `fjordxy-rebuild`. If the build fails, the lock commit is taken back off, and only if nothing has landed on top of it. - **Update all and rebuild**, and **update fjordxy only** (what `./deploy` does). - **Outside the flake:** declared apps whose command isn't in the store (Rex, built by hand), and `nix profile`, which keeps its own upgrade-all. - **Generation:** the current one, and a switch back to the previous one. It needs Enter twice and goes through the existing `fjordxy-activate@` unit. **How** - `fjordxy-sources status | update <input|all> | rollback` in `nix/package.nix`. - The `fjordxy-update@` user unit in `nix/rebuild.nix`. It gets the rebuild's environment, because the shell has the repo path but not the hostname. - The dirty-tree check moved into one snippet that `fjordxy-rebuild` and `fjordxy-sources` both use. An update with someone else's edit in the tree stops before re-locking anything, and the page names the file. - The update writes its progress to `$XDG_RUNTIME_DIR/fjordxy-update.json`, and `Sources.qml` watches that file instead of polling. - Declared apps carry `position`. The drawer IPC gains `updates()`. - The design was previewed in the drawer prototype artifact first. **Tested** - black's toplevel builds with `--override-input fjordxy` on this branch. The unit has the right environment, and the apps file carries positions. - `fjordxy-sources status` against black: correct sources and generations (about 4.5 s, mostly ls-remote). - On a scratch clone of black: the dirty-tree check refuses, a bad input name is refused, and re-lock → commit → failed rebuild → lock commit reset all happen in order. - Rendered in a nested session: the idle page, and the running state driven through the progress file. - **Not yet tested:** a real update and switch on black, and the rollback. Both switch the machine. **Known gap:** `dev/fjordxy-dev up` fails on `main` with an infinite recursion in `nix/dev-config.nix`. That's unrelated to this PR, and I worked around it for testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The update page now lists the flake inputs of the machine's own repository
(programs.fjordxy.settings.repo): where each comes from, whether its upstream
has moved (git ls-remote against the locked ref), how old its lock is, and
which declared apps it moves (matched by the package's meta.position against
each input's store paths). Enter on a source starts fjordxy-update@<input>,
which re-locks just that input, commits flake.lock as "lock: <input> a→b",
and runs fjordxy-rebuild; a failed build takes the lock commit back off.
"update all" and "update fjordxy only" sit under the list, apps no source can
move are listed as built by hand, and the previous generation is one confirmed
Enter away through the existing fjordxy-activate@ unit.

- fjordxy-sources (status | update | rollback), the backend
- fjordxy-update@ user unit, carrying the rebuild's environment
- the dirty-tree guard shared between fjordxy-rebuild and fjordxy-sources
- declared apps carry their package's position
- drawer IPC gains updates()

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Declared apps alone left most sources empty — Claude Code, pi and codex come
from llm-agents through environment.systemPackages, rexy-desk from rexy. The
home-manager module now writes FJORDXY_PACKAGES: every system and user
package with the file it was defined in. `fjordxy-sources status` places each
one (and each declared app) under the input whose store paths hold that file,
or under the repository itself when the same file exists there — matched by
path, since the repository's store copy moves with every commit while the
running generation stays put.

A source's second line is now what it moves: declared apps by name, then the
other packages, counted once there are more than six. The lock age moves up to
the first line, and a GitHub input that follows a branch shows just the branch.
Packages the repository builds itself get a row under "outside the flake".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Added: every installed package now shows under its source, not only declared apps. On black, llm-agents lists claude-code · pi · codex, rexy lists rexy-desk · ghostty, nixpkgs shows browser · telegram · terminal · +143 packages, and fleet · forge show as built in this repo. Packages are placed by fjordxy-sources status from the new FJORDXY_PACKAGES file the home-manager module writes. Packages the repo builds itself are matched by path, so they stay placed after later commits. Black's toplevel builds with it, and I checked it rendered in a nested session.

🤖 Generated with Claude Code

Added: every installed package now shows under its source, not only declared apps. On black, llm-agents lists claude-code · pi · codex, rexy lists rexy-desk · ghostty, nixpkgs shows browser · telegram · terminal · +143 packages, and fleet · forge show as built in this repo. Packages are placed by `fjordxy-sources status` from the new `FJORDXY_PACKAGES` file the home-manager module writes. Packages the repo builds itself are matched by path, so they stay placed after later commits. Black's toplevel builds with it, and I checked it rendered in a nested session. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
arne force-pushed update-sources from 884b7bbdd8 to 5b86ec222f 2026-11-06 15:40:26 +01:00 Compare
A source whose remote did not answer used to end as "could not re-lock all
sources". The page and the notification now carry the reason — for the
common case, "api.github.com answered HTTP 504; try again later" — and nix's
own output still goes to the journal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- fjordxy-sources: a re-lock failure with no HTTP error in nix's output
  no longer trips pipefail/errexit before it can record the failure.
- An EXIT trap (with TERM/INT/HUP trapped so it runs on a stop) turns a
  still-running phase into `failed` and puts back an uncommitted
  flake.lock, so nothing leaves the page busy until logout. `update`
  also refuses a repo that isn't a git checkout up front.
- A failed rebuild keeps the lock commit when the switch failed after
  the profile was set (the machine already runs that lock), and only
  says "flake.lock put back" if `git reset --keep` actually did it.
- `update` records its lock commit and the generations around it; a
  rollback across exactly that update commits flake.lock back to the
  commit's parent, so the next background rebuild doesn't undo it.
- Rollback runs as the fjordxy-rollback user unit instead of a child of
  the shell, which the switch restarts.
- `follows` inputs are resolved by walking the path from the root, not
  by taking its first element.
- ls-remote fields are split on 0x1f; tab is IFS whitespace and merged
  the empty url of tarball/path inputs into the next field.
- FJORDXY_SETTINGS_BASENAME is in the session environment, so `status`
  guards the same settings file `update` does.
- Apps with a package aren't listed as "built by hand".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"Switch back" went through fjordxy-activate@, whose `nix-env --set`
always makes a new generation. Going back from a broken 37 made 38, a
copy of 36, and "the one before this" was then 37 again: a second
press went forward to the broken system, and nothing older than the
last two could be reached.

- New root template fjordxy-generation@<n> (fjordxy-switch-generation):
  `nix-env --switch-generation n`, then that generation's
  switch-to-configuration. The instance must be a generation number
  with an existing system-<n>-link into the store that has
  switch-to-configuration. The polkit rule allows it for digits only.
  It can reach strictly less than fjordxy-activate@ already can.
- fjordxy-rebuild and fjordxy-sources record every switch fjordxy makes
  as {from, to, commit} in $XDG_STATE_HOME/fjordxy/generations.json.
  "Previous" is the `from` of the entry that made the current
  generation, and falls back to the highest number below it. Back on
  36 after a broken 37, the next rebuild's 38 then offers 36, not 37.
- The rollback walks that history one step per press. Each step over
  an update commits flake.lock back to the lock commit's parent. If the
  switch fails after the profile moved, the lock still follows it.
- fjordxy-rebuild's notification no longer says "the generation is
  unchanged" when the profile was set and only the switch failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
arne merged commit ef3af645cd into main 2026-11-06 16:56:22 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bases/fjord!20
No description provided.