desktop.scm 51 KB

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