Files
nixpkgs/lib/services/config-data.nix
cinereal a338deb8a1 lib/services: move portable service infrastructure out of nixos/
Move the portable modular service base from
nixos/modules/system/service/portable/ to lib/services/, making it
importable by any module system (home-manager, nix-darwin) without
reaching into the nixos/ tree.

Moved files: service.nix, lib.nix, config-data.nix, config-data-item.nix,
test.nix. All external references updated (systemd/system.nix,
doc/manual/default.nix, assertions.nix, README.md).

No functional changes - only import paths differ.
2026-04-04 08:23:23 +02:00

48 lines
1.5 KiB
Nix

# Tests in: ../../nixos/tests/modular-service-etc/test.nix
# Non-modular context provided by the modular services integration.
{ pkgs }:
# Configuration data support for portable services
# This module provides configData for services, enabling configuration reloading
# without terminating and restarting the service process.
{
lib,
...
}:
let
inherit (lib) mkOption types;
inherit (lib.modules) importApply;
in
{
options = {
configData = mkOption {
default = { };
example = lib.literalExpression ''
{
"server.conf" = {
text = '''
port = 8080
workers = 4
''';
};
"ssl/cert.pem" = {
source = ./cert.pem;
};
}
'';
description = ''
Configuration data files for the service
These files are made available to the service and can be updated without restarting the service process, enabling configuration reloading.
The service manager implementation determines how these files are exposed to the service (e.g., via a specific directory path).
This path is available in the `path` sub-option for each `configData.<name>` entry.
This is particularly useful for services that support configuration reloading via signals (e.g., SIGHUP) or which pick up changes automatically, so that no downtime is required in order to reload the service.
'';
type = types.lazyAttrsOf (types.submodule (importApply ./config-data-item.nix pkgs));
};
};
}