/
chunkwm.nix
132 lines (109 loc) · 4.44 KB
/
chunkwm.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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.chunkwm;
plugins = [ "border" "ffm" "tiling" ];
in
{
options = {
services.chunkwm.enable = mkOption {
type = types.bool;
default = false;
description = lib.mdDoc "Whether to enable the chunkwm window manager.";
};
services.chunkwm.package = mkOption {
type = types.package;
example = literalExpression "pkgs.chunkwm";
description = lib.mdDoc "This option specifies the chunkwm package to use.";
};
services.chunkwm.hotload = mkOption {
type = types.bool;
default = true;
description = lib.mdDoc "Whether to enable hotload.";
};
services.chunkwm.extraConfig = mkOption {
type = types.lines;
default = "";
example = ''chunkc tiling::rule --owner Emacs --state tile'';
description = lib.mdDoc "Additional commands for {file}`chunkwmrc`.";
};
services.chunkwm.plugins.dir = mkOption {
type = types.path;
default = "/run/current-system/sw/lib/chunkwm/plugins";
description = lib.mdDoc "Chunkwm Plugins directory.";
};
services.chunkwm.plugins.list = mkOption {
type = types.listOf (types.enum plugins);
default = plugins;
example = ["tiling"];
description = lib.mdDoc "Chunkwm Plugins to enable.";
};
services.chunkwm.plugins."border".config = mkOption {
type = types.lines;
default = ''chunkc set focused_border_color 0xffc0b18b'';
description = lib.mdDoc "Optional border plugin configuration.";
};
services.chunkwm.plugins."tiling".config = mkOption {
type = types.lines;
example = ''chunkc set global_desktop_mode bsp'';
description = lib.mdDoc "Optional tiling plugin configuration.";
};
};
config = mkIf cfg.enable {
services.chunkwm.plugins."border".config = mkDefault ''
chunkc set focused_border_color 0xffc0b18b
chunkc set focused_border_width 4
chunkc set focused_border_radius 0
chunkc set focused_border_skip_floating 0
'';
services.chunkwm.plugins."tiling".config = mkDefault ''
chunkc set global_desktop_mode bsp
chunkc set 2_desktop_mode monocle
chunkc set 5_desktop_mode float
chunkc set 1_desktop_tree ~/.chunkwm_layouts/dev_1
chunkc set global_desktop_offset_top 25
chunkc set global_desktop_offset_bottom 15
chunkc set global_desktop_offset_left 15
chunkc set global_desktop_offset_right 15
chunkc set global_desktop_offset_gap 15
chunkc set 1_desktop_offset_top 25
chunkc set 1_desktop_offset_bottom 15
chunkc set 1_desktop_offset_left 15
chunkc set 1_desktop_offset_right 15
chunkc set 1_desktop_offset_gap 15
chunkc set 3_desktop_offset_top 15
chunkc set 3_desktop_offset_bottom 15
chunkc set 3_desktop_offset_left 15
chunkc set 3_desktop_offset_right 15
chunkc set desktop_padding_step_size 10.0
chunkc set desktop_gap_step_size 5.0
chunkc set bsp_spawn_left 1
chunkc set bsp_optimal_ratio 1.618
chunkc set bsp_split_mode optimal
chunkc set bsp_split_ratio 0.66
chunkc set window_focus_cycle monitor
chunkc set mouse_follows_focus 1
chunkc set window_float_next 0
chunkc set window_float_center 1
chunkc set window_region_locked 1
'';
environment.etc."chunkwmrc".source = pkgs.writeScript "etc-chunkwmrc" (
''
#!/bin/bash
chunkc core::plugin_dir ${toString cfg.plugins.dir}
chunkc core::hotload ${if cfg.hotload then "1" else "0"}
''
+ concatMapStringsSep "\n" (p: "# Config for chunkwm-${p} plugin\n"+cfg.plugins.${p}.config or "# Nothing to configure") cfg.plugins.list
+ concatMapStringsSep "\n" (p: "chunkc core::load "+p+".so") cfg.plugins.list
+ "\n" + cfg.extraConfig
);
launchd.user.agents.chunkwm = {
path = [ cfg.package config.environment.systemPath ];
serviceConfig.ProgramArguments = [ "${getOutput "out" cfg.package}/bin/chunkwm" ]
++ [ "-c" "/etc/chunkwmrc" ];
serviceConfig.RunAtLoad = true;
serviceConfig.KeepAlive = true;
serviceConfig.ProcessType = "Interactive";
};
};
}