| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 |
|
| 19 | (define-module (gnu home services niri)
|
| 20 | #:use-module (gnu home services)
|
| 21 | #:use-module (gnu home services shepherd)
|
| 22 | #:use-module (gnu home services desktop)
|
| 23 | #:use-module (gnu packages bash)
|
| 24 | #:use-module (gnu packages freedesktop)
|
| 25 | #:use-module (gnu packages glib)
|
| 26 | #:use-module (gnu packages gnome)
|
| 27 | #:use-module (gnu packages xorg)
|
| 28 | #:use-module (gnu packages window-management)
|
| 29 | #:use-module (gnu services)
|
| 30 | #:use-module (gnu services shepherd)
|
| 31 | #:use-module (guix gexp)
|
| 32 | #:use-module (guix records)
|
| 33 | #:export (niri-configuration
|
| 34 | home-niri-service-type))
|
| 35 |
|
| 36 | (define-record-type* <niri-configuration>
|
| 37 | niri-configuration make-niri-configuration
|
| 38 | niri-configuration?
|
| 39 | (environment-variables niri-configuration-environment-variables |
| 40 | (default '())))
|
| 41 |
|
| 42 | (define (home-niri-shepherd-service config)
|
| 43 | "Return a shepherd service that runs Niri, a scrollable tiling Wayland
|
| 44 | compositor. The service starts Niri with appropriate environment variables
|
| 45 | set for a Wayland desktop session."
|
| 46 | (list (shepherd-service
|
| 47 | (documentation "Run Niri scrollable tiling Wayland compositor.")
|
| 48 | (provision '(niri))
|
| 49 | (requirement '(dbus))
|
| 50 | (start #~(make-forkexec-constructor
|
| 51 | (list #$(file-append bash "/bin/bash") "-l"
|
| 52 | "-c" "exec niri --session")
|
| 53 | #:environment-variables
|
| 54 | (append (list #$@(niri-configuration-environment-variables config))
|
| 55 | '("DESKTOP_SESSION=niri"
|
| 56 | "XDG_CURRENT_DESKTOP=niri"
|
| 57 | "XDG_SESSION_DESKTOP=niri"
|
| 58 | "XDG_SESSION_TYPE=wayland")
|
| 59 | (filter (negate
|
| 60 | (lambda (str)
|
| 61 | (string-prefix? "WAYLAND_DISPLAY=" str)))
|
| 62 | (environ)))))
|
| 63 | (stop #~(make-kill-destructor)))))
|
| 64 |
|
| 65 | (define home-niri-service-type
|
| 66 | (service-type
|
| 67 | (name 'home-niri)
|
| 68 | (extensions
|
| 69 | (list (service-extension home-shepherd-service-type
|
| 70 | home-niri-shepherd-service)
|
| 71 | (service-extension home-dbus-service-type
|
| 72 | (const '()))
|
| 73 | (service-extension home-profile-service-type
|
| 74 | (lambda (config)
|
| 75 | (list dbus
|
| 76 | niri
|
| 77 | xdg-desktop-portal
|
| 78 | xdg-desktop-portal-gnome
|
| 79 | xdg-desktop-portal-gtk
|
| 80 | xwayland-satellite)))))
|
| 81 | (description "Install and configure Niri, a scrollable tiling Wayland
|
| 82 | compositor. This service starts Niri as a user-level desktop session with
|
| 83 | proper environment variables set for Wayland compatibility. It ensures Niri
|
| 84 | and its dependencies are available in the user's profile.")
|
| 85 | (default-value (niri-configuration))))
|