aboutsummaryrefslogtreecommitdiffstats
path: root/modules/fysiweb-capabilities/default.nix
blob: 862aaf74df627fefd7915b342bc5b5aaba5bb80c (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
30
31
32
33
34
35
{ config, lib, ... }:
let
  allApps = lib.concatMap lib.attrValues (lib.concatMap lib.attrValues (lib.attrValues config.fysiweb-apps));
in
{
  options.fysiweb.capabilities.password-credentials = lib.mkOption {
    type = lib.types.attrsOf (lib.types.attrsOf (lib.types.submodule {
      options.username = lib.mkOption {
        type = lib.types.str;
      };
      options.passwordFile = lib.mkOption {
        type = lib.types.str;
      };
    }));
    default = { };
  };
  options.fysiweb.capabilities.ssh-credentials = lib.mkOption {
    type = lib.types.attrsOf (lib.types.attrsOf (lib.types.submodule {
      options.publicKeyFiles = lib.mkOption {
        type = lib.types.listOf lib.types.str;
      };
    }));
    default = { };
  };
  config = {
    fysiweb.capabilities = lib.attrsets.mergeAttrsList (lib.concatMap
      (appConfig:
        let path = (toString ../../apps) + "/${appConfig.appName}/capabilities.nix"; in
        lib.optionals (lib.pathIsRegularFile path) [
          (lib.mapAttrs (_: value: { ${appConfig.appId} = value; })
            (import path { inherit appConfig config lib; }))
        ])
      allApps);
  };
}