main
 1{inputs, ...}: {
 2  den.aspects.desktop.wm.niri = {
 3    nixos = {
 4      # See https://github.com/NixOS/nixpkgs/blob/bcb52fa87abbc7ec046c4817d85950c35dae92b7/nixos/modules/services/misc/graphical-desktop.nix
 5      services.graphical-desktop.enable = true;
 6
 7      programs.niri = {
 8        enable = true;
 9        useNautilus = true;
10      };
11    };
12
13    provides.to-users = {
14      hjem = {
15        user,
16        pkgs,
17        lib,
18        ...
19      }: let
20        niriKeybindsKDLGenerator = binds: ''
21          binds {
22            ${lib.concatMapAttrsStringSep "\n  " (key: bind: ''${key} { ${bind}; }'') binds}
23          }
24        '';
25      in {
26        xdg.config.files =
27          lib.mergeAttrsList
28          (inputs.import-tree.withLib lib
29            (i: i.initFilter (lib.hasSuffix ".kdl"))
30            (i: i.map (x: {"niri/${lib.lists.last (lib.path.subpath.components (lib.path.splitRoot x).subpath)}".source = x;}))
31            (i: i.leafs ./config))
32          // {
33            "niri/nix/pre.kdl".text = "";
34            "niri/nix/post.kdl".text = ''
35              include "keybinds.kdl"
36
37              xwayland-satellite { path "${lib.getExe pkgs.xwayland-satellite}"; }
38            '';
39            "niri/nix/keybinds.kdl" = {
40              generator = niriKeybindsKDLGenerator;
41              value = {
42                "Mod+Grave" =
43                  lib.mkIf (user.system.settings.desktop.app.term.default != null)
44                  ''spawn "${user.system.settings.desktop.app.term.default}"'';
45              };
46            };
47          };
48      };
49    };
50  };
51
52  den.aspects.desktop.wm.niri.themes = {
53    catppuccin = {
54      hjem.xdg.config.files."niri/nix/pre.kdl".text = ''
55        layout {
56        	focus-ring {
57        		active-color "#cba6f7"
58        	}
59        }
60        recent-windows {
61        	highlight {
62        		active-color "#cba6f7"
63        		urgent-color "#f2cdcd"
64        	}
65        }
66      '';
67    };
68  };
69}