operating-systems: buer: Move to impermanence setup

main
Luis Guilherme Coelho 2024-11-03 05:43:37 +01:00
parent ba91125c7e
commit 82cc77b433
No known key found for this signature in database
GPG Key ID: 1F2E76ACE3F531C8
2 changed files with 148 additions and 104 deletions

View File

@ -75,6 +75,8 @@
#:prefix channel:) #:prefix channel:)
#|F|# #:use-module ((buer files) #|F|# #:use-module ((buer files)
#:prefix file:) #:prefix file:)
#|F|# #:use-module ((buer file-systems)
#:prefix file-system:)
#|P|# #:use-module ((buer privilege) #|P|# #:use-module ((buer privilege)
#:prefix privileged-programs:) #:prefix privileged-programs:)
#|R|# #:use-module ((buer rules) #|R|# #:use-module ((buer rules)
@ -104,7 +106,7 @@
(bootloader (bootloader
(bootloader-configuration (bootloader-configuration
(bootloader grub-bootloader) (bootloader grub-bootloader)
(targets `("/dev/sda")) (targets `("/dev/disk/by-id/wwn-0x50026b7785a0a591"))
(theme (grub-theme (theme (grub-theme
(color-normal (color-normal
'((fg . light-gray) (bg . black))) '((fg . light-gray) (bg . black)))
@ -124,15 +126,8 @@
%kicksecure-kernel-arguments))) %kicksecure-kernel-arguments)))
(file-systems (file-systems
(cons* (file-system (append file-system:volumes
(device (file-system-label "guix-root")) file-system:persistent-directories))
(mount-point "/")
(type "ext4"))
(file-system
(device (file-system-label "home"))
(mount-point "/home")
(type "ext4"))
%base-file-systems))
(users (users
(cons* user:radio (cons* user:radio
@ -309,6 +304,11 @@
(service special-files-service-type (service special-files-service-type
`(("/bin/sh" ,(file-append bash "/bin/bash")) `(("/bin/sh" ,(file-append bash "/bin/bash"))
("/usr/bin/env" ,(file-append coreutils "/bin/env")))) ("/usr/bin/env" ,(file-append coreutils "/bin/env"))))
(simple-service 'persistent-files-service
special-files-service-type
(map (juxt identity
(partial string-append "/gnu/persist/"))
file-system:persistent-files))
#|Sysctl services|# #|Sysctl services|#
(simple-service 'extra-sysctl-settings sysctl-service-type (simple-service 'extra-sysctl-settings sysctl-service-type

View File

@ -1,104 +1,148 @@
;; based on https://codeberg.org/squishypinkelephant/guix-random-junk
;; how to guix: / as tmpfs
;; /var/guix is REQUIRED to perform rollbacks
;; create the folders /gnu/persist/etc/ssh /gnu/persist/etc/wireguard and
;; the file /gnu/persist/etc/machine-id for dbus
(define-module (buer file-systems) (define-module (buer file-systems)
#:use-module (gnu system file-systems) #:use-module (gnu system file-systems)
#:export (rootfs #:export (partition:guix
bootfs persistent-directories
file-systems)) persistent-files
volumes))
;;; reminder: Send a patch to guix to make file-system-options and ;;; reminder: Send a patch to guix to make file-system-options and
;;; privileged-program-capabitilities receive a list-of-strings ;;; privileged-program-capabitilities receive a list-of-strings
(define rootfs (define partition:guix
(file-system (file-system-label "guix"))
(device (file-system-label "root"))
(mount-point "/")
(type "tmpfs")
(options "mode=755")))
(define bootfs (define volumes
(list #|base|#
%immutable-store
%pseudo-terminal-file-system
%shared-memory-file-system
#|boot|#
(file-system (file-system
(device (file-system-label "root") (device partition:guix)
(type "btrfs") (type "btrfs")
(mount-point "/boot") (mount-point "/boot")
(dependencies (list rootfs)) (check? #f)
(flags '(no-atime))
(options (format #f "compress=zstd:7,~
discard=async,~
ssd,~
subvol=@boot")))))
(define file-systems
(cons* rootfs
;; /gnu/store
(file-system
(device (file-system-label "root"))
(type "btrfs")
(mount-point "/gnu/store")
(needed-for-boot? #t) (needed-for-boot? #t)
(dependencies (list rootfs)) (flags '(no-atime))
(flags '(read-only bind-mount no-atime)) (options (format #f "subvol=@boot,~
(options (format #f "compress=zstd:7,~
discard=async,~ discard=async,~
ssd,~ ssd")))
subvol=@gnu/store")))
;; /gnu/persist #|run|#
(file-system (file-system
(device (file-system-label "root")) (device "none")
(type "tmpfs")
(mount-point "/run")
(check? #f)
(needed-for-boot? #t)
(options "mode=0755"))
#|tmp|#
(file-system
(device "none")
(type "tmpfs")
(mount-point "/tmp")
(check? #f)
(needed-for-boot? #f))
#|root|#
(file-system
(device "none")
(type "tmpfs")
(mount-point "/")
(check? #f)
(needed-for-boot? #t)
(options "mode=0755"))
#|gnu|#
(file-system
(device partition:guix)
(type "btrfs") (type "btrfs")
(mount-point "/gnu/persist") (mount-point "/gnu/persist")
(needed-for-boot? #t) (needed-for-boot? #t)
(dependencies (list rootfs)) (flags '(no-atime))
(flags '(no-atime bind-mount)) (options (format #f "subvol=@gnu/persist,~
(options (format #f "discard=async,~ ssd")))
ssd,~
subvol=@gnu/persist")))
;; /home
(file-system (file-system
(device (file-system-label "root")) (device partition:guix)
(type "btrfs") (type "btrfs")
(mount-point "/home") (mount-point "/gnu/store")
(dependencies (list rootfs)) (needed-for-boot? #t)
(flags '(no-atime bind-mount)) (flags '(no-atime))
(options (format #f "compress=zstd:7,~ (options (format #f "compress=zstd,~
discard=async,~ subvol=@gnu/store,~
ssd,~ ssd")))
subvol=@home")))
;; /var/guix #|var|#
(file-system (file-system
(device (file-system-label "root")) (device partition:guix)
(type "btrfs") (type "btrfs")
(mount-point "/var/guix") (mount-point "/var/guix")
(dependencies (list rootfs)) (needed-for-boot? #t)
(flags '(no-atime)) (flags '(no-atime))
(options (format #f "compress=zstd:7,~ (options (format #f "compress=zstd,~
discard=async,~ subvol=@var/guix,~
ssd,~ ssd")))
subvol=@var/guix")))
;; /var/log
(file-system (file-system
(device (file-system-label "root")) (device partition:guix)
(type "btrfs")
(mount-point "/var/lib")
(needed-for-boot? #t)
(flags '(no-atime))
(options (format #f "compress=zstd,~
subvol=@var/lib,~
ssd")))
(file-system
(device partition:guix)
(type "btrfs") (type "btrfs")
(mount-point "/var/log") (mount-point "/var/log")
(dependencies (list rootfs)) (check? #f)
(needed-for-boot? #t)
(flags '(no-atime)) (flags '(no-atime))
(options (format #f "compress=zstd:7,~ (options (format #f "compress=zstd,~
discard=async,~ subvol=@var/log,~
ssd,~ ssd")))
subvol=@var/log")))
;; /boot
bootfs
(file-system (file-system
(device (file-system-label "esp")) (device "none")
(type "vfat") (type "tmpfs")
(dependencies (list bootfs)) (mount-point "/var/run")
(mount-point "/boot/efi") (check? #f)
(create-mount-point? #t)) (needed-for-boot? #t)
%base-file-systems)) (options "mode=0755"))
#|home|#
(file-system
(device partition:guix)
(type "btrfs")
(mount-point "/root")
(flags '(no-atime))
(options (format #f "subvol=@root,~
discard=async,~
ssd")))
(file-system
(device partition:guix)
(type "btrfs")
(mount-point "/home")
(flags '(no-atime))
(options (format #f "subvol=@home,~
discard=async,~
ssd")))))
(define persistent-directories
(map (lambda (filename)
(file-system
(mount-point filename)
(device (string-append "/gnu/persist" mount-point))
(type "none")
(flags '(no-atime bind-mount))))
`("/mnt"
"/etc/guix"
"/etc/ssh"
"/etc/wireguard")))
(define persistent-files
(list "/etc/config.scm"
"/etc/machine-id"
"/etc/wpa-supplicant.conf"))