Repository navigation
feat(darwin): activate the homes and hjem configurations inside a machine - #95
Merged
Merged
Conversation
…hine A home or hjem configuration now takes as its machine the nearest NixOS or darwin configuration above it, found with the new `caisson.integrations.nearestOf`. A home inside a darwin machine gets `osClass = "darwin"` and `darwinConfig`, and is published as `<user>@<machine>`. caisson's new `default` darwin module gives each home the home-manager module `darwin-parent` and each hjem configuration the hjem module `darwin-parent`, which set the options that come from the machine's account. It imports `home-manager-activation`, which activates the homes in `postActivation` as home-manager's nix-darwin module does, and `hjem-activation`, which writes the launchd agents of hjem's nix-darwin module. The agents are in `/Library/LaunchAgents`, so they run for every user and need no `system.primaryUser`, and they are restarted from `postActivation`, after nix-darwin installs them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 17, 2026
The applications agent of `hjem-activation` started with the case that sets the CLI of the user, which that agent does not run, and shellcheck refused the unused variable when the system was built on macOS. It now starts with a case that only exits for a user no hjem configuration here names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A macOS machine now activates the homes and hjem configurations declared inside it, as a NixOS machine does. This PR is based on #94 (hjem). Its diff is the darwin commit alone. Merge #94 first, then change the base of this PR to
main. The repository does not delete merged branches, so GitHub does not change the base by itself.The machine of a home
A home or hjem configuration used to read its machine as
nearest.nixos. The newcaisson.integrations.nearestOf [ "nixos" "darwin" ]returns the nearer of the nearest NixOS configuration and the nearest darwin configuration. The nearer one is the one with more ancestors. A home inside a darwin machine getsosConfig,osClass = "darwin"anddarwinConfig, as home-manager's nix-darwin module gives them, and it is published as<user>@<machine>. Only a NixOS machine gives an hjem configuration hjem'ssystemd.nix, because hjem's nix-darwin module does not import it. Both kinds of machine giveosOptions.caisson's default darwin module
A darwin configuration had no
defaultmodule. The new one does three things:caisson.forChildren, it gives each home the home-manager moduledarwin-parentand each hjem configuration the hjem moduledarwin-parent. They set what home-manager's and hjem's nix-darwin modules set from the machine's account: the home directory, the user ID read withtryEvalas home-manager reads it, and the Nix of the machine.home-manager-activation. That module adds thepostActivationstep of home-manager's nix-darwin module, which runs each home'sactivateas its user throughlaunchctl asuserandsudo. As in caisson's NixOS activation,activateruns without a driver version, so the user's home-manager profile keeps working withhome-manager switch.hjem-activation. That module writes the two launchd agents of hjem's nix-darwin module,org.hjem.activateandorg.nix.link-nix-apps, with upstream's scripts. It also adds the users' packages and records theirextraDependenciesin/etc/hjem/extra-dependencies.The hjem module differs from upstream in two places.
launchd.user.agentsinto the home ofsystem.primaryUseralone, so upstream's agent runs for the primary user only. Upstream also requiressystem.primaryUserto be set. caisson declares the agents inlaunchd.agents, which nix-darwin installs in/Library/LaunchAgents. launchd loads agents from there for every user at login. Each agent exits for a user that no hjem configuration of the machine names.modules/system/activation-scripts.nix). Upstream restarts the activation agent from a step namedhjem-activate-kick, which is not on that list, so the restart never runs. It restarts the applications agent fromapplications, which runs before thelaunchdstep installs the new agents. caisson restarts both agents frompostActivation, which runs after the agents are installed.Tests
family, with a home and an hjem configuration for its user. The bare machine still builds exactly the derivationdarwinSystembuilds.family:postActivationruns the home's activation wrapper throughlaunchctl asuserand restartsorg.hjem.activate.launchd.agents, andlaunchd.user.agentsis empty.probe@familyandprobe.checks.aarch64-darwin.darwin-systemnow builds both systems, so the macOS job builds the home's activation package and hjem's CLI.nearestOf.Activation on a running Mac is not tested.
Caisson's evaluation overhead in the eval-weight check is 4.18 MB, against 4.15 MB on #94, and the ceiling is 4.28 MB. All 18 workspace consumers pass
nix flake check --no-buildat #96, which contains this branch. That run puts the branch in place of both caisson pins of each consumer: the root input, and thetests/dependencieslock that the checks partition reads. An earlier run on this branch alone overrode only the root input, so those partitions then ran against the caisson they pin.🤖 Generated with Claude Code