summary refs log tree commit diff
path: root/nixos/lib/systemd-types.nix
blob: a109f248b17040b9b2a5411feb8d4ef4d7a23489 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{ lib, systemdUtils, pkgs }:

with systemdUtils.lib;
with systemdUtils.unitOptions;
with lib;

rec {
  units = with types;
    attrsOf (submodule ({ name, config, ... }: {
      options = concreteUnitOptions;
      config = { unit = mkDefault (systemdUtils.lib.makeUnit name config); };
    }));

  services = with types; attrsOf (submodule [ stage2ServiceOptions unitConfig stage2ServiceConfig ]);
  initrdServices = with types; attrsOf (submodule [ stage1ServiceOptions unitConfig stage1ServiceConfig ]);

  targets = with types; attrsOf (submodule [ stage2CommonUnitOptions unitConfig ]);
  initrdTargets = with types; attrsOf (submodule [ stage1CommonUnitOptions unitConfig ]);

  sockets = with types; attrsOf (submodule [ stage2SocketOptions unitConfig ]);
  initrdSockets = with types; attrsOf (submodule [ stage1SocketOptions unitConfig ]);

  timers = with types; attrsOf (submodule [ stage2TimerOptions unitConfig ]);
  initrdTimers = with types; attrsOf (submodule [ stage1TimerOptions unitConfig ]);

  paths = with types; attrsOf (submodule [ stage2PathOptions unitConfig ]);
  initrdPaths = with types; attrsOf (submodule [ stage1PathOptions unitConfig ]);

  slices = with types; attrsOf (submodule [ stage2SliceOptions unitConfig ]);
  initrdSlices = with types; attrsOf (submodule [ stage1SliceOptions unitConfig ]);

  mounts = with types; listOf (submodule [ stage2MountOptions unitConfig mountConfig ]);
  initrdMounts = with types; listOf (submodule [ stage1MountOptions unitConfig mountConfig ]);

  automounts = with types; listOf (submodule [ stage2AutomountOptions unitConfig automountConfig ]);
  initrdAutomounts = with types; attrsOf (submodule [ stage1AutomountOptions unitConfig automountConfig ]);

  initrdContents = types.attrsOf (types.submodule ({ config, options, name, ... }: {
    options = {
      enable = mkEnableOption (lib.mdDoc "copying of this file and symlinking it") // { default = true; };

      target = mkOption {
        type = types.path;
        description = lib.mdDoc ''
          Path of the symlink.
        '';
        default = name;
      };

      text = mkOption {
        default = null;
        type = types.nullOr types.lines;
        description = lib.mdDoc "Text of the file.";
      };

      source = mkOption {
        type = types.path;
        description = lib.mdDoc "Path of the source file.";
      };
    };

    config = {
      source = mkIf (config.text != null) (
        let name' = "initrd-" + baseNameOf name;
        in mkDerivedConfig options.text (pkgs.writeText name')
      );
    };
  }));
}