-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodule.nix
81 lines (75 loc) · 2.16 KB
/
module.nix
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
{inputs}: {
config,
lib,
pkgs,
...
}: let
cfg = config.programs.phomemo-d30;
tomlFormat = pkgs.formats.toml {};
d30-cli-full = pkgs.callPackage ./pkg.nix {
inherit (inputs) naersk;
fullBuild = true;
guiPreview = true;
};
d30-cli-minimal = pkgs.callPackage ./pkg.nix {
inherit (inputs) naersk;
};
in {
options.programs.phomemo-d30 = {
package = lib.mkOption {
type = lib.types.package;
default =
if (cfg.preview == "show_image")
then d30-cli-full
else d30-cli-minimal;
description = ''
Package to use.
'';
};
enable = lib.mkEnableOption "phomemo-d30";
default_device = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = "The default device to pick. Can be a device name, or a bluetooth address.";
example = {
default = "alice_desk";
};
};
resolution = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
default = {};
description = "Key-value list of device names for phomemo devices, alongside their actual addresses";
example = {
alice_desk = "E9:7B:61:9E:76:47";
bob_desk = "11:94:FC:4A:99:AC";
};
};
preview = lib.mkOption {
type = lib.types.oneOf [(lib.types.enum ["show_image" "wezterm" "gio"]) lib.types.str];
default = "gio";
description = ''
Preview backend to use. Defaults to `d30`.
Requires `d30-cli-full` package for `show_image` backend.
'';
example = "show_image";
};
};
config = lib.mkIf cfg.enable {
home.packages = [
cfg.package
];
xdg.configFile."phomemo-library/phomemo-cli-config.toml".source = tomlFormat.generate "phomemo-cli-config.toml" {
preview = cfg.preview;
};
xdg.configFile."phomemo-library/phomemo-config.toml".source =
tomlFormat.generate "phomemo-config.toml" {
resolution = cfg.resolution;
}
// (lib.optionalAttrs (cfg.default_device != null) {
default_device = cfg.default_device;
});
# // (lib.optionalAttrs (cfg.default != null) {
# default = cfg.default;
# });
};
}