summary refs log tree commit diff
path: root/modules/foundation/services/utils.nix
blob: c7bbcf7ac6f37cf9a567d31c487eed504a244458 (plain)
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
{ ... }:

{
  naming = {
    networkService = name: "docker-${name}-network";

    groupTarget = group: "docker-${group}-group-root";

    serviceService = fullName: "docker-${fullName}";

    service =
      {
        group,
        name,
        full ? false,
      }:
      let
        isGroup = group != "";
        isDefault = name == "default" || name == group;

        shortName = if isGroup && isDefault then group else name;

        fullName = if isGroup then (if isDefault then group else "${group}-${name}") else name;
      in
      assert name != "";
      assert isDefault -> isGroup;
      if full then fullName else shortName;
  };
}