aboutsummaryrefslogtreecommitdiff
path: root/modules/kfmon.nix
blob: adb53bdb21b82e8f9b28d27cbaa1ea6e6b8f4576 (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
36
37
38
39
40
41
42
43
44
45
46
{ config, pkgs, lib, options, ... }:
with builtins // lib;
let
  cfg = config.kfmon;
  ini = pkgs.formats.ini {};
  importOption = p: (import p { inherit pkgs lib; } cfg.path).option;

  addSuffix = s: p: if hasSuffix s p then p else p + s;
in {
  options.kfmon = {
    enable = mkEnableOption "KFMon";

    path = mkOption {
      type = types.str;
      default = ".adds/kfmon";
      description = "Relative path to kfmon within src";
    };

    devPath = mkOption {
      type = types.str;
      default = "/mnt/onboard/${cfg.path}";
      readOnly = true;
      internal = true;
    };

    file = importOption ./lib/file.nix;
    manifest = importOption ./lib/manifest.nix;

    configs = mkOption {
      type = types.attrsOf ini.type
      default = {};
      description = ''
        KFMon .ini config files. Do not touch this unless you know what you're doing!
      '';
    };
  };

  config.kfmon.file = mapAttrs' (n: v: {
    name = addSuffix ".ini" n;
    value = {
      target = "config/${addSuffix ".ini" n}";
      text = generators.toINI {} v;
    };
  }) cfg.configs;

}