summaryrefslogtreecommitdiffstats
path: root/modules/desktop/niri.nix
blob: 1cf80e819698a68561c5c7def74823a49169e442 (plain) (blame)
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
{
    config,
    options,
    lib,
    pkgs,
    ...
}: let
    niriConf = config.modules.desktop.niri;
    device = config.modules.device;
    defaultApps = config.modules.desktop.defaultApplications.apps;
    configDir = config.nixosConfig.configDir;
in {
    options.modules.desktop.niri = {
        enable = lib.mkOption {
            type = lib.types.bool;
            default = false;
        };
    };

    config = lib.mkIf (niriConf.enable) (lib.mkMerge [
    {
        programs.niri.enable = true;
        programs.waybar.enable = true;
        programs.xwayland.enable = true;

        home.manager.services.polkit-gnome.enable = true;
        
        home.packages = with pkgs; [
            libnotify
            killall
            wdisplays
            xwayland-satellite
            wofi
            mako
            jq
            swww
        ];

        modules.device.displayProtocol = "wayland";

        environment.sessionVariables.NIXOS_OZONE_WL = "1";

        home.manager.xdg.configFile."niri/config.kdl".source = "${configDir}/niri/${config.networking.hostName}.kdl";

        system.userActivationScripts.linkwaybar.text = ''
            if [[ ! -h "$HOME/.config/waybar" ]]; then
                ln -s "${configDir}/waybar" "$HOME/.config/waybar"
            fi
        '';
    }
    (lib.mkIf (config.modules.desktop.greetd.enable) {
        services.greetd.settings = {
            default_session.command = ''
                ${pkgs.greetd.tuigreet}/bin/tuigreet \
                    --time \
                    --asterisks \
                    --user-menu \
                    --cmd niri-session
            '';
        };

        environment.etc."greetd/environments".text = ''
            Niri
        '';
    })
    ]);
}