blob: 8ac50e4059b40c5fb8e9f3c50f4e7ba837951328 (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
{ config, pkgs, lib, ... }:
with builtins // lib;
let
cfg = config.kfmon;
ini = pkgs.formats.ini {};
in {
options.kfmon = {
enable = mkEnableOption "KFMon";
package = mkPackageOption pkgs "kfmon" {};
path = mkOption {
type = types.str;
readOnly = true;
internal = true;
default = ".adds/kfmon";
};
devicePath = mkOption {
type = types.str;
readOnly = true;
internal = true;
default = "/mnt/onboard/${cfg.path}";
};
file = mkOption {
default = {};
type = types.attrsOf (types.submodule (pkgs.callPackage ../lib/file-type.nix {}));
apply = filterAttrs (_: v: v.enable);
};
_createdFiles = mkOption {
type = types.package;
internal = true;
readOnly = true;
default = pkgs.buildEnv {
name = "kfmon-files-created";
paths = mapAttrsToList (_: v: v._package) cfg.file;
extraPrefix = cfg.devicePath;
};
};
finalPackage = mkOption {
type = types.package;
internal = true;
readOnly = true;
default = pkgs.mergePaths {
name = "kfmon-package";
paths = [
(pkgs.linkFarm "kfmon" [{
name = removePrefix "/" cfg.devicePath;
path = cfg.package.out;
}])
cfg._createdFiles
cfg.package.KoboRoot
];
};
};
# _allFiles = mkOption {
# type = types.package;
# internal = true;
# readOnly = true;
# default = pkgs.symlinkJoin {
# name = "kfmon-files";
# paths = mapAttrsToList (v: v._package) cfg.file;
# };
# };
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 = mkMerge [
{
info.kfmon = cfg.enable;
kfmon.file = mapAttrs' (n: v: {
name = "kfmon-config-${n}";
value = {
text = generators.toINI {
mkKeyValue = generators.mkKeyValueDefault {} " = ";
} v;
target =
let
fixedN = if hasSuffix ".ini" n then n else "${n}.ini";
in "config/${fixedN}";
};
}) cfg.configs;
kfmon.configs = {
kfmon.daemon = {
db_timeout = 500;
use_syslog = 0;
with_notifications = 1;
};
kfmon-log.watch = {
filename = "/mnt/onboard/icons/kfmon.png";
action = "${cfg.devicePath}/bin/kfmon-printlog.sh";
label = "Show KFMon log";
hidden = 1;
block_spawns = 0;
do_db_update = 0;
db_title = "KFMon Log";
db_author = "NiLuJe";
db_comment = "Print the last few lines of KFMon's log";
};
};
}
(mkIf cfg.enable {
koboroot.include = singleton cfg.finalPackage;
})
];
}
|