1# Non-module arguments
2# These are separate from the module arguments to avoid implicit dependencies.
3# This makes service modules self-contains, allowing mixing of Nixpkgs versions.
4{ pkgs }:
5
6# The module
7{
8 lib,
9 ...
10}:
11let
12 inherit (lib) mkOption types;
13 pathOrStr = types.coercedTo types.path (x: "${x}") types.str;
14in
15{
16 # https://nixos.org/manual/nixos/unstable/#modular-services
17 _class = "service";
18 imports = [
19 ../../../../../modules/generic/meta-maintainers.nix
20 ../../../misc/assertions.nix
21 (lib.modules.importApply ./config-data.nix { inherit pkgs; })
22 ];
23 options = {
24 services = mkOption {
25 type = types.attrsOf (
26 types.submoduleWith {
27 modules = [
28 (lib.modules.importApply ./service.nix { inherit pkgs; })
29 ];
30 }
31 );
32 description = ''
33 A collection of [modular services](https://nixos.org/manual/nixos/unstable/#modular-services) that are configured in one go.
34
35 You could consider the sub-service relationship to be an ownership relation.
36 It **does not** automatically create any other relationship between services (e.g. systemd slices), unless perhaps such a behavior is explicitly defined and enabled in another option.
37 '';
38 default = { };
39 visible = "shallow";
40 };
41 process = {
42 argv = lib.mkOption {
43 type = types.listOf pathOrStr;
44 example = lib.literalExpression ''[ (lib.getExe config.package) "--nobackground" ]'';
45 description = ''
46 Command filename and arguments for starting this service.
47 This is a raw command-line that should not contain any shell escaping.
48 If expansion of environmental variables is required then use
49 a shell script or `importas` from `pkgs.execline`.
50 '';
51 };
52 };
53 };
54}