projects/guix·blob python-team · refs

85 lines · 3.8 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2025 Oleg Pykhalov <[email protected]>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
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 ;list of strings
40 (default '())))
41
42(define (home-niri-shepherd-service config)
43 "Return a shepherd service that runs Niri, a scrollable tiling Wayland
44compositor. The service starts Niri with appropriate environment variables
45set 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
82compositor. This service starts Niri as a user-level desktop session with
83proper environment variables set for Wayland compatibility. It ensures Niri
84and its dependencies are available in the user's profile.")
85 (default-value (niri-configuration))))