yams/packaging/systemd/yams-daemon.service
trvon e389e384b1
feat(packaging): ship the daemon as a systemd user unit
The service is now user-bound: each user runs their own daemon with
their own config ($XDG_CONFIG_HOME/yams/config.toml), corpus
($XDG_DATA_HOME/yams) and socket ($XDG_RUNTIME_DIR/yams-daemon.sock),
which is exactly what the CLI already resolves. The system service, its
yams account/group, the group socket and the /etc/yams/config.toml
configuration go away.

- Unit: /usr/lib/systemd/user/yams-daemon.service runs
  `yams-daemon --foreground` with default path resolution,
  Restart=on-failure, WantedBy=default.target, and light hardening
  (NoNewPrivileges, LockPersonality, RestrictRealtime, RestrictSUIDSGID,
  native syscalls only). No ProtectHome/PrivateTmp: the daemon reads the
  files its user adds.
- Enablement: /usr/lib/systemd/user-preset/80-yams.preset plus
  `systemctl --global preset` on first install (and on upgrade from a
  release with the system unit), so the unit starts with every user's
  next session; administrators override with a user preset or
  `systemctl --global disable`, and later upgrades keep that choice.
  Package scripts never start per-user instances: they reload running
  user managers, try-restart running user daemons on upgrade and stop
  them on removal (`systemctl --user` via runuser per /run/user/<uid>),
  then `systemctl --global disable` on removal.
- Migration from 0.20.x and the system-service design: deb preinst, rpm
  %pre and Arch pre_upgrade stop and disable the old system unit while
  its file is still installed (deb also purges deb-systemd-helper
  state). /var/lib/yams, the old system corpus that the CLI never
  reached, is left alone and documented; user corpora are never
  touched.
- The sysusers entry, account creation and the deb's passwd and
  init-system-helpers dependencies are dropped; the deb purge no longer
  deletes /var/lib/yams.
- Install paths move to lib/systemd/user and lib/systemd/user-preset in
  meson, the Arch stage/PKGBUILD and the install-surface policy.
- docs/install.md: the user service, enabling it now
  (`systemctl --user enable --now`), lingering, plugins via the user's
  config, opting out, upgrade and removal behaviour, and the 0.20.3
  leftover.

Signed-off-by: trvon <me@trevon.dev>
2026-10-02 07:55:01 -06:00

35 lines
1.3 KiB
Desktop File

# Per-user YAMS daemon, shipped by the deb, rpm and Arch packages as a
# systemd *user* unit (/usr/lib/systemd/user/yams-daemon.service).
#
# It runs as the logged-in user with the same path resolution as the CLI:
# config $XDG_CONFIG_HOME/yams/config.toml, data $XDG_DATA_HOME/yams (or the
# config's core.data_dir), socket $XDG_RUNTIME_DIR/yams-daemon.sock (or the
# config's daemon.socket_path) and log $XDG_STATE_HOME/yams/daemon.log. The
# CLI finds it without any configuration.
#
# The packages enable it for all users through the user preset
# (80-yams.preset), so it starts with each user's session. Start it now with
# systemctl --user enable --now yams-daemon.service
# Keep it running without a login session with `loginctl enable-linger <user>`.
[Unit]
Description=YAMS daemon (per-user)
Documentation=https://github.com/trvon/yams/blob/main/docs/install.md
[Service]
Type=simple
ExecStart=/usr/bin/yams-daemon --foreground
Restart=on-failure
RestartSec=2
LimitNOFILE=16384
UMask=0077
# Light hardening only: the daemon must read the files its user adds, so the
# home directory and /tmp stay visible (no ProtectHome=, no PrivateTmp=).
NoNewPrivileges=yes
LockPersonality=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
SystemCallArchitectures=native
[Install]
WantedBy=default.target