aboutsummaryrefslogtreecommitdiffstats
path: root/modules/desktop/niri/default.nix
blob: 48c508cde8eefe7b255c4842ad5d0b18b8b65144 (plain)
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
{
  config,
  lib,
  pkgs,
  ...
}:
{
  imports = [ ./keybindings.nix ];

  options.desktop.hardware.gpu = {
    nvidia.enable = lib.mkEnableOption "Nvidia GPU Wayland optimizations";
    amd.enable = lib.mkEnableOption "AMD GPU Wayland optimizations";
  };

  config = lib.mkIf config.desktop.enable {
    home.sessionVariables = lib.mkMerge [
      {
        NIXOS_OZONE_WL = "1";
        QT_QPA_PLATFORM = "wayland;xcb";
        SDL_VIDEODRIVER = "wayland";
        CLUTTER_BACKEND = "wayland";
        GDK_SCALE = "1";
        QT_SCALE_FACTOR = "1";
      }

      (lib.mkIf config.desktop.hardware.gpu.nvidia.enable {
        LIBVA_DRIVER_NAME = "nvidia";
        __GLX_VENDOR_LIBRARY_NAME = "nvidia";
        GBM_BACKEND = "nvidia-drm";
        __GL_YIELD = "USLEEP";
        __GL_VRR_ALLOWED = "0";
      })

      (lib.mkIf config.desktop.hardware.gpu.amd.enable {
        AMD_VULKAN_ICD = "RADV";
        MESA_VK_DEVICE_SELECT = "1002:";
      })
    ];

    wayland.windowManager.niri = {
      enable = true;
      systemd.enable = true;
      # Let Niri register its recommended GNOME portal implementation.
      portalPackage = pkgs.xdg-desktop-portal-gnome;
    };

    home.packages = [ pkgs.swaybg ];

    home.pointerCursor = {
      enable = true;
      package = pkgs.adwaita-icon-theme;
      name = "Adwaita";
      size = 20;
      gtk.enable = true;
      x11.enable = true;
    };

    wayland.windowManager.niri.extraConfigEarly = ''
      input {
        keyboard {
          xkb {
            layout "us"
          }
        }
        touchpad {
          natural-scroll
          tap
          dwt
          click-method "clickfinger"
          accel-speed 0.5
        }
      }

      layout {
        gaps 5
        center-focused-column "on-overflow"
        default-column-width { proportion 1.0; }
        preset-column-widths {
          proportion 0.5
          proportion 1.0
        }
        focus-ring {
          width 1
          active-color "${config.scheme.withHashtag.base07}"
          inactive-color "${config.scheme.withHashtag.base03}"
        }
        border { off; }
        shadow { off; }
      }

      prefer-no-csd
      screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png"
      animations { off; }

      spawn-at-startup "${lib.getExe pkgs.swaybg}" "-i" "${../../../assets/sapling.png}" "-m" "fill"

      // Keep the familiar numbered workspaces persistent; Niri otherwise uses dynamic workspaces.
      workspace "1"
      workspace "2"
      workspace "3"
      workspace "4"
      workspace "5"
      workspace "6"
      workspace "7"
      workspace "8"
      workspace "9"
      workspace "10"
    '';
  };
}