From b3edd2cef626a98233fec0807d79f3093841e80d Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sun, 8 Nov 2026 18:11:44 -0500 Subject: [PATCH] docs(nix): explain Home Manager setup and migration --- README.md | 4 +++ docs/daemon-lifecycle.md | 3 +- docs/home-manager.md | 78 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 docs/home-manager.md diff --git a/README.md b/README.md index 2ef9da163..392ad6244 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,10 @@ nix build .#albedo-server --out-link result-server ALBEDO_DAEMON="$PWD/result-server/bin/albedo-daemon" ./result-client/bin/albedo ``` +To install the client and declare a login user service with Home Manager, import +`albedo.homeModules.default`. See [Manage albedo with Home Manager](docs/home-manager.md) +for the four options and migration steps. + optional: `view`, which lets the model see its changes and code as highlighted images for a final review pass. needs cargo. diff --git a/docs/daemon-lifecycle.md b/docs/daemon-lifecycle.md index 4d308bea1..5fda31d14 100644 --- a/docs/daemon-lifecycle.md +++ b/docs/daemon-lifecycle.md @@ -58,7 +58,8 @@ Albedo validates its source, loaded configuration, and file identity before control. A supported loaded idle declaration can start through its manager; an authenticated matching daemon can stop through HTTP. Albedo never installs, rewrites, reloads, enables, disables, bootstraps, or uninstalls an external -declaration. Reconcile or remove it through its owner. +declaration. Reconcile or remove it through its owner. See +[Manage albedo with Home Manager](home-manager.md) for configuration and migration. Declaration checks retain symlink-chain and target identity across waits. They detect observed replacement but cannot lock another same-user writer or diff --git a/docs/home-manager.md b/docs/home-manager.md new file mode 100644 index 000000000..14f427d77 --- /dev/null +++ b/docs/home-manager.md @@ -0,0 +1,78 @@ +# Manage albedo with Home Manager + +Add albedo to your flake inputs, then import its Home Manager module: + +```nix +{ + imports = [ inputs.albedo.homeModules.default ]; + programs.albedo.enable = true; + services.albedo.enable = true; +} +``` + +`programs.albedo.enable` adds the client package to your profile. +`services.albedo.enable` declares `albedo.service` on Linux or the +`systems.albedo.daemon` login agent on macOS. +The enables are independent. A service alone does not add the client to PATH. + +`programs.albedo.package` defaults to this flake's joined `albedo` package. +`services.albedo.package` defaults to `programs.albedo.package`. To choose a +separate daemon package, set `services.albedo.package`. That package must provide +`bin/albedo daemon --serve`, including its daemon runtime. No package metadata +is required. Ambient `ALBEDO_DAEMON` overrides can still affect packaged startup. + +The service uses `${home.homeDirectory}/.albedo`. Set `home.homeDirectory` to +exactly the value of `$HOME`, without a trailing slash. Equivalent symlinked +paths still fail the daemon-home identity check. On Linux, the CLI's +`XDG_CONFIG_HOME` must match Home Manager's `xdg.configHome`. If unset, the CLI +uses `$HOME/.config`. Setting +`ALBEDO_HOME` for the CLI selects a different daemon home and service name. It +does not change this module's `${home.homeDirectory}/.albedo` declaration. +The module creates a missing daemon directory with mode 0700, preserves an +existing directory, and keeps data when you disable the service. + +## Tools available to the daemon + +The service PATH includes `home.profileDirectory` and `nix.package` when set. +Install the tools the agent needs through `home.packages`. The daemon package +provides its own runtime. The service does not inherit your interactive shell's +PATH, so migrating from `albedo daemon install` can change which tools it finds. + +For additional tools, extend the native service environment. On Linux, set +`systemd.user.sessionVariables.PATH` and include the profile and system paths you +need. On macOS, override +`launchd.agents.albedo-daemon.config.EnvironmentVariables.PATH` with `lib.mkForce`. +Include your system or Homebrew directories there if needed. These replace the +service PATH; keep the Home Manager profile so the daemon can find its tools. + +## Migrate an installed service + +Before enabling the declaration, run `albedo daemon uninstall` with the client +that owns your existing service. Then activate your Home Manager configuration. +CLI-installed and Home Manager services have different names. Leaving both +registered makes service control ambiguous, so Albedo refuses service mutations. +If both are already registered, disable the Home Manager service and activate, +uninstall the CLI service, then enable and activate the Home Manager service. + +Once Home Manager owns the declaration, use Home Manager to update or remove it. +Albedo refuses `daemon install` and `daemon uninstall` for external declarations. +It can start a supported, already loaded idle service and stop its authenticated +daemon. It never reloads or bootstraps an external declaration. + +## Apply service changes + +Home Manager owns registration and activation. Linux uses its normal +`systemd.user.startServices` behavior, which defaults to `sd-switch`. +Changed active services normally restart, wanted inactive services can start, +and removed active services stop. With `suggest`, run the suggested commands +yourself. Home Manager can skip reload if the user manager is unavailable. + +On macOS, Home Manager uses the GUI domain and waits for the Nix store before +exec. Its activation handles agent replacement. A disabled launchd override +blocks start until its owner or operator resolves the override. Albedo does not +change it, and Home Manager activation does not guarantee that it is cleared. + +A failed activation can leave the old loaded definition. Inspect +`albedo daemon status` after a change. Package selection alone does not prove +which daemon is running. See [Daemon service](daemon-lifecycle.md#daemon-service) +for shutdown and kernel survival limits. -- knotmirror 0.0.1