2.3 KiB
2.3 KiB
container-services/
Custom compose-style container service groups for systemd.
Files
| File | Purpose |
|---|---|
default.nix |
Main module entry point; imports options and wires everything |
options.nix |
All skyg.nixos.common.container-services.* option declarations |
lib.nix |
Shared helpers (runtime dispatch, path sanitization, env file collection) |
compose.nix |
YAML composition (mkComposeService, mkComposeAttrs, mkComposeFile, mkOverridesFile) |
files.nix |
File mounting logic (getAllFiles, mkFileVolumesForService, mkFilesService) |
systemd.nix |
Systemd unit builders (mkSystemdService, mkPathUnit, mkEnvReloadService) |
How it works
- User declares a group under
skyg.nixos.common.container-services.<group> options.nixvalidates the structurelib.nixprovides runtime dispatch (docker vs podman)compose.nixrenders a YAML compose file with all servicesfiles.nixcollects custom files, generates write commands, and builds file volume mountssystemd.nixbuilds oneshot units to manage the stackdefault.nixwires tmpfiles, services, and paths together
A group may instead set composeFile (e.g. to an agenix secret path) to use an
external, ready-made compose file for services instead of rendering from
options — useful for keeping sensitive definitions (NFS, env) out of version
control. networks/volumes/extraConfig set alongside composeFile still
apply: they're rendered as a base overrides file merged in via an earlier
compose -f flag, with composeFile itself taking precedence on overlaps.
See user-guide.md → "Secret Compose Definitions".
Adding a new feature
If adding a new per-service option:
- Add it to the submodule in
options.nix - Update the builder(s) in
compose.nix,files.nix, orsystemd.nixas needed - Update
user-guide.mdwith examples
Architecture
- Each group gets one systemd unit (
container-services-<group>.service) that manages the whole stack - Custom files are collected and written by a separate unit (
container-services-<group>-files.service) - Env file changes trigger a path unit that restarts the stack (
container-services-<group>-env-reload.*) - Compose files are rendered to the store and staged to
/var/lib/container-services/<group>/compose.yml