diff options
| -rw-r--r-- | gnu/services/desktop.scm | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index 0d0f6d949c2..d4a8878bfd3 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm | |||
| @@ -1040,6 +1040,39 @@ screens and scanners."))) | |||
| 1040 | @uref{https://github.com/kmonad/kmonad/blob/master/keymap/tutorial.kbd, KMonad | 1040 | @uref{https://github.com/kmonad/kmonad/blob/master/keymap/tutorial.kbd, KMonad |
| 1041 | - Keymap Tutorial}")) | 1041 | - Keymap Tutorial}")) |
| 1042 | 1042 | ||
| 1043 | ;; Isolate write access to /dev/uinput to prevent privilege escalation for | ||
| 1044 | ;; users/processes that only need read access to the 'input' group. | ||
| 1045 | (define %uinput-group | ||
| 1046 | (user-group | ||
| 1047 | (name "uinput") | ||
| 1048 | (system? #t))) | ||
| 1049 | |||
| 1050 | (define %kmonad-group | ||
| 1051 | (user-group | ||
| 1052 | (name "kmonad") | ||
| 1053 | (system? #t))) | ||
| 1054 | |||
| 1055 | ;; OPTIONS+="static_node=uinput" triggers kmod to load the uinput module on | ||
| 1056 | ;; boot. | ||
| 1057 | (define %kmonad-udev-rule | ||
| 1058 | (udev-rule | ||
| 1059 | "99-kmonad.rules" | ||
| 1060 | "KERNEL==\"uinput\", MODE=\"0660\", GROUP=\"uinput\", OPTIONS+=\"static_node=uinput\"\n")) | ||
| 1061 | |||
| 1062 | (define %kmonad-user | ||
| 1063 | (user-account | ||
| 1064 | (name "kmonad") | ||
| 1065 | (group "kmonad") | ||
| 1066 | (supplementary-groups '("input" "uinput")) | ||
| 1067 | (system? #t) | ||
| 1068 | (comment "KMonad daemon user") | ||
| 1069 | (home-directory "/var/empty") | ||
| 1070 | (create-home-directory? #f) | ||
| 1071 | (shell (file-append shadow "/sbin/nologin")))) | ||
| 1072 | |||
| 1073 | (define %kmonad-accounts | ||
| 1074 | (list %uinput-group %kmonad-group %kmonad-user)) | ||
| 1075 | |||
| 1043 | (define (kmonad-shepherd-services config) | 1076 | (define (kmonad-shepherd-services config) |
| 1044 | "Return a shepherd service for each @command{kmonad} configuration." | 1077 | "Return a shepherd service for each @command{kmonad} configuration." |
| 1045 | (let* ((kmonad (file-append (kmonad-configuration-kmonad config) | 1078 | (let* ((kmonad (file-append (kmonad-configuration-kmonad config) |
| @@ -1054,6 +1087,9 @@ screens and scanners."))) | |||
| 1054 | (number->string index) ".")) | 1087 | (number->string index) ".")) |
| 1055 | (start #~(make-forkexec-constructor | 1088 | (start #~(make-forkexec-constructor |
| 1056 | (list #$kmonad "-l" "info" #$keymap) | 1089 | (list #$kmonad "-l" "info" #$keymap) |
| 1090 | #:user "kmonad" | ||
| 1091 | #:group "kmonad" | ||
| 1092 | #:supplementary-groups '("input" "uinput") | ||
| 1057 | #:log-file #$(string-append "/var/log/" name ".log"))) | 1093 | #:log-file #$(string-append "/var/log/" name ".log"))) |
| 1058 | (stop #~(make-kill-destructor))))) | 1094 | (stop #~(make-kill-destructor))))) |
| 1059 | (iota (length keymaps)) | 1095 | (iota (length keymaps)) |
| @@ -1063,8 +1099,12 @@ screens and scanners."))) | |||
| 1063 | (service-type | 1099 | (service-type |
| 1064 | (name 'kmonad) | 1100 | (name 'kmonad) |
| 1065 | (extensions | 1101 | (extensions |
| 1066 | (list (service-extension shepherd-root-service-type | 1102 | (list (service-extension account-service-type |
| 1067 | kmonad-shepherd-services))) | 1103 | (const %kmonad-accounts)) |
| 1104 | (service-extension shepherd-root-service-type | ||
| 1105 | kmonad-shepherd-services) | ||
| 1106 | (service-extension udev-service-type | ||
| 1107 | (const (list %kmonad-udev-rule))))) | ||
| 1068 | (description "Run the @command{kmonad} daemon, which allows customizing | 1108 | (description "Run the @command{kmonad} daemon, which allows customizing |
| 1069 | and extending the functionalities of different keyboards."))) | 1109 | and extending the functionalities of different keyboards."))) |
| 1070 | 1110 | ||
