2.home-manager/docs/manual/usage
cinereal fb6a0c6d39 modules: add modular services support
Adds `home.services`, an attribute set of nixpkgs
[modular services](https://nixos.org/manual/nixos/unstable/#modular-services)
sourced from `<nixpkgs/lib/services/lib.nix>`. Each service exposes
`process.argv` and the upstream NixOS-style systemd schema
(`systemd.lib`, `systemd.mainExecStart`, `systemd.service`,
`systemd.services`, `systemd.sockets`) by re-exporting
`nixos/modules/system/service/systemd/service.nix`. Service modules
shipped with `_class = "service"` (e.g.
`pkgs.<name>.passthru.services.default`) drop in unchanged --
service portability across module systems is the point of modular
services.

Lifted units are evaluated and translated from NixOS-style attrs
(`wantedBy`, `serviceConfig`, `unitConfig`, `environment`, ...) into
the section-based INI shape (`{ Unit; Service; Install; }`) that
home-manager's `systemd.user.{services,sockets}` consumes; only the
common keys are mapped, uncommon options remain reachable via
`unitConfig` / `serviceConfig` / `socketConfig`. Sub-services and
their units are dashed under the parent service name;
`process.argv` becomes the default `ExecStart` for the service's
primary unit, which defaults to `WantedBy=default.target`.

Mirrors the surface of nixpkgs' portable systemd module (services +
sockets only); other unit kinds home-manager supports natively
(timers etc.) are intentionally not modeled until upstream grows
them.

Each service's `configData.<name>` entries are materialized at
`$XDG_CONFIG_HOME/system-services/<service-prefix>/<name>` (mirroring
how `nixos/modules/system/service/systemd/{config-data-path,system}.nix`
lifts `configData` to `environment.etc`), with the absolute path
injected back into `configData.<name>.path` so the service can refer
to its files at a stable location.

Includes nmt tests covering: a basic `process.argv`-only service, a
service with a `configData` entry, and importing
`pkgs.ghostunnel.passthru.services.default` to assert the lifted user
unit contains the expected ExecStart flags and `LoadCredential`
entries.
2026-05-04 17:22:16 +02:00
..
configuration.md home-manager: set 25.11 as stable 2025-11-26 10:43:01 -06:00
dotfiles.md docs: replace console language with shell 2023-12-07 21:28:18 +09:00
gpu-non-nixos.md docs/generic-linux-gpu: add instructions to manual 2025-11-09 09:02:58 -06:00
graphical.md docs: render without deprecated optionsDocBook 2023-12-07 21:27:38 +09:00
modular-services.md modules: add modular services support 2026-05-04 17:22:16 +02:00
rollbacks.md home-manager: avoid profile management during activation 2025-07-22 11:00:18 +02:00
updating.md docs: replace console language with shell 2023-12-07 21:28:18 +09:00
upgrading.md docs: add upgrade guide for NixOS version transitions 2025-07-28 11:04:16 +02:00