1{ config, pkgs, lib, ... }:
2
3with lib;
4
5let
6 cfg = config.programs.rootston;
7
8 rootstonWrapped = pkgs.writeScriptBin "rootston" ''
9 #! ${pkgs.runtimeShell}
10 if [[ "$#" -ge 1 ]]; then
11 exec ${pkgs.rootston}/bin/rootston "$@"
12 else
13 ${cfg.extraSessionCommands}
14 exec ${pkgs.rootston}/bin/rootston -C ${cfg.configFile}
15 fi
16 '';
17in {
18 options.programs.rootston = {
19 enable = mkEnableOption ''
20 rootston, the reference compositor for wlroots. The purpose of rootston
21 is to test and demonstrate the features of wlroots (if you want a real
22 Wayland compositor you should e.g. use Sway instead). You can manually
23 start the compositor by running "rootston" from a terminal'';
24
25 extraSessionCommands = mkOption {
26 type = types.lines;
27 default = "";
28 example = ''
29 # Define a keymap (US QWERTY is the default)
30 export XKB_DEFAULT_LAYOUT=de,us
31 export XKB_DEFAULT_VARIANT=nodeadkeys
32 export XKB_DEFAULT_OPTIONS=grp:alt_shift_toggle,caps:escape
33 '';
34 description = ''
35 Shell commands executed just before rootston is started.
36 '';
37 };
38
39 extraPackages = mkOption {
40 type = with types; listOf package;
41 default = with pkgs; [
42 westonLite xwayland rofi
43 ];
44 defaultText = literalExample ''
45 with pkgs; [
46 westonLite xwayland rofi
47 ]
48 '';
49 example = literalExample "[ ]";
50 description = ''
51 Extra packages to be installed system wide.
52 '';
53 };
54
55 config = mkOption {
56 type = types.str;
57 default = ''
58 [keyboard]
59 meta-key = Logo
60
61 # Sway/i3 like Keybindings
62 # Maps key combinations with commands to execute
63 # Commands include:
64 # - "exit" to stop the compositor
65 # - "exec" to execute a shell command
66 # - "close" to close the current view
67 # - "next_window" to cycle through windows
68 [bindings]
69 Logo+Shift+e = exit
70 Logo+q = close
71 Logo+m = maximize
72 Alt+Tab = next_window
73 Logo+Return = exec weston-terminal
74 Logo+d = exec rofi -show run
75 '';
76 description = ''
77 Default configuration for rootston (used when called without any
78 parameters).
79 '';
80 };
81
82 configFile = mkOption {
83 type = types.path;
84 default = "/etc/rootston.ini";
85 example = literalExample "${pkgs.rootston}/etc/rootston.ini";
86 description = ''
87 Path to the default rootston configuration file (the "config" option
88 will have no effect if you change the path).
89 '';
90 };
91 };
92
93 config = mkIf cfg.enable {
94 environment.etc."rootston.ini".text = cfg.config;
95 environment.systemPackages = [ rootstonWrapped ] ++ cfg.extraPackages;
96
97 hardware.opengl.enable = mkDefault true;
98 fonts.enableDefaultFonts = mkDefault true;
99 programs.dconf.enable = mkDefault true;
100 };
101
102 meta.maintainers = with lib.maintainers; [ primeos gnidorah ];
103}