This commit is contained in:
Daniel Ziltener 2023-12-01 14:22:33 +01:00
parent a634bd358a
commit 08b8d54061
Signed by: zilti
GPG Key ID: B38976E82C9DAE42
4 changed files with 297 additions and 67 deletions

View File

@ -1,20 +1,38 @@
#+TITLE: GUIX System Configuration #+TITLE: GUIX System Configuration
#+AUTHOR: Daniel Ziltener
#+PROPERTY: header-args:scheme :comments both
#+begin_src emacs-lisp :results none
(org-babel-lob-ingest "./library.org")
#+end_src
* Modules * Modules
#+NAME: module-list #+NAME: module-list
- gnu - gnu
- gnu services avahi
- gnu services base - gnu services base
- gnu services dbus
- gnu services desktop - gnu services desktop
- gnu services linux
- gnu services networking - gnu services networking
- gnu services pm - gnu services pm
- gnu services virtualization
- gnu services xorg
- gnu system nss - gnu system nss
#+begin_src scheme :noweb yes :exports none :results code :tangle config.scm
<<list-to-use(use-call="use-modules",entries=module-list)>>
#+end_src
** Service Modules ** Service Modules
#+NAME: service-module-list #+NAME: service-module-list
- desktop - desktop
- xorg
#+begin_src scheme :noweb yes :exports none :results code :tangle config.scm
<<list-to-use(use-call="use-service-modules",entries=service-module-list)>>
#+end_src
** Package Modules ** Package Modules
@ -22,7 +40,174 @@
- bootloaders - bootloaders
- certs - certs
- emacs - emacs
- swayfx - emacs-xyz
- fonts
- readline
- terminals
- version-control
- wm - wm
- xorg - xorg
#+begin_src scheme :noweb yes :exports none :results code :tangle config.scm
<<list-to-use(use-call="use-package-modules",entries=package-module-list)>>
#+end_src
* Configuration Definitions
** File System
The variable ~%local-filesystem~ extracts the file system definitions from the installer-provided
=config.scm= file.
#+begin_src scheme :tangle config.scm
(define %local-filesystem
(call-with-input-file "/etc/config.scm"
(lambda (port)
(read port)
(read port)
(eval (cadar (last-pair (read port)))
(interaction-environment)))))
#+end_src
As a sibling to the former, the variable ~%local-swap~ does the same with the swap partition.
#+begin_src scheme :tangle config.scm
(define %local-swap
(call-with-input-file "/etc/config.scm"
(lambda (port)
(read port)
(read port)
(let* ((os-list (read port))
(os-list-length (length os-list)))
(eval
(cdr
(list-ref os-list
(- os-list-length 2)))
(interaction-environment))))))
#+end_src
** Packages
#+NAME: root-packages
- emacs
- emacs-desktop-environment
- font-terminus
- git
- nss-certs
- readline
- swayfx
#+NAME: root-package-block
#+begin_src scheme :noweb no-export
(packages
(append
<<org-to-scheme-sym-list(input=root-packages)>>
%base-packages))
#+end_src
** Services
#+NAME: root-services-block
#+begin_src scheme :noweb yes :exports none :results code
(services
(append
(modify-services
%desktop-services
(delete login-service-type)
(delete mingetty-service-type)
(delete console-font-service-type))
<<root-simple-service-block>>
<<greeter-service>>
<<screen-lock-service>>
))
#+end_src
*** Simple Services
These services are unmodified, or have just few settings.
#+NAME: root-simple-services
| Service | Options |
|-------------+------------------------------------------------------|
| tlp | () |
| thermald | ((adaptive? t)) |
| bluetooth | () |
| earlyoom | ((minimum-available-memory 5) (minimum-free-swap 5)) |
| inputattach | () |
| libvirt | ((unix-sock-group "libvirt")) |
| fstrim | () |
| fprintd | () |
#+NAME: root-simple-service-block
#+begin_src scheme :noweb yes :exports none :results code
<<service-converter(input=root-simple-services)>>
#+end_src
*** Greeter Service
=greetd= is a broken mess, yet here we are.
#+NAME: greeter-service
#+begin_src scheme
(service greetd-service-type
(greetd-configuration
(greeter-supplementary-groups
(list "video" "input"))
(terminals
(list
(greetd-terminal-configuration
(terminal-vt "7")
(terminal-switch #t)
(default-session-command
(greetd-wlgreet-session
(command
(file-append swayfx "/bin/sway")))))
(greetd-terminal-configuration
(terminal-vt "8"))))))
#+end_src
*** Screen Locker Service
For some reason, this service runs on root level for Guix.
#+NAME: screen-lock-service
#+begin_src scheme
(service screen-locker-service-type
(screen-locker-configuration
(name "swaylock")
(program
(file-append swaylock-effects "/bin/swaylock"))
(using-setuid? #f)))
#+end_src
* Operating System
This is the full operating system specification.
#+begin_src scheme :noweb no-export :results code :tangle config.scm
(operating-system
(host-name "ziltis-machine")
(timezone "Europe/Berlin")
(locale "de_DE.utf8")
(keyboard-layout
(keyboard-layout "de" #:options '("caps:swapescape")))
(bootloader
(bootloader-configuration
(bootloader grup-efi-bootloader)
(targets
'("/boot/efi"))
(keyboard-layout keyboard-layout)))
(file-systems %local-filesystem)
(swap-devices %local-swap)
(users
(cons*
(user-account
(name "zilti")
(group "users")
(supplementary-groups
'("wheel" "netdev" "audio" "video" "libvirt")))
%base-user-accounts))
<<root-package-block>>
<<root-services-block>>
(name-service-switch %mdns-host-lookup-nss))
#+end_src

View File

@ -1,10 +1,5 @@
;; -*- mode: guix-scheme -*-
(use-modules (use-modules
(gnu) (gnu)
(gnu image)
(gnu services authentication)
(gnu services avahi)
(gnu services base) (gnu services base)
(gnu services dbus) (gnu services dbus)
(gnu services desktop) (gnu services desktop)
@ -15,19 +10,21 @@
(gnu services xorg) (gnu services xorg)
(gnu system nss)) (gnu system nss))
(use-service-modules desktop (use-service-modules
xorg) (desktop)
(xorg))
(use-package-modules bootloaders (use-package-modules
certs (bootloaders)
emacs (certs)
emacs-xyz (emacs)
fonts (emacs-xyz)
readline (fonts)
terminals (readline)
version-control (terminals)
wm (version-control)
xorg) (wm)
(xorg))
(define %local-filesystem (define %local-filesystem
(call-with-input-file "/etc/config.scm" (call-with-input-file "/etc/config.scm"
@ -37,47 +34,45 @@
(eval (cadar (last-pair (read port))) (eval (cadar (last-pair (read port)))
(interaction-environment))))) (interaction-environment)))))
(define %local-swap
(call-with-input-file "/etc/config.scm"
(lambda (port)
(read port)
(read port)
(let* ((os-list (read port))
(os-list-length (length os-list)))
(eval
(cdr
(list-ref os-list
(- os-list-length 2)))
(interaction-environment))))))
(operating-system (operating-system
(host-name "ziltis-machine") (host-name "ziltis-machine")
(timezone "Europe/Berlin") (timezone "Europe/Berlin")
(locale "de_DE.utf8") (locale "de_DE.utf8")
(keyboard-layout (keyboard-layout
(keyboard-layout "de" #:options (keyboard-layout "de" #:options '("caps:swapescape")))
'("caps:swapescape")))
(bootloader (bootloader
(bootloader-configuration (bootloader-configuration
(bootloader grub-efi-bootloader) (bootloader grup-efi-bootloader)
(targets (targets
'("/boot/efi")) '("/boot/efi"))
(keyboard-layout keyboard-layout))) (keyboard-layout keyboard-layout)))
(file-systems %local-filesystem) (file-systems %local-filesystem)
(swap-devices (swap-devices %local-swap)
(list
(swap-space
(target "/dev/disk/by-partlabel/swap")
(discard? #t))))
(users (users
(cons* (cons*
(user-account (user-account
(name "zilti") (name "zilti")
(group "users") (group "users")
(supplementary-groups (supplementary-groups
'("wheel" '("wheel" "netdev" "audio" "video" "libvirt")))
"netdev"
"audio"
"video"
"libvirt")))
%base-user-accounts)) %base-user-accounts))
(packages (packages
(append (append
(list (list emacs emacs-desktop-environment font-terminus git nss-certs readline swayfx)
nss-certs
readline
emacs
emacs-desktop-environment
font-terminus
git
swayfx)
%base-packages)) %base-packages))
(services (services
(append (append
@ -87,17 +82,27 @@
(delete mingetty-service-type) (delete mingetty-service-type)
(delete console-font-service-type)) (delete console-font-service-type))
(list (list
(service tlp-service-type) (tlp-service-type
(service thermald-service-type (tlp-configuration))
(thermald-service-type
(thermald-configuration (thermald-configuration
(adaptive? #t))) (adaptive? t)))
(service bluetooth-service-type) (bluetooth-service-type
(service inputattach-service-type) (bluetooth-configuration))
(service fstrim-service-type) (earlyoom-service-type
(service earlyoom-service-type
(earlyoom-configuration (earlyoom-configuration
(minimum-available-memory 5) (minimum-available-memory 5)
(minimum-free-swap 5))) (minimum-free-swap 5)))
(inputattach-service-type
(inputattach-configuration))
(libvirt-service-type
(libvirt-configuration
(unix-sock-group "libvirt")))
(fstrim-service-type
(fstrim-configuration))
(fprintd-service-type
(fprintd-configuration)))
(service greetd-service-type (service greetd-service-type
(greetd-configuration (greetd-configuration
(greeter-supplementary-groups (greeter-supplementary-groups
@ -113,14 +118,11 @@
(file-append swayfx "/bin/sway"))))) (file-append swayfx "/bin/sway")))))
(greetd-terminal-configuration (greetd-terminal-configuration
(terminal-vt "8")))))) (terminal-vt "8"))))))
(service fprintd-service-type)
(service screen-locker-service-type (service screen-locker-service-type
(screen-locker-configuration (screen-locker-configuration
(name "swaylock") (name "swaylock")
(program (program
(file-append swaylock-effects "/bin/swaylock")) (file-append swaylock-effects "/bin/swaylock"))
(using-setuid? #f))) (using-setuid? #f)))
(service libvirt-service-type ))
(libvirt-configuration
(unix-sock-group "libvirt"))))))
(name-service-switch %mdns-host-lookup-nss)) (name-service-switch %mdns-host-lookup-nss))

View File

@ -30,6 +30,7 @@
(packages (packages
(specifications->packages (specifications->packages
(list "chicken" (list "chicken"
"fuzzel"
"icecat" "icecat"
"kitty" "kitty"
"pinentry-qt" "pinentry-qt"
@ -101,7 +102,10 @@
(list (list
(channel (channel
(name 'ziltis-channel) (name 'ziltis-channel)
(url "https://gitea.lyrion.ch/zilti/guixchannel.git")))) (url "https://gitea.lyrion.ch/zilti/guixchannel"))
(channel
(name 'nongnu-guix)
(url "https://gitlab.com/nonguix/nonguix"))))
(service home-openssh-service-type (service home-openssh-service-type
(home-openssh-configuration (home-openssh-configuration
(hosts (hosts

39
library.org Normal file
View File

@ -0,0 +1,39 @@
#+TITLE: Babel Library
This library contains code blocks to be used by other files in this repository.
* Converting Lists
Converting org lists into guix ~use-~ calls.
#+NAME: list-to-use
#+begin_src emacs-lisp :var use-call="use-modules" :var entries='() :results code
`(,(make-symbol use-call)
,@(mapcar (lambda (x)
(mapcar (lambda (y) (make-symbol y))
(split-string x)))
entries))
#+end_src
Converting Org lists into Scheme symbol lists.
#+NAME: org-to-scheme-sym-list
#+begin_src emacs-lisp :var input='() :results code
`(list
,@(mapcar (lambda (x) (make-symbol x)) input))
#+end_src
* Converting Tables
#+NAME: service-converter
#+begin_src emacs-lisp :var input='() :colnames yes :results code
`(list
,@(mapcar
(lambda (row)
(let ((service-name (cl-first row))
(configuration (cl-second row)))
`(,(make-symbol (s-concat service-name "-service-type"))
(,(make-symbol (s-concat service-name "-configuration"))
,@(car (read-from-string configuration))))))
input))
#+end_src