Flake for my NixOS devices
1{...}: {
2 config,
3 lib,
4 pkgs,
5 ...
6}: {
7 options.cow.gdi = {
8 enable = lib.mkEnableOption "Hyprland with graphical apps, etc.";
9 doIdle = lib.mkEnableOption "Idling the system";
10 showGreet = lib.mkEnableOption "Show a greeter interface that runs UWSM to launch a Wayland window manager";
11 };
12
13 config = lib.mkIf config.cow.gdi.enable {
14 environment = {
15 systemPackages = with pkgs;
16 lib.mkIf config.cow.gdi.showGreet [
17 uwsm
18 ];
19 variables = {
20 NIXOS_OZONE_WL = "1";
21 _JAVA_AWT_WM_NONEREPARENTING = "1";
22 GDK_BACKEND = "wayland,x11";
23 ANKI_WAYLAND = "1";
24 MOZ_ENABLE_WAYLAND = "1";
25 XDG_SESSION_TYPE = "wayland";
26 SDL_VIDEODRIVER = "wayland";
27 CLUTTER_BACKEND = "wayland";
28 };
29 };
30
31 xdg.portal.extraPortals = with pkgs; [xdg-desktop-portal-gtk];
32
33 programs.hyprland = {
34 enable = true;
35 withUWSM = true;
36 };
37
38 services.greetd = lib.mkIf config.cow.gdi.showGreet {
39 enable = true;
40 useTextGreeter = true;
41 settings.default_session.command = let
42 greeting = ''--greeting "Authenticate into ${lib.toUpper config.networking.hostName}"'';
43 deCmd = pkgs.writeScript "start-session.sh" ''
44 #!/usr/bin/env sh
45 exec uwsm start ${pkgs.hyprland}/share/wayland-sessions/hyprland.desktop
46 '';
47 cmd = ''--cmd "systemd-inhibit --what=handle-power-key:handle-lid-switch ${deCmd}"'';
48 in "${pkgs.tuigreet}/bin/tuigreet --time ${greeting} ${cmd}";
49 };
50 };
51}