summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/guix.texi126
-rw-r--r--gnu/services/base.scm246
2 files changed, 372 insertions, 0 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 127c87f7f48..c349ffc6d33 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -154,6 +154,7 @@ Copyright @copyright{} 2026 Yarl Baudig@*
154Copyright @copyright{} 2026 Joan Vilardaga Castro@* 154Copyright @copyright{} 2026 Joan Vilardaga Castro@*
155Copyright @copyright{} 2026 Nemin@* 155Copyright @copyright{} 2026 Nemin@*
156Copyright @copyright{} 2026 Fredrik Salomonsson@* 156Copyright @copyright{} 2026 Fredrik Salomonsson@*
157Copyright @copyright{} 2026 Sughosha@*
157 158
158Permission is granted to copy, distribute and/or modify this document 159Permission is granted to copy, distribute and/or modify this document
159under the terms of the GNU Free Documentation License, Version 1.3 or 160under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -22126,6 +22127,131 @@ instance of @code{greetd-user-session}.
22126@end table 22127@end table
22127@end deftp 22128@end deftp
22128 22129
22130@c %start of fragment
22131
22132@deftp {Data Type} greetd-nwg-hello-sway-session
22133Configuration record for the nwg-hello greetd greeter. It can be used as
22134follows:
22135
22136@lisp
22137 (greetd-configuration
22138 ;; The graphical greeter requires additional groups membership.
22139 (greeter-supplementary-groups (list "input" "video"))
22140 (terminals
22141 (list (greetd-terminal-configuration
22142 ;; Sway requires either seatd or elogind service, but elogind
22143 ;; is preferred for nwg-hello to reboot, shutdown or halt as
22144 ;; user by using the loginctl command.
22145 (extra-shepherd-requirement '(elogind))
22146 (terminal-vt "1")
22147 (terminal-switch #t)
22148 (default-session-command
22149 (greetd-nwg-hello-sway-session))))))
22150@end lisp
22151
22152Available @code{greetd-nwg-hello-sway-session} fields are:
22153
22154@table @asis
22155@item @code{sway} (default: @code{sway}) (type: package)
22156Package providing the @command{sway} and @command{swaymsg} commands.
22157
22158@item @code{sway-configuration} (type: maybe-file-like)
22159Extra configuration for @command{sway} to be included before executing
22160the greeter.
22161
22162@item @code{nwg-hello} (default: @code{nwg-hello}) (type: package)
22163Package providing the @command{nwg-hello} command.
22164
22165@item @code{nwg-hello-config} (type: nwg-hello-configuration)
22166Configuration of @command{nwg-hello}.
22167
22168@item @code{nwg-hello-style} (type: nwg-hello-style)
22169CSS style rules for @command{nwg-hello}.
22170
22171@end table
22172
22173@end deftp
22174
22175
22176@c %end of fragment
22177
22178@c %start of fragment
22179
22180@deftp {Data Type} nwg-hello-configuration
22181Available @code{nwg-hello-configuration} fields are:
22182
22183@table @asis
22184@item @code{session-dirs} (default: @code{("/run/current-system/profile/share/wayland-sessions" "/run/current-system/profile/share/xsessions")}) (type: list-of-strings)
22185List of directories containing Wayland or X session desktop files.
22186
22187@item @code{custom-sessions} (type: alist-of-strings-to-greetd-user-sessions)
22188Session names and the commands.
22189
22190@item @code{environment-variables} (default: @code{()}) (type: alist-of-strings-to-strings)
22191Environment variables associated to their values to pass to user
22192sessions.
22193
22194@item @code{halt-command} (default: @code{"loginctl suspend"}) (type: string)
22195Command to run when halting the device.
22196
22197@item @code{reboot-command} (default: @code{"loginctl reboot"}) (type: string)
22198Command to run when rebooting the device.
22199
22200@item @code{shutdown-command} (default: @code{"loginctl poweroff"}) (type: string)
22201Command to run when shutting down the device.
22202
22203@item @code{gtk-theme} (default: @code{"Advaita"}) (type: string)
22204GTK theme to use.
22205
22206@item @code{icon-theme} (default: @code{"Advaita"}) (type: string)
22207Icon theme to use.
22208
22209@item @code{cursor-theme} (default: @code{"Adwaita"}) (type: string)
22210Cursor theme to use.
22211
22212@item @code{prefer-dark-theme?} (default: @code{#t}) (type: boolean)
22213Flag to prefer dark mode for the theme.
22214
22215@item @code{extra-config} (type: maybe-alist-of-strings-to-strings)
22216Extra configuration of keys and values.
22217
22218@end table
22219
22220@end deftp
22221
22222
22223@c %end of fragment
22224
22225@c %start of fragment
22226
22227@deftp {Data Type} nwg-hello-style
22228Available @code{nwg-hello-style} fields are:
22229
22230@table @asis
22231@item @code{background-image} (type: file-like-or-#f)
22232Image file to be set as the background. Setting this to @code{#f}
22233respects the background color.
22234
22235@item @code{background-size} (default: @code{"auto 100%"}) (type: string)
22236Size of the background image. It can be @code{"auto"} (for preserving
22237the original size), @code{"cover"} (for resizing to fill while allowing
22238to cut or to stretch), @code{"contain"} (for resizing to fit assuring
22239the full visibility of the image), or a string of a number suffixed with
22240with @code{px} (to represent in pixels) or @code{%} (to represent in
22241percentage). It can also be a string of two such values separated by a
22242whitespace, representing width and height respectively.
22243
22244@item @code{extra-style} (type: maybe-alist-of-strings-to-alists-of-strings-to-strings)
22245List of CSS selectors associated to their lists of CSS properties
22246associated to their values.
22247
22248@end table
22249
22250@end deftp
22251
22252
22253@c %end of fragment
22254
22129@node Scheduled Job Execution 22255@node Scheduled Job Execution
22130@subsection Scheduled Job Execution 22256@subsection Scheduled Job Execution
22131 22257
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 6d514237314..af9dcc1bf60 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -23,6 +23,7 @@
23;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu> 23;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
24;;; Copyright © 2024 Zheng Junjie <873216071@qq.com> 24;;; Copyright © 2024 Zheng Junjie <873216071@qq.com>
25;;; Copyright © 2024 Andreas Enge <andreas@enge.fr> 25;;; Copyright © 2024 Andreas Enge <andreas@enge.fr>
26;;; Copyright © 2026 Sughosha <sughosha@disroot.org>
26;;; 27;;;
27;;; This file is part of GNU Guix. 28;;; This file is part of GNU Guix.
28;;; 29;;;
@@ -45,9 +46,11 @@
45 #:autoload (guix diagnostics) (warning formatted-message &fix-hint) 46 #:autoload (guix diagnostics) (warning formatted-message &fix-hint)
46 #:autoload (guix i18n) (G_) 47 #:autoload (guix i18n) (G_)
47 #:use-module (guix combinators) 48 #:use-module (guix combinators)
49 #:use-module (guix packages)
48 #:use-module (guix utils) 50 #:use-module (guix utils)
49 #:use-module (gnu services) 51 #:use-module (gnu services)
50 #:use-module (gnu services admin) 52 #:use-module (gnu services admin)
53 #:use-module (gnu services configuration)
51 #:use-module (gnu services shepherd) 54 #:use-module (gnu services shepherd)
52 #:use-module (gnu services sysctl) 55 #:use-module (gnu services sysctl)
53 #:use-module (gnu system pam) 56 #:use-module (gnu system pam)
@@ -83,6 +86,7 @@
83 #:use-module ((gnu packages file-systems) 86 #:use-module ((gnu packages file-systems)
84 #:select (bcachefs-tools exfat-utils jfsutils zfs)) 87 #:select (bcachefs-tools exfat-utils jfsutils zfs))
85 #:use-module (gnu packages fonts) 88 #:use-module (gnu packages fonts)
89 #:use-module ((gnu packages nwg-shell) #:select (nwg-hello))
86 #:use-module (gnu packages terminals) 90 #:use-module (gnu packages terminals)
87 #:use-module ((gnu packages wm) #:select (sway)) 91 #:use-module ((gnu packages wm) #:select (sway))
88 #:use-module ((gnu build file-systems) 92 #:use-module ((gnu build file-systems)
@@ -289,6 +293,31 @@
289 greetd-wlgreet-configuration 293 greetd-wlgreet-configuration
290 greetd-wlgreet-sway-session 294 greetd-wlgreet-sway-session
291 greetd-gtkgreet-sway-session 295 greetd-gtkgreet-sway-session
296 nwg-hello-configuration
297 nwg-hello-configuration?
298 nwg-hello-configuration-session-dirs
299 nwg-hello-configuration-custom-sessions
300 nwg-hello-configuration-environment-variables
301 nwg-hello-configuration-halt-command
302 nwg-hello-configuration-reboot-command
303 nwg-hello-configuration-shutdown-command
304 nwg-hello-configuration-gtk-theme
305 nwg-hello-configuration-icon-theme
306 nwg-hello-configuration-cursor-theme
307 nwg-hello-configuration-prefer-dark-theme?
308 nwg-hello-configuration-extra-config
309 nwg-hello-style
310 nwg-hello-style?
311 nwg-hello-style-background-image
312 nwg-hello-style-background-size
313 nwg-hello-style-extra-style
314 greetd-nwg-hello-sway-session
315 greetd-nwg-hello-sway-session?
316 greetd-nwg-hello-sway-session-sway
317 greetd-nwg-hello-sway-session-sway-configuration
318 greetd-nwg-hello-sway-session-nwg-hello
319 greetd-nwg-hello-sway-session-nwg-hello-config
320 greetd-nwg-hello-sway-session-nwg-hello-style
292 321
293 %base-services)) 322 %base-services))
294 323
@@ -4039,6 +4068,223 @@ to handle."
4039 sway 4068 sway
4040 (make-greetd-gtkgreet-sway-session-sway-config session))))) 4069 (make-greetd-gtkgreet-sway-session-sway-config session)))))
4041 4070
4071(define (alist-of pred?)
4072 "Return a procedure that takes an association list and check if all the
4073elements of the list result in @code{#t} when applying PRED? on them."
4074 (lambda (x)
4075 (if (alist? x)
4076 (every pred? x)
4077 #f)))
4078
4079(define alist-of-strings-to-greetd-user-sessions?
4080 (alist-of (match-lambda
4081 ((key . value)
4082 (if (and (string? key)
4083 (greetd-user-session? value))
4084 #t
4085 #f)))))
4086
4087(define alist-of-strings-to-strings?
4088 (alist-of (match-lambda
4089 ((key . value)
4090 (if (and (string? key)
4091 (string? value))
4092 #t
4093 #f)))))
4094
4095(define-maybe/no-serialization alist-of-strings-to-strings)
4096
4097(define-configuration/no-serialization nwg-hello-configuration
4098 (session-dirs
4099 (list-of-strings
4100 '("/run/current-system/profile/share/wayland-sessions"
4101 "/run/current-system/profile/share/xsessions"))
4102 "List of directories containing Wayland or X session desktop files.")
4103 (custom-sessions
4104 (alist-of-strings-to-greetd-user-sessions
4105 `(("Shell" . ,(greetd-user-session))))
4106 "Session names and the commands.")
4107 (environment-variables
4108 (alist-of-strings-to-strings '())
4109 "Environment variables associated to their values to pass to user sessions.")
4110 (halt-command
4111 (string "loginctl suspend")
4112 "Command to run when halting the device.")
4113 (reboot-command
4114 (string "loginctl reboot")
4115 "Command to run when rebooting the device.")
4116 (shutdown-command
4117 (string "loginctl poweroff")
4118 "Command to run when shutting down the device.")
4119 (gtk-theme
4120 (string "Advaita")
4121 "GTK theme to use.")
4122 (icon-theme
4123 (string "Advaita")
4124 "Icon theme to use.")
4125 (cursor-theme
4126 (string "Adwaita")
4127 "Cursor theme to use.")
4128 (prefer-dark-theme?
4129 (boolean #t)
4130 "Flag to prefer dark mode for the theme.")
4131 (extra-config
4132 (maybe-alist-of-strings-to-strings)
4133 "Extra configuration of keys and values."))
4134
4135(define nwg-hello-configuration-file
4136 (match-record-lambda <nwg-hello-configuration>
4137 (session-dirs custom-sessions environment-variables halt-command
4138 reboot-command shutdown-command gtk-theme icon-theme cursor-theme
4139 prefer-dark-theme? extra-config)
4140 (apply mixed-text-file "nwg-hello.json"
4141 (append '("{")
4142
4143 `("\n \"session_dirs\": [\n "
4144 ,(string-join (map (lambda (dir)
4145 (string-append "\"" dir "\""))
4146 session-dirs)
4147 ",\n ")
4148 "\n ]")
4149 `(",\n \"custom_sessions\": [\n "
4150 ,@(append-map (lambda (custom-session)
4151 `("{\n "
4152 "\"name\": \"" ,(car custom-session)
4153 "\",\n "
4154 "\"exec\": \"" ,(cdr custom-session)
4155 "\"\n }"
4156 ,(if (eq? custom-session
4157 (list-ref custom-sessions
4158 (- (length
4159 custom-sessions)
4160 1)))
4161 ""
4162 ",\"\n ")))
4163 custom-sessions)
4164 "\n ]")
4165 `(",\n \"cmd-sleep\": \"" ,halt-command "\"")
4166 `(",\n \"cmd-reboot\": \"" ,reboot-command "\"")
4167 `(",\n \"cmd-poweroff\": \"" ,shutdown-command "\"")
4168 `(",\n \"gtk-theme\": \"" ,gtk-theme "\"")
4169 `(",\n \"gtk-icon-theme\": \"" ,icon-theme "\"")
4170 `(",\n \"gtk-cursor-theme\": \"" ,cursor-theme "\"")
4171 `(",\n \"prefer-dark-theme\": "
4172 ,(if prefer-dark-theme? "true" "false"))
4173 `(",\n \"env-vars\": [\n "
4174 ,(string-join (map (match-lambda
4175 ((key . value)
4176 (string-append "\"" key "="
4177 value "\"")))
4178 environment-variables)
4179 ",\n ")
4180 "\n ]")
4181 (if (maybe-value-set? extra-config)
4182 (map (match-lambda
4183 ((key . value)
4184 (string-append ",\n \"" key "\": " value)))
4185 extra-config)
4186 '())
4187 '("\n}\n")))))
4188
4189(define (file-like-or-#f? value)
4190 (or (file-like? value)
4191 (not value)))
4192
4193(define alist-of-strings-to-alists-of-strings-to-strings?
4194 (alist-of (match-lambda
4195 ((key . value)
4196 (if (and (string? key)
4197 (alist-of-strings-to-strings? value))
4198 #t
4199 #f)))))
4200
4201(define-maybe/no-serialization alist-of-strings-to-alists-of-strings-to-strings)
4202
4203(define-configuration/no-serialization nwg-hello-style
4204 (background-image
4205 (file-like-or-#f (file-append nwg-hello "/share/nwg-hello/nwg.jpg"))
4206 "Image file to be set as the background. Setting this to @code{#f} respects
4207the background color.")
4208 (background-size
4209 (string "auto 100%")
4210 "Size of the background image. It can be @code{\"auto\"} (for preserving the
4211original size), @code{\"cover\"} (for resizing to fill while allowing to cut or
4212to stretch), @code{\"contain\"} (for resizing to fit assuring the full
4213visibility of the image), or a string of a number suffixed with with @code{px}
4214(to represent in pixels) or @code{%} (to represent in percentage). It can also
4215be a string of two such values separated by a whitespace, representing width and
4216height respectively.")
4217 (extra-style
4218 (maybe-alist-of-strings-to-alists-of-strings-to-strings)
4219 "List of CSS selectors associated to their lists of CSS properties
4220associated to their values."))
4221
4222(define nwg-hello-stylesheet
4223 (match-record-lambda <nwg-hello-style>
4224 (background-image background-size extra-style)
4225 (apply mixed-text-file "nwg-hello.css"
4226 "window {\n\tbackground-image: "
4227 #~(if #$background-image
4228 (string-append "url(\"" #$background-image "\")")
4229 "none")
4230 "; background-size: " background-size ";\n}"
4231 (append-map (match-lambda
4232 ((selector . declaration)
4233 `(,(string-append "\n" selector " {")
4234 ,@(map (match-lambda
4235 ((property . value)
4236 (string-append "\n\t" property ": " value
4237 ";")))
4238 declaration)
4239 "\n}")))
4240 (if (maybe-value-set? extra-style) extra-style '())))))
4241
4242(define-maybe/no-serialization file-like)
4243
4244(define-configuration/no-serialization greetd-nwg-hello-sway-session
4245 (sway
4246 (package sway)
4247 "Package providing the @command{sway} and @command{swaymsg} commands.")
4248 (sway-configuration
4249 (maybe-file-like)
4250 "Extra configuration for @command{sway} to be included before executing the
4251greeter.")
4252 (nwg-hello
4253 (package nwg-hello)
4254 "Package providing the @command{nwg-hello} command.")
4255 (nwg-hello-config
4256 (nwg-hello-configuration (nwg-hello-configuration))
4257 "Configuration of @command{nwg-hello}.")
4258 (nwg-hello-style
4259 (nwg-hello-style (nwg-hello-style))
4260 "CSS style rules for @command{nwg-hello}."))
4261
4262(define make-greetd-nwg-hello-sway-session-sway-config
4263 (match-record-lambda <greetd-nwg-hello-sway-session>
4264 (sway sway-configuration nwg-hello nwg-hello-config nwg-hello-style)
4265 (let ((nwg-hello-bin (file-append nwg-hello "/bin/nwg-hello"))
4266 (nwg-hello-configuration-file
4267 (nwg-hello-configuration-file nwg-hello-config))
4268 (nwg-hello-stylesheet (nwg-hello-stylesheet nwg-hello-style))
4269 (swaymsg-bin (file-append sway "/bin/swaymsg")))
4270 (mixed-text-file "nwg-hello-sway-config"
4271 (if (maybe-value-set? sway-configuration)
4272 #~(string-append "include " #$sway-configuration "\n")
4273 "")
4274 "xwayland disable\n"
4275 "exec \"" nwg-hello-bin " -l"
4276 " -c " nwg-hello-configuration-file " -s " nwg-hello-stylesheet
4277 "\""))))
4278
4279(define-gexp-compiler (greetd-nwg-hello-sway-session-compiler
4280 (session <greetd-nwg-hello-sway-session>)
4281 system target)
4282 (match-record session <greetd-nwg-hello-sway-session> (sway)
4283 (lower-object
4284 (make-greetd-sway-greeter-command
4285 sway
4286 (make-greetd-nwg-hello-sway-session-sway-config session)))))
4287
4042(define-record-type* <greetd-terminal-configuration> 4288(define-record-type* <greetd-terminal-configuration>
4043 greetd-terminal-configuration make-greetd-terminal-configuration 4289 greetd-terminal-configuration make-greetd-terminal-configuration
4044 greetd-terminal-configuration? 4290 greetd-terminal-configuration?