services.scm (6835B)
1 (define-module (mt services) 2 #:use-module (srfi srfi-1) 3 #:use-module (guix gexp) 4 #:use-module (gnu packages admin) 5 #:use-module (gnu packages libusb) 6 #:use-module (gnu packages linux) 7 #:use-module (gnu packages nfs) 8 #:use-module (gnu services) 9 #:use-module (gnu services avahi) 10 #:use-module (gnu services base) 11 #:use-module (gnu services dbus) 12 #:use-module (gnu services desktop) 13 #:use-module (gnu services networking) 14 #:use-module (gnu services sound) 15 #:use-module (gnu services ssh) 16 #:use-module (gnu system) 17 #:use-module (gnu system privilege) 18 #:use-module (mt channels) 19 #:use-module (mt channels-locked) 20 #:export (etc-mt-client-service 21 tuigreet-login-manager 22 greetd-helper-service 23 mt-base-services 24 %mt-bishop-services 25 %mt-clergy-services 26 %mt-laity-services 27 %mt-desktop-services)) 28 29 (define (etc-mt-client-service client) 30 (simple-service 'etc-mt-client 31 etc-service-type 32 (list 33 `("mt-client" 34 ,(plain-file "mt-client" client))))) 35 36 ;; Generate a login manager script based on tuigreet 37 (define* (tuigreet-login-manager 38 #:key (args '("--time" 39 "--user-menu" 40 "--window-padding" "1" 41 "--asterisks" 42 "--remember" 43 "--remember-user-session")) 44 ;; TODO: Fix atrocious light mode 45 (colors (list "FFFCF0" "F2F0E5" 46 "AF3029" "D14D41" 47 "66800B" "879A39" 48 "AD8301" "D0A215" 49 "205EA6" "4385BE" 50 "A02F6F" "CE5D97" 51 "24837B" "3AA99F" 52 "100F0F" "6F6E69"))) 53 (let ((tuigreet-bin (file-append tuigreet "/bin/tuigreet")) 54 (setfont-bin (file-append kbd "/bin/setfont")) 55 (color-codes (list "P0" "P8" "P1" "P9" "P2" "PA" "P3" "PB" 56 "P4" "PC" "P5" "PD" "P6" "PE" "P7" "PF"))) 57 (program-file 58 "tuigreet-wrapper" 59 #~(begin 60 ;; TODO: Take font as argument 61 (system* #$setfont-bin "-d" "alt-8x8") 62 ;; Set TTY colors 63 (for-each (lambda (color-code color) 64 (display #\esc) 65 (display "]") 66 (display color-code) 67 (display color)) 68 '#$color-codes 69 '#$colors) 70 ;; Switch current process to tuigreet 71 (execl #$tuigreet-bin #$tuigreet-bin 72 #$@args))))) 73 74 75 ;; Generate a greetd service 76 (define* (greetd-helper-service #:key (login-manager (tuigreet-login-manager))) 77 (service greetd-service-type 78 (greetd-configuration 79 (terminals 80 (list 81 (greetd-terminal-configuration (terminal-vt "1")) 82 (greetd-terminal-configuration (terminal-vt "2")) 83 (greetd-terminal-configuration (terminal-vt "3")) 84 (greetd-terminal-configuration (terminal-vt "4")) 85 (greetd-terminal-configuration (terminal-vt "5")) 86 (greetd-terminal-configuration (terminal-vt "6")) 87 (greetd-terminal-configuration 88 (terminal-vt "7") 89 (terminal-switch #t) 90 (default-session-command login-manager))))))) 91 92 (define* (mt-base-services #:key (discover? #f) 93 (sans-mt-substitutes? #f)) 94 (append 95 (list 96 (service openssh-service-type 97 (openssh-configuration 98 (password-authentication? #f)))) 99 (modify-services %base-services 100 (guix-service-type 101 config => (guix-configuration 102 (inherit config) 103 (channels %mt-channels-locked) 104 (discover? discover?) 105 (substitute-urls (if sans-mt-substitutes? 106 (cdr %mt-substitute-urls) 107 %mt-substitute-urls)) 108 (authorized-keys (if sans-mt-substitutes? 109 (cdr %mt-authorized-guix-keys) 110 %mt-authorized-guix-keys)))) 111 (delete login-service-type) 112 (delete agetty-service-type) 113 (delete mingetty-service-type) 114 (delete console-font-service-type)))) 115 116 ;; Provide substitutes for all machines and perform build farm capabilities 117 ;; TODO: Add anti-spam measures 118 ;; TODO: Add build farm capabilities 119 ;; TODO: 120 (define %mt-bishop-services 121 (append 122 (list 123 ;; Serial support 124 (service agetty-service-type (agetty-configuration (tty #f))) 125 ;; Ethernet-only internet 126 (service dhcpcd-service-type) 127 ;; Required by guix-publish 128 (service avahi-service-type) 129 ;; Host a substitute server on locahost. 130 ;; Each server should ideally serve this from a subdomain. 131 (service guix-publish-service-type 132 (guix-publish-configuration 133 (port 8080)))) 134 (mt-base-services #:sans-mt-substitutes? #t))) 135 136 (define %mt-clergy-services 137 (append 138 (list 139 ;; Host a local substitute server 140 (service guix-publish-service-type 141 (guix-publish-configuration 142 (host "0.0.0.0") 143 (advertise? #t)))) 144 (mt-base-services))) 145 146 (define %mt-laity-services 147 (mt-base-services #:discover? #t)) 148 149 ;; These are basic services that will generally be used by all user systems. It 150 ;; should contain everything necessary to begin building a basic desktop setup. 151 ;; Essentially, these are all the "standard" services that you wouldn't need on 152 ;; a server. 153 ;; TODO: Add printer-related services 154 (define %mt-desktop-services 155 (list 156 ;; Essential 157 (service dbus-root-service-type) 158 (service elogind-service-type) 159 (service polkit-service-type) 160 polkit-wheel-service 161 (service avahi-service-type) ;; Used by guix-daemon 162 (service ntp-service-type) 163 164 ;; Complimentary 165 fontconfig-file-system-service 166 (service udisks-service-type) 167 (service upower-service-type) ;; TODO: Make optional 168 169 ;; Networking 170 (service network-manager-service-type) 171 (service wpa-supplicant-service-type) 172 (service usb-modeswitch-service-type) 173 174 ;; Audio 175 (service pulseaudio-service-type) 176 (service alsa-service-type))) 177 178 ;; TODO: Create automatic update services 179 ;; This would be for laity and clergy machines. It would basically check for 180 ;; configuration / channel updates daily and notify users that updates are 181 ;; available. They will not be forced to update. It would also prompt monthly to 182 ;; perform a guix update.