desktop.scm 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2014-2021 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
  4. ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
  5. ;;; Copyright © 2016 Sou Bunnbu <iyzsong@gmail.com>
  6. ;;; Copyright © 2017, 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  7. ;;; Copyright © 2017 Nikita <nikita@n0.is>
  8. ;;; Copyright © 2018, 2020 Efraim Flashner <efraim@flashner.co.il>
  9. ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
  10. ;;; Copyright © 2017, 2019 Christopher Baines <mail@cbaines.net>
  11. ;;; Copyright © 2019 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
  12. ;;; Copyright © 2019 David Wilson <david@daviwil.com>
  13. ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
  14. ;;; Copyright © 2020 Reza Alizadeh Majd <r.majd@pantherx.org>
  15. ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
  16. ;;;
  17. ;;; This file is part of GNU Guix.
  18. ;;;
  19. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  20. ;;; under the terms of the GNU General Public License as published by
  21. ;;; the Free Software Foundation; either version 3 of the License, or (at
  22. ;;; your option) any later version.
  23. ;;;
  24. ;;; GNU Guix is distributed in the hope that it will be useful, but
  25. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  26. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. ;;; GNU General Public License for more details.
  28. ;;;
  29. ;;; You should have received a copy of the GNU General Public License
  30. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  31. (define-module (gnu services desktop)
  32. #:use-module (gnu services)
  33. #:use-module (gnu services shepherd)
  34. #:use-module (gnu services base)
  35. #:use-module (gnu services dbus)
  36. #:use-module (gnu services avahi)
  37. #:use-module (gnu services xorg)
  38. #:use-module (gnu services networking)
  39. #:use-module (gnu services sound)
  40. #:use-module ((gnu system file-systems)
  41. #:select (%elogind-file-systems file-system))
  42. #:autoload (gnu services sddm) (sddm-service-type)
  43. #:use-module (gnu system)
  44. #:use-module (gnu system setuid)
  45. #:use-module (gnu system shadow)
  46. #:use-module (gnu system pam)
  47. #:use-module (gnu packages glib)
  48. #:use-module (gnu packages admin)
  49. #:use-module (gnu packages cups)
  50. #:use-module (gnu packages freedesktop)
  51. #:use-module (gnu packages gnome)
  52. #:use-module (gnu packages xfce)
  53. #:use-module (gnu packages avahi)
  54. #:use-module (gnu packages xdisorg)
  55. #:use-module (gnu packages scanner)
  56. #:use-module (gnu packages suckless)
  57. #:use-module (gnu packages linux)
  58. #:use-module (gnu packages libusb)
  59. #:use-module (gnu packages lxqt)
  60. #:use-module (gnu packages mate)
  61. #:use-module (gnu packages nfs)
  62. #:use-module (gnu packages enlightenment)
  63. #:use-module (guix deprecation)
  64. #:use-module (guix records)
  65. #:use-module (guix packages)
  66. #:use-module (guix store)
  67. #:use-module (guix utils)
  68. #:use-module (guix gexp)
  69. #:use-module (srfi srfi-1)
  70. #:use-module (ice-9 match)
  71. #:export (<upower-configuration>
  72. upower-configuration
  73. upower-configuration?
  74. upower-configuration-upower
  75. upower-configuration-watts-up-pro?
  76. upower-configuration-poll-batteries?
  77. upower-configuration-ignore-lid?
  78. upower-configuration-use-percentage-for-policy?
  79. upower-configuration-percentage-low
  80. upower-configuration-percentage-critical
  81. upower-configuration-percentage-action
  82. upower-configuration-time-low
  83. upower-configuration-time-critical
  84. upower-configuration-time-action
  85. upower-configuration-critical-power-action
  86. upower-service-type
  87. udisks-configuration
  88. udisks-configuration?
  89. udisks-service
  90. udisks-service-type
  91. colord-service-type
  92. geoclue-application
  93. geoclue-configuration
  94. geoclue-configuration?
  95. %standard-geoclue-applications
  96. geoclue-service
  97. geoclue-service-type
  98. bluetooth-service-type
  99. bluetooth-configuration
  100. bluetooth-configuration?
  101. bluetooth-service
  102. elogind-configuration
  103. elogind-configuration?
  104. elogind-service
  105. elogind-service-type
  106. %fontconfig-file-system
  107. fontconfig-file-system-service
  108. accountsservice-service-type
  109. accountsservice-service
  110. cups-pk-helper-service-type
  111. sane-service-type
  112. gnome-desktop-configuration
  113. gnome-desktop-configuration?
  114. gnome-desktop-service
  115. gnome-desktop-service-type
  116. mate-desktop-configuration
  117. mate-desktop-configuration?
  118. mate-desktop-service
  119. mate-desktop-service-type
  120. lxqt-desktop-configuration
  121. lxqt-desktop-configuration?
  122. lxqt-desktop-service-type
  123. xfce-desktop-configuration
  124. xfce-desktop-configuration?
  125. xfce-desktop-service
  126. xfce-desktop-service-type
  127. x11-socket-directory-service
  128. enlightenment-desktop-configuration
  129. enlightenment-desktop-configuration?
  130. enlightenment-desktop-service-type
  131. inputattach-configuration
  132. inputattach-configuration?
  133. inputattach-service-type
  134. polkit-wheel-service
  135. gnome-keyring-configuration
  136. gnome-keyring-configuration?
  137. gnome-keyring-service-type
  138. %desktop-services))
  139. ;;; Commentary:
  140. ;;;
  141. ;;; This module contains service definitions for a "desktop" environment.
  142. ;;;
  143. ;;; Code:
  144. ;;;
  145. ;;; Helpers.
  146. ;;;
  147. (define (bool value)
  148. (if value "true\n" "false\n"))
  149. (define (package-direct-input-selector input)
  150. (lambda (package)
  151. (match (assoc-ref (package-direct-inputs package) input)
  152. ((package . _) package))))
  153. ;;;
  154. ;;; Upower D-Bus service.
  155. ;;;
  156. (define-record-type* <upower-configuration>
  157. upower-configuration make-upower-configuration
  158. upower-configuration?
  159. (upower upower-configuration-upower
  160. (default upower))
  161. (watts-up-pro? upower-configuration-watts-up-pro?
  162. (default #f))
  163. (poll-batteries? upower-configuration-poll-batteries?
  164. (default #t))
  165. (ignore-lid? upower-configuration-ignore-lid?
  166. (default #f))
  167. (use-percentage-for-policy? upower-configuration-use-percentage-for-policy?
  168. (default #f))
  169. (percentage-low upower-configuration-percentage-low
  170. (default 10))
  171. (percentage-critical upower-configuration-percentage-critical
  172. (default 3))
  173. (percentage-action upower-configuration-percentage-action
  174. (default 2))
  175. (time-low upower-configuration-time-low
  176. (default 1200))
  177. (time-critical upower-configuration-time-critical
  178. (default 300))
  179. (time-action upower-configuration-time-action
  180. (default 120))
  181. (critical-power-action upower-configuration-critical-power-action
  182. (default 'hybrid-sleep)))
  183. (define* upower-configuration-file
  184. ;; Return an upower-daemon configuration file.
  185. (match-lambda
  186. (($ <upower-configuration> upower
  187. watts-up-pro? poll-batteries? ignore-lid? use-percentage-for-policy?
  188. percentage-low percentage-critical percentage-action time-low
  189. time-critical time-action critical-power-action)
  190. (plain-file "UPower.conf"
  191. (string-append
  192. "[UPower]\n"
  193. "EnableWattsUpPro=" (bool watts-up-pro?)
  194. "NoPollBatteries=" (bool (not poll-batteries?))
  195. "IgnoreLid=" (bool ignore-lid?)
  196. "UsePercentageForPolicy=" (bool use-percentage-for-policy?)
  197. "PercentageLow=" (number->string percentage-low) "\n"
  198. "PercentageCritical=" (number->string percentage-critical) "\n"
  199. "PercentageAction=" (number->string percentage-action) "\n"
  200. "TimeLow=" (number->string time-low) "\n"
  201. "TimeCritical=" (number->string time-critical) "\n"
  202. "TimeAction=" (number->string time-action) "\n"
  203. "CriticalPowerAction=" (match critical-power-action
  204. ('hybrid-sleep "HybridSleep")
  205. ('hibernate "Hibernate")
  206. ('power-off "PowerOff"))
  207. "\n")))))
  208. (define %upower-activation
  209. #~(begin
  210. (use-modules (guix build utils))
  211. (mkdir-p "/var/lib/upower")))
  212. (define (upower-dbus-service config)
  213. (list (wrapped-dbus-service (upower-configuration-upower config)
  214. "libexec/upowerd"
  215. `(("UPOWER_CONF_FILE_NAME"
  216. ,(upower-configuration-file config))))))
  217. (define (upower-shepherd-service config)
  218. "Return a shepherd service for UPower with CONFIG."
  219. (let ((upower (upower-configuration-upower config))
  220. (config (upower-configuration-file config)))
  221. (list (shepherd-service
  222. (documentation "Run the UPower power and battery monitor.")
  223. (provision '(upower-daemon))
  224. (requirement '(dbus-system udev))
  225. (start #~(make-forkexec-constructor
  226. (list (string-append #$upower "/libexec/upowerd"))
  227. #:environment-variables
  228. (list (string-append "UPOWER_CONF_FILE_NAME="
  229. #$config))))
  230. (stop #~(make-kill-destructor))))))
  231. (define upower-service-type
  232. (let ((upower-package (compose list upower-configuration-upower)))
  233. (service-type (name 'upower)
  234. (description
  235. "Run @command{upowerd}}, a system-wide monitor for power
  236. consumption and battery levels, with the given configuration settings. It
  237. implements the @code{org.freedesktop.UPower} D-Bus interface, and is notably
  238. used by GNOME.")
  239. (extensions
  240. (list (service-extension dbus-root-service-type
  241. upower-dbus-service)
  242. (service-extension shepherd-root-service-type
  243. upower-shepherd-service)
  244. (service-extension activation-service-type
  245. (const %upower-activation))
  246. (service-extension udev-service-type
  247. upower-package)
  248. ;; Make the 'upower' command visible.
  249. (service-extension profile-service-type
  250. upower-package)))
  251. (default-value (upower-configuration)))))
  252. ;;;
  253. ;;; GeoClue D-Bus service.
  254. ;;;
  255. ;; TODO: Export.
  256. (define-record-type* <geoclue-configuration>
  257. geoclue-configuration make-geoclue-configuration
  258. geoclue-configuration?
  259. (geoclue geoclue-configuration-geoclue
  260. (default geoclue))
  261. (whitelist geoclue-configuration-whitelist)
  262. (wifi-geolocation-url geoclue-configuration-wifi-geolocation-url)
  263. (submit-data? geoclue-configuration-submit-data?)
  264. (wifi-submission-url geoclue-configuration-wifi-submission-url)
  265. (submission-nick geoclue-configuration-submission-nick)
  266. (applications geoclue-configuration-applications))
  267. (define* (geoclue-application name #:key (allowed? #t) system? (users '()))
  268. "Configure default GeoClue access permissions for an application. NAME is
  269. the Desktop ID of the application, without the .desktop part. If ALLOWED? is
  270. true, the application will have access to location information by default.
  271. The boolean SYSTEM? value indicates that an application is a system component
  272. or not. Finally USERS is a list of UIDs of all users for which this
  273. application is allowed location info access. An empty users list means all
  274. users are allowed."
  275. (string-append
  276. "[" name "]\n"
  277. "allowed=" (bool allowed?)
  278. "system=" (bool system?)
  279. "users=" (string-join users ";") "\n"))
  280. (define %standard-geoclue-applications
  281. (list (geoclue-application "gnome-datetime-panel" #:system? #t)
  282. (geoclue-application "epiphany" #:system? #f)
  283. (geoclue-application "firefox" #:system? #f)))
  284. (define* (geoclue-configuration-file config)
  285. "Return a geoclue configuration file."
  286. (plain-file "geoclue.conf"
  287. (string-append
  288. "[agent]\n"
  289. "whitelist="
  290. (string-join (geoclue-configuration-whitelist config)
  291. ";") "\n"
  292. "[wifi]\n"
  293. "url=" (geoclue-configuration-wifi-geolocation-url config) "\n"
  294. "submit-data=" (bool (geoclue-configuration-submit-data? config))
  295. "submission-url="
  296. (geoclue-configuration-wifi-submission-url config) "\n"
  297. "submission-nick="
  298. (geoclue-configuration-submission-nick config)
  299. "\n"
  300. (string-join (geoclue-configuration-applications config)
  301. "\n"))))
  302. (define (geoclue-dbus-service config)
  303. (list (wrapped-dbus-service (geoclue-configuration-geoclue config)
  304. "libexec/geoclue"
  305. `(("GEOCLUE_CONFIG_FILE"
  306. ,(geoclue-configuration-file config))))))
  307. (define %geoclue-accounts
  308. (list (user-group (name "geoclue") (system? #t))
  309. (user-account
  310. (name "geoclue")
  311. (group "geoclue")
  312. (system? #t)
  313. (comment "GeoClue daemon user")
  314. (home-directory "/var/empty")
  315. (shell "/run/current-system/profile/sbin/nologin"))))
  316. (define geoclue-service-type
  317. (service-type (name 'geoclue)
  318. (extensions
  319. (list (service-extension dbus-root-service-type
  320. geoclue-dbus-service)
  321. (service-extension account-service-type
  322. (const %geoclue-accounts))))))
  323. (define* (geoclue-service #:key (geoclue geoclue)
  324. (whitelist '())
  325. (wifi-geolocation-url
  326. ;; Mozilla geolocation service:
  327. "https://location.services.mozilla.com/v1/geolocate?key=geoclue")
  328. (submit-data? #f)
  329. (wifi-submission-url
  330. "https://location.services.mozilla.com/v1/submit?key=geoclue")
  331. (submission-nick "geoclue")
  332. (applications %standard-geoclue-applications))
  333. "Return a service that runs the @command{geoclue} location service. This
  334. service provides a D-Bus interface to allow applications to request access to
  335. a user's physical location, and optionally to add information to online
  336. location databases. By default, only the GNOME date-time panel and the Icecat
  337. and Epiphany web browsers are able to ask for the user's location, and in the
  338. case of Icecat and Epiphany, both will ask the user for permission first. See
  339. @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the geoclue web
  340. site} for more information."
  341. (service geoclue-service-type
  342. (geoclue-configuration
  343. (geoclue geoclue)
  344. (whitelist whitelist)
  345. (wifi-geolocation-url wifi-geolocation-url)
  346. (submit-data? submit-data?)
  347. (wifi-submission-url wifi-submission-url)
  348. (submission-nick submission-nick)
  349. (applications applications))))
  350. ;;;
  351. ;;; Bluetooth.
  352. ;;;
  353. (define-record-type* <bluetooth-configuration>
  354. bluetooth-configuration make-bluetooth-configuration
  355. bluetooth-configuration?
  356. (bluez bluetooth-configuration-bluez (default bluez))
  357. (auto-enable? bluetooth-configuration-auto-enable? (default #f)))
  358. (define (bluetooth-configuration-file config)
  359. "Return a configuration file for the systemd bluetooth service, as a string."
  360. (string-append
  361. "[Policy]\n"
  362. "AutoEnable=" (bool (bluetooth-configuration-auto-enable?
  363. config))))
  364. (define (bluetooth-directory config)
  365. (computed-file "etc-bluetooth"
  366. #~(begin
  367. (mkdir #$output)
  368. (chdir #$output)
  369. (call-with-output-file "main.conf"
  370. (lambda (port)
  371. (display #$(bluetooth-configuration-file config)
  372. port))))))
  373. (define (bluetooth-shepherd-service config)
  374. "Return a shepherd service for @command{bluetoothd}."
  375. (shepherd-service
  376. (provision '(bluetooth))
  377. (requirement '(dbus-system udev))
  378. (documentation "Run the bluetoothd daemon.")
  379. (start #~(make-forkexec-constructor
  380. (list #$(file-append (bluetooth-configuration-bluez config)
  381. "/libexec/bluetooth/bluetoothd"))))
  382. (stop #~(make-kill-destructor))))
  383. (define bluetooth-service-type
  384. (service-type
  385. (name 'bluetooth)
  386. (extensions
  387. (list (service-extension dbus-root-service-type
  388. (compose list bluetooth-configuration-bluez))
  389. (service-extension udev-service-type
  390. (compose list bluetooth-configuration-bluez))
  391. (service-extension etc-service-type
  392. (lambda (config)
  393. `(("bluetooth"
  394. ,(bluetooth-directory config)))))
  395. (service-extension shepherd-root-service-type
  396. (compose list bluetooth-shepherd-service))))
  397. (default-value (bluetooth-configuration))
  398. (description "Run the @command{bluetoothd} daemon, which manages all the
  399. Bluetooth devices and provides a number of D-Bus interfaces.")))
  400. (define* (bluetooth-service #:key (bluez bluez) (auto-enable? #f))
  401. "Return a service that runs the @command{bluetoothd} daemon, which manages
  402. all the Bluetooth devices and provides a number of D-Bus interfaces. When
  403. AUTO-ENABLE? is true, the bluetooth controller is powered automatically at
  404. boot.
  405. Users need to be in the @code{lp} group to access the D-Bus service.
  406. "
  407. (service bluetooth-service-type
  408. (bluetooth-configuration
  409. (bluez bluez)
  410. (auto-enable? auto-enable?))))
  411. ;;;
  412. ;;; Colord D-Bus service.
  413. ;;;
  414. (define %colord-activation
  415. #~(begin
  416. (use-modules (guix build utils))
  417. (mkdir-p "/var/lib/colord")
  418. (let ((user (getpwnam "colord")))
  419. (chown "/var/lib/colord"
  420. (passwd:uid user) (passwd:gid user)))))
  421. (define %colord-accounts
  422. (list (user-group (name "colord") (system? #t))
  423. (user-account
  424. (name "colord")
  425. (group "colord")
  426. (system? #t)
  427. (comment "colord daemon user")
  428. (home-directory "/var/empty")
  429. (shell (file-append shadow "/sbin/nologin")))))
  430. (define colord-service-type
  431. (service-type (name 'colord)
  432. (extensions
  433. (list (service-extension account-service-type
  434. (const %colord-accounts))
  435. (service-extension activation-service-type
  436. (const %colord-activation))
  437. ;; Colord is a D-Bus service that dbus-daemon can
  438. ;; activate.
  439. (service-extension dbus-root-service-type list)
  440. ;; Colord provides "color device" rules for udev.
  441. (service-extension udev-service-type list)
  442. ;; It provides polkit "actions".
  443. (service-extension polkit-service-type list)))
  444. (default-value colord)
  445. (description
  446. "Run @command{colord}, a system service with a D-Bus
  447. interface to manage the color profiles of input and output devices such as
  448. screens and scanners.")))
  449. ;;;
  450. ;;; UDisks.
  451. ;;;
  452. (define-record-type* <udisks-configuration>
  453. udisks-configuration make-udisks-configuration
  454. udisks-configuration?
  455. (udisks udisks-configuration-udisks
  456. (default udisks)))
  457. (define %udisks-activation
  458. (with-imported-modules '((guix build utils))
  459. #~(begin
  460. (use-modules (guix build utils))
  461. (let ((run-dir "/var/run/udisks2"))
  462. (mkdir-p run-dir)
  463. (chmod run-dir #o700)))))
  464. (define udisks-service-type
  465. (let ((udisks-package (lambda (config)
  466. (list (udisks-configuration-udisks config)))))
  467. (service-type (name 'udisks)
  468. (extensions
  469. (list (service-extension polkit-service-type
  470. udisks-package)
  471. (service-extension dbus-root-service-type
  472. udisks-package)
  473. (service-extension udev-service-type
  474. udisks-package)
  475. (service-extension activation-service-type
  476. (const %udisks-activation))
  477. ;; Profile 'udisksctl' & co. in the system profile.
  478. (service-extension profile-service-type
  479. udisks-package))))))
  480. (define* (udisks-service #:key (udisks udisks))
  481. "Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
  482. UDisks}, a @dfn{disk management} daemon that provides user interfaces with
  483. notifications and ways to mount/unmount disks. Programs that talk to UDisks
  484. include the @command{udisksctl} command, part of UDisks, and GNOME Disks."
  485. (service udisks-service-type
  486. (udisks-configuration (udisks udisks))))
  487. ;;;
  488. ;;; Elogind login and seat management service.
  489. ;;;
  490. (define-record-type* <elogind-configuration> elogind-configuration
  491. make-elogind-configuration
  492. elogind-configuration?
  493. (elogind elogind-package
  494. (default elogind))
  495. (kill-user-processes? elogind-kill-user-processes?
  496. (default #f))
  497. (kill-only-users elogind-kill-only-users
  498. (default '()))
  499. (kill-exclude-users elogind-kill-exclude-users
  500. (default '("root")))
  501. (inhibit-delay-max-seconds elogind-inhibit-delay-max-seconds
  502. (default 5))
  503. (handle-power-key elogind-handle-power-key
  504. (default 'poweroff))
  505. (handle-suspend-key elogind-handle-suspend-key
  506. (default 'suspend))
  507. (handle-hibernate-key elogind-handle-hibernate-key
  508. ;; (default 'hibernate)
  509. ;; XXX Ignore it for now, since we don't
  510. ;; yet handle resume-from-hibernation in
  511. ;; our initrd.
  512. (default 'ignore))
  513. (handle-lid-switch elogind-handle-lid-switch
  514. (default 'suspend))
  515. (handle-lid-switch-docked elogind-handle-lid-switch-docked
  516. (default 'ignore))
  517. (handle-lid-switch-external-power elogind-handle-lid-switch-external-power
  518. (default 'ignore))
  519. (power-key-ignore-inhibited? elogind-power-key-ignore-inhibited?
  520. (default #f))
  521. (suspend-key-ignore-inhibited? elogind-suspend-key-ignore-inhibited?
  522. (default #f))
  523. (hibernate-key-ignore-inhibited? elogind-hibernate-key-ignore-inhibited?
  524. (default #f))
  525. (lid-switch-ignore-inhibited? elogind-lid-switch-ignore-inhibited?
  526. (default #t))
  527. (holdoff-timeout-seconds elogind-holdoff-timeout-seconds
  528. (default 30))
  529. (idle-action elogind-idle-action
  530. (default 'ignore))
  531. (idle-action-seconds elogind-idle-action-seconds
  532. (default (* 30 60)))
  533. (runtime-directory-size-percent elogind-runtime-directory-size-percent
  534. (default 10))
  535. (runtime-directory-size elogind-runtime-directory-size
  536. (default #f))
  537. (remove-ipc? elogind-remove-ipc?
  538. (default #t))
  539. (suspend-state elogind-suspend-state
  540. (default '("mem" "standby" "freeze")))
  541. (suspend-mode elogind-suspend-mode
  542. (default '()))
  543. (hibernate-state elogind-hibernate-state
  544. (default '("disk")))
  545. (hibernate-mode elogind-hibernate-mode
  546. (default '("platform" "shutdown")))
  547. (hybrid-sleep-state elogind-hybrid-sleep-state
  548. (default '("disk")))
  549. (hybrid-sleep-mode elogind-hybrid-sleep-mode
  550. (default
  551. '("suspend" "platform" "shutdown"))))
  552. (define (elogind-configuration-file config)
  553. (define (yesno x)
  554. (match x
  555. (#t "yes")
  556. (#f "no")
  557. (_ (error "expected #t or #f, instead got:" x))))
  558. (define char-set:user-name
  559. (string->char-set "abcdefghijklmnopqrstuvwxyz0123456789_-"))
  560. (define (valid-list? l pred)
  561. (and-map (lambda (x) (string-every pred x)) l))
  562. (define (user-name-list users)
  563. (unless (valid-list? users char-set:user-name)
  564. (error "invalid user list" users))
  565. (string-join users " "))
  566. (define (enum val allowed)
  567. (unless (memq val allowed)
  568. (error "invalid value" val allowed))
  569. (symbol->string val))
  570. (define (non-negative-integer x)
  571. (unless (exact-integer? x) (error "not an integer" x))
  572. (when (negative? x) (error "negative number not allowed" x))
  573. (number->string x))
  574. (define handle-actions
  575. '(ignore poweroff reboot halt kexec suspend hibernate hybrid-sleep lock))
  576. (define (handle-action x)
  577. (enum x handle-actions))
  578. (define (sleep-list tokens)
  579. (unless (valid-list? tokens char-set:user-name)
  580. (error "invalid sleep list" tokens))
  581. (string-join tokens " "))
  582. (define-syntax ini-file-clause
  583. (syntax-rules ()
  584. ((_ config (prop (parser getter)))
  585. (string-append prop "=" (parser (getter config)) "\n"))
  586. ((_ config str)
  587. (string-append str "\n"))))
  588. (define-syntax-rule (ini-file config file clause ...)
  589. (plain-file file (string-append (ini-file-clause config clause) ...)))
  590. (ini-file
  591. config "logind.conf"
  592. "[Login]"
  593. ("KillUserProcesses" (yesno elogind-kill-user-processes?))
  594. ("KillOnlyUsers" (user-name-list elogind-kill-only-users))
  595. ("KillExcludeUsers" (user-name-list elogind-kill-exclude-users))
  596. ("InhibitDelayMaxSec" (non-negative-integer elogind-inhibit-delay-max-seconds))
  597. ("HandlePowerKey" (handle-action elogind-handle-power-key))
  598. ("HandleSuspendKey" (handle-action elogind-handle-suspend-key))
  599. ("HandleHibernateKey" (handle-action elogind-handle-hibernate-key))
  600. ("HandleLidSwitch" (handle-action elogind-handle-lid-switch))
  601. ("HandleLidSwitchDocked" (handle-action elogind-handle-lid-switch-docked))
  602. ("HandleLidSwitchExternalPower" (handle-action elogind-handle-lid-switch-external-power))
  603. ("PowerKeyIgnoreInhibited" (yesno elogind-power-key-ignore-inhibited?))
  604. ("SuspendKeyIgnoreInhibited" (yesno elogind-suspend-key-ignore-inhibited?))
  605. ("HibernateKeyIgnoreInhibited" (yesno elogind-hibernate-key-ignore-inhibited?))
  606. ("LidSwitchIgnoreInhibited" (yesno elogind-lid-switch-ignore-inhibited?))
  607. ("HoldoffTimeoutSec" (non-negative-integer elogind-holdoff-timeout-seconds))
  608. ("IdleAction" (handle-action elogind-idle-action))
  609. ("IdleActionSec" (non-negative-integer elogind-idle-action-seconds))
  610. ("RuntimeDirectorySize"
  611. (identity
  612. (lambda (config)
  613. (match (elogind-runtime-directory-size-percent config)
  614. (#f (non-negative-integer (elogind-runtime-directory-size config)))
  615. (percent (string-append (non-negative-integer percent) "%"))))))
  616. ("RemoveIPC" (yesno elogind-remove-ipc?))
  617. "[Sleep]"
  618. ("SuspendState" (sleep-list elogind-suspend-state))
  619. ("SuspendMode" (sleep-list elogind-suspend-mode))
  620. ("HibernateState" (sleep-list elogind-hibernate-state))
  621. ("HibernateMode" (sleep-list elogind-hibernate-mode))
  622. ("HybridSleepState" (sleep-list elogind-hybrid-sleep-state))
  623. ("HybridSleepMode" (sleep-list elogind-hybrid-sleep-mode))))
  624. (define (elogind-dbus-service config)
  625. (list (wrapped-dbus-service (elogind-package config)
  626. "libexec/elogind/elogind"
  627. `(("ELOGIND_CONF_FILE"
  628. ,(elogind-configuration-file config))))))
  629. (define (pam-extension-procedure config)
  630. "Return an extension for PAM-ROOT-SERVICE-TYPE that ensures that all the PAM
  631. services use 'pam_elogind.so', a module that allows elogind to keep track of
  632. logged-in users (run 'loginctl' to see elogind's world view of users and
  633. seats.)"
  634. (define pam-elogind
  635. (pam-entry
  636. (control "required")
  637. (module (file-append (elogind-package config)
  638. "/lib/security/pam_elogind.so"))))
  639. (list (lambda (pam)
  640. (pam-service
  641. (inherit pam)
  642. (session (cons pam-elogind (pam-service-session pam)))))))
  643. (define (elogind-shepherd-service config)
  644. "Return a Shepherd service to start elogind according to @var{config}."
  645. (list (shepherd-service
  646. (requirement '(dbus-system))
  647. (provision '(elogind))
  648. (start #~(make-forkexec-constructor
  649. (list #$(file-append (elogind-package config)
  650. "/libexec/elogind/elogind"))
  651. #:environment-variables
  652. (list (string-append "ELOGIND_CONF_FILE="
  653. #$(elogind-configuration-file
  654. config)))))
  655. (stop #~(make-kill-destructor)))))
  656. (define elogind-service-type
  657. (service-type (name 'elogind)
  658. (extensions
  659. (list (service-extension dbus-root-service-type
  660. elogind-dbus-service)
  661. (service-extension udev-service-type
  662. (compose list elogind-package))
  663. (service-extension polkit-service-type
  664. (compose list elogind-package))
  665. ;; Start elogind from the Shepherd rather than waiting
  666. ;; for bus activation. This ensures that it can handle
  667. ;; events like lid close, etc.
  668. (service-extension shepherd-root-service-type
  669. elogind-shepherd-service)
  670. ;; Provide the 'loginctl' command.
  671. (service-extension profile-service-type
  672. (compose list elogind-package))
  673. ;; Extend PAM with pam_elogind.so.
  674. (service-extension pam-root-service-type
  675. pam-extension-procedure)
  676. ;; We need /run/user, /run/systemd, etc.
  677. (service-extension file-system-service-type
  678. (const %elogind-file-systems))))
  679. (default-value (elogind-configuration))))
  680. (define* (elogind-service #:key (config (elogind-configuration)))
  681. "Return a service that runs the @command{elogind} login and seat management
  682. service. The @command{elogind} service integrates with PAM to allow other
  683. system components to know the set of logged-in users as well as their session
  684. types (graphical, console, remote, etc.). It can also clean up after users
  685. when they log out."
  686. (service elogind-service-type config))
  687. ;;;
  688. ;;; Fontconfig and other desktop file-systems.
  689. ;;;
  690. (define %fontconfig-file-system
  691. (file-system
  692. (device "none")
  693. (mount-point "/var/cache/fontconfig")
  694. (type "tmpfs")
  695. (flags '(read-only))
  696. (check? #f)))
  697. ;; The global fontconfig cache directory can sometimes contain stale entries,
  698. ;; possibly referencing fonts that have been GC'd, so mount it read-only.
  699. ;; As mentioned https://debbugs.gnu.org/cgi/bugreport.cgi?bug=36924#8 and
  700. ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=38046#10 and elsewhere.
  701. (define fontconfig-file-system-service
  702. (simple-service 'fontconfig-file-system
  703. file-system-service-type
  704. (list %fontconfig-file-system)))
  705. ;;;
  706. ;;; AccountsService service.
  707. ;;;
  708. (define %accountsservice-activation
  709. #~(begin
  710. (use-modules (guix build utils))
  711. (mkdir-p "/var/lib/AccountsService")))
  712. (define accountsservice-service-type
  713. (service-type (name 'accountsservice)
  714. (extensions
  715. (list (service-extension activation-service-type
  716. (const %accountsservice-activation))
  717. (service-extension dbus-root-service-type list)
  718. (service-extension polkit-service-type list)))
  719. (default-value accountsservice)))
  720. (define* (accountsservice-service #:key (accountsservice accountsservice))
  721. "Return a service that runs AccountsService, a system service that
  722. can list available accounts, change their passwords, and so on.
  723. AccountsService integrates with PolicyKit to enable unprivileged users to
  724. acquire the capability to modify their system configuration.
  725. @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
  726. accountsservice web site} for more information."
  727. (service accountsservice-service-type accountsservice))
  728. ;;;
  729. ;;; cups-pk-helper service.
  730. ;;;
  731. (define cups-pk-helper-service-type
  732. (service-type
  733. (name 'cups-pk-helper)
  734. (description
  735. "PolicyKit helper to configure CUPS with fine-grained privileges.")
  736. (extensions
  737. (list (service-extension dbus-root-service-type list)
  738. (service-extension polkit-service-type list)))
  739. (default-value cups-pk-helper)))
  740. ;;;
  741. ;;; Scanner access via SANE.
  742. ;;;
  743. (define %sane-accounts
  744. ;; The '60-libsane.rules' udev rules refers to the "scanner" group.
  745. (list (user-group (name "scanner") (system? #t))))
  746. (define sane-service-type
  747. (service-type
  748. (name 'sane)
  749. (description
  750. "This service provides access to scanners @i{via}
  751. @uref{http://www.sane-project.org, SANE} by installing the necessary udev
  752. rules.")
  753. (default-value sane-backends-minimal)
  754. (extensions
  755. (list (service-extension udev-service-type list)
  756. (service-extension account-service-type
  757. (const %sane-accounts))))))
  758. ;;;
  759. ;;; GNOME desktop service.
  760. ;;;
  761. (define-record-type* <gnome-desktop-configuration> gnome-desktop-configuration
  762. make-gnome-desktop-configuration
  763. gnome-desktop-configuration?
  764. (gnome gnome-package (default gnome)))
  765. (define (gnome-packages config packages)
  766. "Return the list of GNOME dependencies from CONFIG which names are part of
  767. the given PACKAGES list."
  768. (let ((gnome (gnome-package config)))
  769. (map (lambda (name)
  770. ((package-direct-input-selector name) gnome))
  771. packages)))
  772. (define (gnome-udev-rules config)
  773. "Return the list of GNOME dependencies that provide udev rules."
  774. (gnome-packages config '("gnome-settings-daemon")))
  775. (define (gnome-polkit-settings config)
  776. "Return the list of GNOME dependencies that provide polkit actions and
  777. rules."
  778. (gnome-packages config
  779. '("gnome-settings-daemon"
  780. "gnome-control-center"
  781. "gnome-system-monitor"
  782. "gvfs")))
  783. (define gnome-desktop-service-type
  784. (service-type
  785. (name 'gnome-desktop)
  786. (extensions
  787. (list (service-extension udev-service-type
  788. gnome-udev-rules)
  789. (service-extension polkit-service-type
  790. gnome-polkit-settings)
  791. (service-extension profile-service-type
  792. (compose list
  793. gnome-package))))
  794. (default-value (gnome-desktop-configuration))
  795. (description "Run the GNOME desktop environment.")))
  796. (define-deprecated (gnome-desktop-service #:key (config
  797. (gnome-desktop-configuration)))
  798. gnome-desktop-service-type
  799. "Return a service that adds the @code{gnome} package to the system profile,
  800. and extends polkit with the actions from @code{gnome-settings-daemon}."
  801. (service gnome-desktop-service-type config))
  802. ;; MATE Desktop service.
  803. ;; TODO: Add mate-screensaver.
  804. (define-record-type* <mate-desktop-configuration> mate-desktop-configuration
  805. make-mate-desktop-configuration
  806. mate-desktop-configuration?
  807. (mate-package mate-package (default mate)))
  808. (define (mate-polkit-extension config)
  809. "Return the list of packages for CONFIG's MATE package that extend polkit."
  810. (let ((mate (mate-package config)))
  811. (map (lambda (input)
  812. ((package-direct-input-selector input) mate))
  813. '("mate-system-monitor" ;kill, renice processes
  814. "mate-settings-daemon" ;date/time settings
  815. "mate-power-manager" ;modify brightness
  816. "mate-control-center" ;RandR, display properties FIXME
  817. "mate-applets")))) ;CPU frequency scaling
  818. (define mate-desktop-service-type
  819. (service-type
  820. (name 'mate-desktop)
  821. (extensions
  822. (list (service-extension polkit-service-type
  823. mate-polkit-extension)
  824. (service-extension profile-service-type
  825. (compose list
  826. mate-package))))
  827. (default-value (mate-desktop-configuration))
  828. (description "Run the MATE desktop environment.")))
  829. (define-deprecated (mate-desktop-service #:key
  830. (config
  831. (mate-desktop-configuration)))
  832. mate-desktop-service-type
  833. "Return a service that adds the @code{mate} package to the system profile,
  834. and extends polkit with the actions from @code{mate-settings-daemon}."
  835. (service mate-desktop-service-type config))
  836. ;;;
  837. ;;; XFCE desktop service.
  838. ;;;
  839. (define-record-type* <xfce-desktop-configuration> xfce-desktop-configuration
  840. make-xfce-desktop-configuration
  841. xfce-desktop-configuration?
  842. (xfce xfce-package (default xfce)))
  843. (define (xfce-polkit-settings config)
  844. "Return the list of XFCE dependencies that provide polkit actions and
  845. rules."
  846. (let ((xfce (xfce-package config)))
  847. (map (lambda (name)
  848. ((package-direct-input-selector name) xfce))
  849. '("thunar"
  850. "xfce4-power-manager"))))
  851. (define xfce-desktop-service-type
  852. (service-type
  853. (name 'xfce-desktop)
  854. (extensions
  855. (list (service-extension polkit-service-type
  856. xfce-polkit-settings)
  857. (service-extension profile-service-type
  858. (compose list xfce-package))))
  859. (default-value (xfce-desktop-configuration))
  860. (description "Run the Xfce desktop environment.")))
  861. (define-deprecated (xfce-desktop-service #:key (config
  862. (xfce-desktop-configuration)))
  863. xfce-desktop-service-type
  864. "Return a service that adds the @code{xfce} package to the system profile,
  865. and extends polkit with the ability for @code{thunar} to manipulate the file
  866. system as root from within a user session, after the user has authenticated
  867. with the administrator's password."
  868. (service xfce-desktop-service-type config))
  869. +
  870. ;;;
  871. ;;; Lxqt desktop service.
  872. ;;;
  873. (define-record-type* <lxqt-desktop-configuration> lxqt-desktop-configuration
  874. make-lxqt-desktop-configuration
  875. lxqt-desktop-configuration?
  876. (lxqt lxqt-package
  877. (default lxqt)))
  878. (define (lxqt-polkit-settings config)
  879. "Return the list of LXQt dependencies that provide polkit actions and
  880. rules."
  881. (let ((lxqt (lxqt-package config)))
  882. (map (lambda (name)
  883. ((package-direct-input-selector name) lxqt))
  884. '("lxqt-admin"))))
  885. (define lxqt-desktop-service-type
  886. (service-type
  887. (name 'lxqt-desktop)
  888. (extensions
  889. (list (service-extension polkit-service-type
  890. lxqt-polkit-settings)
  891. (service-extension profile-service-type
  892. (compose list lxqt-package))))
  893. (default-value (lxqt-desktop-configuration))
  894. (description "Run LXQt desktop environment.")))
  895. ;;;
  896. ;;; X11 socket directory service
  897. ;;;
  898. (define x11-socket-directory-service
  899. ;; Return a service that creates /tmp/.X11-unix. When using X11, libxcb
  900. ;; takes care of creating that directory. However, when using XWayland, we
  901. ;; need to create beforehand. Thus, create it unconditionally here.
  902. (simple-service 'x11-socket-directory
  903. activation-service-type
  904. (with-imported-modules '((guix build utils))
  905. #~(begin
  906. (use-modules (guix build utils))
  907. (let ((directory "/tmp/.X11-unix"))
  908. (mkdir-p directory)
  909. (chmod directory #o1777))))))
  910. ;;;
  911. ;;; Enlightenment desktop service.
  912. ;;;
  913. (define-record-type* <enlightenment-desktop-configuration>
  914. enlightenment-desktop-configuration make-enlightenment-desktop-configuration
  915. enlightenment-desktop-configuration?
  916. ;; <package>
  917. (enlightenment enlightenment-package
  918. (default enlightenment)))
  919. (define (enlightenment-setuid-programs enlightenment-desktop-configuration)
  920. (match-record enlightenment-desktop-configuration
  921. <enlightenment-desktop-configuration>
  922. (enlightenment)
  923. (map file-like->setuid-program
  924. (list (file-append enlightenment
  925. "/lib/enlightenment/utils/enlightenment_sys")
  926. (file-append enlightenment
  927. "/lib/enlightenment/utils/enlightenment_system")
  928. (file-append enlightenment
  929. "/lib/enlightenment/utils/enlightenment_ckpasswd")))))
  930. (define enlightenment-desktop-service-type
  931. (service-type
  932. (name 'enlightenment-desktop)
  933. (extensions
  934. (list (service-extension dbus-root-service-type
  935. (compose list
  936. (package-direct-input-selector
  937. "efl")
  938. enlightenment-package))
  939. (service-extension setuid-program-service-type
  940. enlightenment-setuid-programs)
  941. (service-extension profile-service-type
  942. (compose list
  943. enlightenment-package))))
  944. (default-value (enlightenment-desktop-configuration))
  945. (description
  946. "Return a service that adds the @code{enlightenment} package to the system
  947. profile, and extends dbus with the ability for @code{efl} to generate
  948. thumbnails and makes setuid the programs which enlightenment needs to function
  949. as expected.")))
  950. ;;;
  951. ;;; inputattach-service-type
  952. ;;;
  953. (define-record-type* <inputattach-configuration>
  954. inputattach-configuration
  955. make-inputattach-configuration
  956. inputattach-configuration?
  957. (device-type inputattach-configuration-device-type
  958. (default "wacom"))
  959. (device inputattach-configuration-device
  960. (default "/dev/ttyS0"))
  961. (baud-rate inputattach-configuration-baud-rate
  962. (default #f))
  963. (log-file inputattach-configuration-log-file
  964. (default #f)))
  965. (define inputattach-shepherd-service
  966. (match-lambda
  967. (($ <inputattach-configuration> type device baud-rate log-file)
  968. (let ((args (append (if baud-rate
  969. (list "--baud" (number->string baud-rate))
  970. '())
  971. (list (string-append "--" type)
  972. device))))
  973. (list (shepherd-service
  974. (provision '(inputattach))
  975. (requirement '(udev))
  976. (documentation "inputattach daemon")
  977. (start #~(make-forkexec-constructor
  978. (cons (string-append #$inputattach
  979. "/bin/inputattach")
  980. (quote #$args))
  981. #:log-file #$log-file))
  982. (stop #~(make-kill-destructor))))))))
  983. (define inputattach-service-type
  984. (service-type
  985. (name 'inputattach)
  986. (extensions
  987. (list (service-extension shepherd-root-service-type
  988. inputattach-shepherd-service)))
  989. (default-value (inputattach-configuration))
  990. (description "Return a service that runs inputattach on a device and
  991. dispatches events from it.")))
  992. ;;;
  993. ;;; gnome-keyring-service-type
  994. ;;;
  995. (define-record-type* <gnome-keyring-configuration> gnome-keyring-configuration
  996. make-gnome-keyring-configuration
  997. gnome-keyring-configuration?
  998. (keyring gnome-keyring-package (default gnome-keyring))
  999. (pam-services gnome-keyring-pam-services (default '(("gdm-password" . login)
  1000. ("passwd" . passwd)))))
  1001. (define (pam-gnome-keyring config)
  1002. (define (%pam-keyring-entry . arguments)
  1003. (pam-entry
  1004. (control "optional")
  1005. (module (file-append (gnome-keyring-package config)
  1006. "/lib/security/pam_gnome_keyring.so"))
  1007. (arguments arguments)))
  1008. (list
  1009. (lambda (service)
  1010. (case (assoc-ref (gnome-keyring-pam-services config)
  1011. (pam-service-name service))
  1012. ((login)
  1013. (pam-service
  1014. (inherit service)
  1015. (auth (append (pam-service-auth service)
  1016. (list (%pam-keyring-entry))))
  1017. (session (append (pam-service-session service)
  1018. (list (%pam-keyring-entry "auto_start"))))))
  1019. ((passwd)
  1020. (pam-service
  1021. (inherit service)
  1022. (password (append (pam-service-password service)
  1023. (list (%pam-keyring-entry))))))
  1024. (else service)))))
  1025. (define gnome-keyring-service-type
  1026. (service-type
  1027. (name 'gnome-keyring)
  1028. (extensions (list
  1029. (service-extension pam-root-service-type pam-gnome-keyring)))
  1030. (default-value (gnome-keyring-configuration))
  1031. (description "Return a service, that adds the @code{gnome-keyring} package
  1032. to the system profile and extends PAM with entries using
  1033. @code{pam_gnome_keyring.so}, unlocking a user's login keyring when they log in
  1034. or setting its password with passwd.")))
  1035. ;;;
  1036. ;;; polkit-wheel-service -- Allow wheel group to perform admin actions
  1037. ;;;
  1038. (define polkit-wheel
  1039. (file-union
  1040. "polkit-wheel"
  1041. `(("share/polkit-1/rules.d/wheel.rules"
  1042. ,(plain-file
  1043. "wheel.rules"
  1044. "polkit.addAdminRule(function(action, subject) {
  1045. return [\"unix-group:wheel\"];
  1046. });
  1047. ")))))
  1048. (define polkit-wheel-service
  1049. (simple-service 'polkit-wheel polkit-service-type (list polkit-wheel)))
  1050. ;;;
  1051. ;;; The default set of desktop services.
  1052. ;;;
  1053. (define* (desktop-services-for-system #:optional
  1054. (system (or (%current-target-system)
  1055. (%current-system))))
  1056. ;; List of services typically useful for a "desktop" use case.
  1057. ;; Since GDM depends on Rust (gdm -> gnome-shell -> gjs -> mozjs -> rust)
  1058. ;; and Rust is currently unavailable on non-x86_64 platforms, default to
  1059. ;; SDDM there (FIXME).
  1060. (cons* (if (string-prefix? "x86_64" system)
  1061. (service gdm-service-type)
  1062. (service sddm-service-type))
  1063. ;; Screen lockers are a pretty useful thing and these are small.
  1064. (screen-locker-service slock)
  1065. (screen-locker-service xlockmore "xlock")
  1066. ;; Add udev rules for MTP devices so that non-root users can access
  1067. ;; them.
  1068. (simple-service 'mtp udev-service-type (list libmtp))
  1069. ;; Add udev rules for scanners.
  1070. (service sane-service-type)
  1071. ;; Add polkit rules, so that non-root users in the wheel group can
  1072. ;; perform administrative tasks (similar to "sudo").
  1073. polkit-wheel-service
  1074. ;; Allow desktop users to also mount NTFS and NFS file systems
  1075. ;; without root.
  1076. (simple-service 'mount-setuid-helpers setuid-program-service-type
  1077. (map (lambda (program)
  1078. (setuid-program
  1079. (program program)))
  1080. (list (file-append nfs-utils "/sbin/mount.nfs")
  1081. (file-append ntfs-3g "/sbin/mount.ntfs-3g"))))
  1082. ;; The global fontconfig cache directory can sometimes contain
  1083. ;; stale entries, possibly referencing fonts that have been GC'd,
  1084. ;; so mount it read-only.
  1085. fontconfig-file-system-service
  1086. ;; NetworkManager and its applet.
  1087. (service network-manager-service-type)
  1088. (service wpa-supplicant-service-type) ;needed by NetworkManager
  1089. (simple-service 'network-manager-applet
  1090. profile-service-type
  1091. (list network-manager-applet))
  1092. (service modem-manager-service-type)
  1093. (service usb-modeswitch-service-type)
  1094. ;; The D-Bus clique.
  1095. (service avahi-service-type)
  1096. (udisks-service)
  1097. (service upower-service-type)
  1098. (accountsservice-service)
  1099. (service cups-pk-helper-service-type)
  1100. (service colord-service-type)
  1101. (geoclue-service)
  1102. (service polkit-service-type)
  1103. (elogind-service)
  1104. (dbus-service)
  1105. (service ntp-service-type)
  1106. x11-socket-directory-service
  1107. (service pulseaudio-service-type)
  1108. (service alsa-service-type)
  1109. %base-services))
  1110. (define-syntax %desktop-services
  1111. (identifier-syntax (desktop-services-for-system)))
  1112. ;;; desktop.scm ends here