1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8let
9 cfg = config.programs.river;
10
11 wayland-lib = import ./lib.nix { inherit lib; };
12in
13{
14 options.programs.river = {
15 enable = lib.mkEnableOption "river, a dynamic tiling Wayland compositor";
16
17 package =
18 lib.mkPackageOption pkgs "river" {
19 nullable = true;
20 extraDescription = ''
21 If the package is not overridable with `xwaylandSupport`, then the module option
22 {option}`xwayland` will have no effect.
23
24 Set to `null` to not add any River package to your path.
25 This should be done if you want to use the Home Manager River module to install River.
26 '';
27 }
28 // {
29 apply =
30 p:
31 if p == null then
32 null
33 else
34 wayland-lib.genFinalPackage p {
35 xwaylandSupport = cfg.xwayland.enable;
36 };
37 };
38
39 xwayland.enable = lib.mkEnableOption "XWayland" // {
40 default = true;
41 };
42
43 extraPackages = lib.mkOption {
44 type = with lib.types; listOf package;
45 default = with pkgs; [
46 swaylock
47 foot
48 dmenu
49 ];
50 defaultText = lib.literalExpression ''
51 with pkgs; [ swaylock foot dmenu ];
52 '';
53 example = lib.literalExpression ''
54 with pkgs; [ termite rofi light ]
55 '';
56 description = ''
57 Extra packages to be installed system wide. See
58 [Common X11 apps used on i3 with Wayland alternatives](https://github.com/swaywm/sway/wiki/i3-Migration-Guide#common-x11-apps-used-on-i3-with-wayland-alternatives)
59 for a list of useful software.
60 '';
61 };
62 };
63
64 config = lib.mkIf cfg.enable (
65 lib.mkMerge [
66 {
67 environment.systemPackages = lib.optional (cfg.package != null) cfg.package ++ cfg.extraPackages;
68
69 # To make a river session available if a display manager like SDDM is enabled:
70 services.displayManager.sessionPackages = lib.optional (cfg.package != null) cfg.package;
71
72 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
73 xdg.portal.config.river.default = lib.mkDefault [
74 "wlr"
75 "gtk"
76 ];
77 }
78
79 (import ./wayland-session.nix {
80 inherit lib pkgs;
81 enableXWayland = cfg.xwayland.enable;
82 })
83 ]
84 );
85
86 meta.maintainers = with lib.maintainers; [ GaetanLepage ];
87}