;; This is an operating system configuration generated ;; by the graphical installer. ;; TODO: debug emacs semantic (semantic-parse-region-default (point-min) (point-max) nil nil nil) (define %alpine-system-init #t) (define %alpine-use-nongnu #f) (define nongnu-desktop? (and %alpine-use-nongnu (not %alpine-system-init))) (use-modules (guix utils)) (use-modules (guix packages)) (use-modules (gnu services networking)) (use-modules (gnu) (gnu system nss)) (use-service-modules networking ssh) (use-package-modules bootloaders certs suckless wm) (use-service-modules desktop networking cups ssh xorg avahi mail) (use-package-modules certs gnome cups) (use-modules (gnu packages shells)) (use-modules (gnu packages vim)) (use-modules (gnu)) (use-package-modules screen) ;; other guix (use-modules (gnu system locale)) (use-modules (guix store)) (use-modules (rnrs lists)) (use-modules (srfi srfi-1)) (use-package-modules base idutils) (use-service-modules dns mcron messaging) (define this-config-file (local-file (assoc-ref (current-source-location) 'filename))) ;; (define nm-dnsmasq-file ;; (plain-file "cache.conf" ;; "cache-size=1000\n")) ;; non-guix ;; Import nonfree linux module. (when nongnu-desktop? (use-modules (nongnu packages linux))) (define %alpine-account-uid 1000) (define %alpine-account-user-name "user1") (define %alpine-account-comment "User1") (define %alpine-account-group-name "users") (define %alpine-account-supplementry-groups '("wheel" "netdev" "audio" "video")) (define %alpine-account-home-parent-directory "/home") (define %alpine-account-shell #~(string-append #$zsh "/bin/zsh")) (define %alpine-account-create-home-directory #f) (define %alpine-guix-substitute-urls '("https://ci.guix.gnu.org" "https://bayfront.guixsd.org" "http://guix.genenetwork.org" "https://guix.tobias.gr" "https://ci.guix.info/" "https://berlin.guixsd.org")) (define %alpine-guix-extra-options '( ;; "--max-jobs=2" ;; "--cores=1" "--gc-keep-derivations=yes" "--gc-keep-outputs=yes")) (define %alpine-guix-use-substitutes #t) ;always true (define %alpine-network-manager-dns "dnsmasq") (use-modules (gnu packages linux)) (use-modules (guix modules)) (define (open-nonudev-lvm-device source target) "Return a gexp that maps SOURCES to TARGETS as a LVM device, using 'lvm'." (with-imported-modules (source-module-closure '((gnu build file-systems))) #~(let ((source #$source) (lvm-bin #$(file-append lvm2-static "/sbin/lvm"))) ;; Use 'lvm2-static', not 'lvm2', to avoid pulling the ;; whole world inside the initrd (for when we're in an initrd). (begin (format #t "Enabling ~a~%" #$target) (sleep 1) (system* lvm-bin "vgscan" "--mknodes") (sleep 1) (system* lvm-bin "vgchange" "-ay" (car (string-split #$target #\-))) (sleep 1) (zero? (system* lvm-bin "lvchange" "-aay" "-y" "--sysinit" "--ignoreskippedcluster" (string-join (string-split #$target #\-) "/"))))))) (define (close-nonudev-lvm-device sources target) "Return a gexp that closes TARGET, a LVM device." #~(zero? (system* #$(file-append lvm2-static "/sbin/lvm") "lvchange" "-an" "-y" (string-join (string-split #$target #\-) "/")))) ;; (define* (check-nonudev-lvm-device md #:key ;; needed-for-boot? ;; (initrd-modules '()) ;; #:allow-other-keys ;; #:rest rest) ;; "Ensure the source of MD is valid." ;; (let ((source (mapped-device-source md)) ;; (location (mapped-device-location md))) ;; (or (not (zero? (getuid))) ;; (if (uuid? source) ;; (match (find-partition-by-lvm-uuid (uuid-bytevector source)) ;; (#f ;; (raise (condition ;; (&message ;; (message (format #f (G_ "no LVM partition with UUID '~a'") ;; (uuid->string source)))) ;; (&error-location ;; (location (source-properties->location ;; (mapped-device-location md))))))) ;; ((? string? device) ;; (check-device-initrd-modules device initrd-modules location))) ;; (check-device-initrd-modules source initrd-modules location))))) ;; The type of LVM mapped devices. (define nonudev-lvm-device-mapping (mapped-device-kind (open open-nonudev-lvm-device) ;; (check check-nonudev-lvm-device) (close close-nonudev-lvm-device))) (define (open-udev-lvm-device source target) "Return a gexp that maps SOURCES to TARGETS as a LVM device, using 'lvm'." (with-imported-modules (source-module-closure '((gnu build file-systems))) #~(let ((source #$source) (lvm-bin #$(file-append lvm2-static "/sbin/lvm"))) ;; Use 'lvm2-static', not 'lvm2', to avoid pulling the ;; whole world inside the initrd (for when we're in an initrd). (begin (format #t "Enabling ~a~%" #$target) (system* lvm-bin "vgchange" "-ay" (car (string-split #$target #\-))) (sleep 1) (zero? (system* lvm-bin "lvchange" "-aay" "-y" "--sysinit" "--ignoreskippedcluster" (string-join (string-split #$target #\-) "/"))))))) (define (close-udev-lvm-device sources target) "Return a gexp that closes TARGET, a LVM device." #~(zero? (system* #$(file-append lvm2-static "/sbin/lvm") "lvchange" "-an" "-y" (string-join (string-split #$target #\-) "/")))) ;; (define* (check-udev-lvm-device md #:key ;; needed-for-boot? ;; (initrd-modules '()) ;; #:allow-other-keys ;; #:rest rest) ;; "Ensure the source of MD is valid." ;; (let ((source (mapped-device-source md)) ;; (location (mapped-device-location md))) ;; (or (not (zero? (getuid))) ;; (if (uuid? source) ;; (match (find-partition-by-lvm-uuid (uuid-bytevector source)) ;; (#f ;; (raise (condition ;; (&message ;; (message (format #f (G_ "no LVM partition with UUID '~a'") ;; (uuid->string source)))) ;; (&error-location ;; (location (source-properties->location ;; (mapped-device-location md))))))) ;; ((? string? device) ;; (check-device-initrd-modules device initrd-modules location))) ;; (check-device-initrd-modules source initrd-modules location))))) ;; The type of LVM mapped devices. (define udev-lvm-device-mapping (mapped-device-kind (open open-udev-lvm-device) ;; (check check-udev-lvm-device) (close close-udev-lvm-device))) (define %alpine-mapped-device-guix-root (mapped-device (source "/dev/sda31") (target "guix-root") (type nonudev-lvm-device-mapping))) (define %alpine-mapped-device-guix-boot (mapped-device (source "/dev/sda31") (target "guix-boot") (type nonudev-lvm-device-mapping))) (define %alpine-mapped-device-guix-gnu (mapped-device (source "/dev/sda31") (target "guix-gnu") (type nonudev-lvm-device-mapping))) (define %alpine-mapped-device-guix-swap (mapped-device (source "/dev/sda31") (target "guix-swap") (type nonudev-lvm-device-mapping))) (define %alpine-mapped-device-guix-tmp (mapped-device (source "/dev/sda31") (target "guix-tmp") (type nonudev-lvm-device-mapping))) (define %alpine-mapped-device-guix-var (mapped-device (source "/dev/sda31") (target "guix-var") (type nonudev-lvm-device-mapping))) (define %alpine-mapped-device-vg01-lv01 (mapped-device (source "/dev/test") (target "vg01-lv01") (type udev-lvm-device-mapping))) (define %alpine-mapped-device-vg02-lv01 (mapped-device (source "/dev/test") (target "vg02-lv01") (type udev-lvm-device-mapping))) (define %alpine-mapped-device-vgres01-lvres01 (mapped-device (source "/dev/test") (target "vgres01-lvres01") (type udev-lvm-device-mapping))) (define %alpine-mapped-device-house-home (mapped-device (source "/dev/test") (target "house-home") (type nonudev-lvm-device-mapping))) (define %alpine-mapped-devices (list %alpine-mapped-device-guix-root %alpine-mapped-device-guix-boot %alpine-mapped-device-guix-gnu %alpine-mapped-device-guix-var %alpine-mapped-device-guix-swap %alpine-mapped-device-guix-tmp %alpine-mapped-device-house-home %alpine-mapped-device-house-home %alpine-mapped-device-house-home)) (define %alpine-udev-lvm-mapped-devices (list %alpine-mapped-device-vgres01-lvres01 %alpine-mapped-device-vg01-lv01 %alpine-mapped-device-vg02-lv01)) ;; guix system: error: service 'swap-/dev/mapper/guix-swap' requires 'device-mapping-guix-swap', which is not provided by any service (define %alpine-swap-devices (if #f (list "/dev/mapper/guix-swap") (list))) (define %alpine-file-system-guix-root (file-system (mount-point "/") (device "/dev/mapper/guix-root") (type "ext4") (check? #f) (mount? #t) (create-mount-point? #t) (needed-for-boot? #t) (dependencies %alpine-mapped-devices))) (define %alpine-file-system-guix-boot (file-system (mount-point "/boot") (device "/dev/mapper/guix-boot") (type "ext4") (check? #f) (mount? #t) (create-mount-point? #t) (needed-for-boot? #t) (dependencies (append (list %alpine-file-system-guix-root) %alpine-mapped-devices)))) (define %alpine-file-system-guix-gnu (file-system (mount-point "/gnu") (device "/dev/mapper/guix-gnu") (type "ext4") (check? #f) (mount? #t) (create-mount-point? #t) (needed-for-boot? #t) (dependencies (append (list %alpine-file-system-guix-root) %alpine-mapped-devices)))) (define %alpine-file-system-guix-tmp (file-system (mount-point "/tmp") (device "/dev/mapper/guix-tmp") (type "ext4") (check? #f) (mount? #t) (create-mount-point? #t) (needed-for-boot? #t) (dependencies (append (list %alpine-file-system-guix-root) %alpine-mapped-devices)))) (define %alpine-file-system-guix-var (file-system (mount-point "/var") (device "/dev/mapper/guix-var") (type "ext4") (check? #f) (mount? #t) (create-mount-point? #t) (needed-for-boot? #t) (dependencies (append (list %alpine-file-system-guix-root) %alpine-mapped-devices)))) (define %alpine-file-system-house-home (file-system (mount-point "/home") (device "/dev/mapper/house-home") (type "ext4") (check? #f) (mount? (if %alpine-system-init #f #t)) (create-mount-point? #t) (needed-for-boot? #f) (dependencies (append (list ;; %alpine-file-system-guix-root ) %alpine-mapped-devices)))) (define %alpine-file-system-vg01-lv01 (file-system (mount-point "/srv/volumes/local/vg01/lv01") (device "/dev/mapper/vg01-lv01") (type "ext4") (check? #f) (mount? #f) (create-mount-point? #f) (needed-for-boot? #f) (dependencies (append (list %alpine-file-system-guix-root) %alpine-udev-lvm-mapped-devices)))) (define %alpine-file-system-vg02-lv01 (file-system (mount-point "/srv/volumes/local/vg02/lv01") (device "/dev/mapper/vg02-lv01") (type "ext4") (check? #f) (mount? #f) (create-mount-point? #f) (needed-for-boot? #f) (dependencies (append (list %alpine-file-system-guix-root) %alpine-udev-lvm-mapped-devices)))) (define %alpine-file-system-vgres01-lvres01 (file-system (mount-point "/srv/volumes/local/vgres01/lvres01") (device "/dev/mapper/vgres01-lvres01") (type "reiserfs") (check? #f) (mount? #f) (create-mount-point? #f) (needed-for-boot? #f))) (define %alpine-file-system-boot-efi (file-system (mount-point "/boot/efi") ;; (device (uuid "BAA8-1C0B" 'fat32)) (device "/dev/sda1") (mount? #t) (create-mount-point? #t) (needed-for-boot? #t) (type "vfat") (dependencies (append (list %alpine-file-system-guix-boot %alpine-file-system-guix-root) %alpine-mapped-devices)))) (define %alpine-lvm-mount-home-file-systems (if %alpine-system-init (list) (list %alpine-file-system-house-home))) (define %alpine-lvm-unmount-home-file-systems (if %alpine-system-init (list %alpine-file-system-house-home) (list))) (define %alpine-mount-lvm-system-file-systems (list %alpine-file-system-guix-root ;; %alpine-file-system-guix-swap %alpine-file-system-guix-boot %alpine-file-system-guix-gnu %alpine-file-system-guix-tmp %alpine-file-system-guix-var)) (define %alpine-unmount-lvm-system-file-systems (list)) (define %alpine-mount-lvm-non-system-file-systems (list %alpine-file-system-vg01-lv01 ;; %alpine-file-system-vg02-lv01 %alpine-file-system-vgres01-lvres01)) (define %alpine-unmount-lvm-non-system-file-systems (list %alpine-file-system-vg02-lv01)) (define %alpine-lvm-system-file-systems (append %alpine-mount-lvm-system-file-systems %alpine-unmount-lvm-system-file-systems %alpine-lvm-mount-home-file-systems %alpine-lvm-unmount-home-file-systems %alpine-mount-lvm-non-system-file-systems %alpine-unmount-lvm-non-system-file-systems)) (define %alpine-lvm-file-systems (append %alpine-lvm-system-file-systems)) (define %alpine-other-file-systems (list %alpine-file-system-boot-efi)) (define %alpine-file-systems (append %alpine-lvm-file-systems %alpine-other-file-systems %base-file-systems)) ;; packages (if (not %alpine-system-init) (load "packages.scm")) (define %alpine-packages (if %alpine-system-init (cons* nss-certs lvm2 vim zsh %base-packages) %alpine-reinit-packages)) (define %alpine-keyboard-layout (keyboard-layout "us" "altgr-intl")) ;; https://www.hubert-lombard.website/GuixSD/html/GuixSD-0.16_en-Dual-Boot-avec-Debian-Testing.html (define %alpine-grub-other-menuentries '(menu-entries (list (menu-entry (label "Debian GNU/Linux") (linux "/boot/vmlinuz-4.19.0-1-amd64") (linux-arguments '("root=/dev/sda1")) (initrd "/boot/initrd.img-4.19.0-1-amd64"))))) (define %alpine-vm-bootloader (bootloader-configuration (bootloader grub-bootloader) (target "/dev/vda"))) (define %alpine-efi-bootloader (bootloader-configuration (bootloader grub-efi-bootloader) (target "/boot/efi") (keyboard-layout %alpine-keyboard-layout))) (define %alpine-nonefi-bootloader (bootloader-configuration (bootloader grub-bootloader) (target "/dev/sda") (keyboard-layout %alpine-keyboard-layout))) (define %alpine-vm-initrd (lambda (file-systems . rest) (apply base-initrd file-systems #:extra-modules '("virtio.ko" "virtio_balloon.ko" "virtio_ring.ko" "virtio_blk.ko" "virtio_pci.ko" "virtio_net.ko") rest))) (define %alpine-metal-initrd base-initrd) (define %alpine-simple-users (list (user-account (uid %alpine-account-uid) (name %alpine-account-user-name) (comment %alpine-account-comment) (group %alpine-account-group-name) (home-directory (string-append %alpine-account-home-parent-directory "/" %alpine-account-user-name)) (shell %alpine-account-shell) (supplementary-groups %alpine-account-supplementry-groups) (create-home-directory? %alpine-account-create-home-directory)) (user-account (uid 1002) (name "j") (comment "Jam") (group %alpine-account-group-name) (home-directory (string-append %alpine-account-home-parent-directory "/" "j")) (supplementary-groups %alpine-account-supplementry-groups) (create-home-directory? %alpine-account-create-home-directory)))) (define %alpine-users (append %alpine-simple-users %base-user-accounts)) (define %alpine-copy-current-config-file-in-etc (list (simple-service 'config-file etc-service-type ;; https://willschenk.com/articles/2019/installing_guix_on_nuc/ ;; Copy current config to /etc/config.scm (append (list `("config/config.scm" ,this-config-file)) ;; ("dnsmasq.d/cache.conf" ,nm-dnsmasq-file) (if (not %alpine-system-init) (list `("config/package.scm" ,this-package-file)) (list)))))) (define (remove-services types services) (remove! (lambda (service) (any (lambda (type) (eq? (service-kind service) type)) types)) services)) ;; Vixie cron schedular (define updatedb-job ;; Run 'updatedb' at 3AM every day. Here we write the ;; job's action as a Scheme procedure. #~(job '(next-hour '(3)) (lambda () (execl (string-append #$findutils "/bin/updatedb") ;; "updatedb" "--prunepaths=`/tmp /var/tmp /gnu/store /run'")))) (define garbage-collector-job ;; Collect garbage 5 minutes after midnight every day. ;; The job's action is a shell command. #~(job "5 0 * * *" ;Vixie cron syntax "guix gc -F 1G")) (define idutils-job ;; Update the index database as user "charlie" at 12:15PM ;; and 19:15PM. This runs from the user's home directory. #~(job '(next-minute-from (next-hour '(12 19)) '(15)) (string-append #$idutils "/bin/mkid src") #:user "s")) ;; https://guix.gnu.org/manual/en/html_node/Scheduled-Job-Execution.html (define %alpine-mcron-services (list (service mcron-service-type (mcron-configuration (jobs (list garbage-collector-job ;; idutils-job updatedb-job)))))) (define %alpine-bitlbee-services (list (service bitlbee-service-type))) ;; https://guix.gnu.org/manual/en/html_node/Mail-Services.html (define %alpine-mail-aliases-services (list (service mail-aliases-service-type '(("postmaster" "bob") ("bob" "bob@example.com" "bob@example2.com"))))) ;; https://lists.nongnu.org/archive/html/help-guix/2016-08/msg00061.html ;; https://wingolog.org/pub/alt-os-config.scm (define %alpine-dovecot-services (list (dovecot-service #:config (dovecot-configuration (mail-location "maildir:~/.maildir") (listen '("127.0.0.1")))))) (define %alpine-exim-services (list (service exim-service-type (exim-configuration (config-file #f))))) ;; https://notabug.org/thomassgn/guixsd-configuration/src/master/config.scm ;; https://guix.gnu.org/manual/en/html_node/Networking-Services.html ;; https://jonathansblog.co.uk/using-dnsmasq-as-an-internal-dns-server-to-block-online-adverts ;; https://stackoverflow.com/questions/48644841/multiple-addn-hosts-conf-in-dnsmasq (define %alpine-dnsmasq-services (list (service dnsmasq-service-type (dnsmasq-configuration (no-resolv? #t) ;; (resolv-file) ;; (no-resolv? #f) ;; (servers '("82.196.9.45" ;; "51.255.48.78" ;; "51.15.98.97")) (local-service? #t))))) ;; https://guix.gnu.org/manual/en/html_node/Networking-Services.html (define %alpine-network-manager-services (list (service network-manager-service-type (network-manager-configuration (dns %alpine-network-manager-dns))))) (define %alpine-avahi-services (list (service avahi-service-type))) (define %alpine-gpm-services (list (service gpm-service-type))) ;; https://github.com/alezost/guix-config/blob/master/system-config/os-main.scm (define %alpine-mingetty-services (list (service mingetty-service-type (mingetty-configuration (tty "tty1"))) (service mingetty-service-type (mingetty-configuration (tty "tty2"))) (service mingetty-service-type (mingetty-configuration (tty "tty3"))) (service mingetty-service-type (mingetty-configuration (tty "tty4"))) (service mingetty-service-type (mingetty-configuration (tty "tty5"))) (service mingetty-service-type (mingetty-configuration (tty "tty6"))))) (define %alpine-cups-services (list (service cups-service-type (cups-configuration (web-interface? #t) (default-paper-size "A4") (extensions (list cups-filters hplip-minimal)))))) ;; https://github.com/alezost/guix-config/blob/master/system-config/os-main.scm ;; (define %alpine-polkit-services (list (service polkit-service-type))) (define %alpine-polkit-services (list )) (define %alpine-desktop-nm-services (modify-services %desktop-services (network-manager-service-type config => (network-manager-configuration (inherit config) ;; (vpn-plugins '("network-manager-openconnect")) (dns "dnsmasq"))) ;; https://gitlab.com/Efraim/guix-config/blob/master/macbook41_config.scm (guix-service-type config => (guix-configuration (inherit config) ;; (use-substitutes? %alpine-guix-use-substitutes) ;; (authorized-keys '()) (substitute-urls (append %alpine-guix-substitute-urls %default-substitute-urls)) (extra-options %alpine-guix-extra-options))))) ;; https://issues.guix.info/issue/35674 (when #t (set! %alpine-desktop-nm-services (modify-services %alpine-desktop-nm-services (gdm-service-type config => (gdm-configuration (inherit config) (xorg-configuration (xorg-configuration (keyboard-layout %alpine-keyboard-layout))) ;; (allow-empty-passwords? #t) (auto-login? #f) (default-user %alpine-account-user-name)))))) (define %alpine-desktop-services %alpine-desktop-nm-services) (define %alpine-network-services (list (service openssh-service-type) (service tor-service-type))) (define %alpine-heavy-wm-services (list (service gnome-desktop-service-type) (service xfce-desktop-service-type) (service mate-desktop-service-type) (service enlightenment-desktop-service-type))) (define %alpine-many-services (append %alpine-network-services %alpine-heavy-wm-services)) (define %alpine-few-services (append %alpine-network-services)) (define %alpine-simple-services %alpine-few-services) (define %alpine-simple-and-desktop-services (append %alpine-simple-services %alpine-mail-aliases-services %alpine-dovecot-services %alpine-gpm-services %alpine-mcron-services %alpine-cups-services %alpine-polkit-services %alpine-desktop-services)) (define %alpine-base-with-dhcp-services (append (list (service dhcp-client-service-type) (service openssh-service-type (openssh-configuration (port-number 2222)))) %base-services)) (define %alpine-base-services %base-services) (define %alpine-final-services (if %alpine-system-init %alpine-base-with-dhcp-services %alpine-simple-and-desktop-services)) (define %alpine-services (append %alpine-copy-current-config-file-in-etc %alpine-final-services)) (define %alpine-firmware (if nongnu-desktop? (list linux-firmware) %base-firmware)) ;; https://github.com/alezost/guix-config/blob/master/system-config/os-main.scm (define %alpine-locale "en_US.utf8") (define %alpine-locate-names (list "en_US" "hi_IN" "ur_PK" "fa_IR" "ar_SA")) (define %alpine-all-locale-definitions (map (lambda (locale) (locale-definition (source locale) (name (string-append locale "." "utf8")))) %alpine-locate-names)) (define %alpine-locale-definitions (append %alpine-all-locale-definitions %default-locale-definitions)) (define %alpine-timezone "Asia/Kolkata") ;; (define %alpine-host-name "komputilo") (define %alpine-host-name "guilem") (define %alpine-bootloader %alpine-efi-bootloader) (define %alpine-initrd %alpine-metal-initrd) ;; (define %alpine-setuid-programs %setuid-programs) (define %alpine-setuid-programs (cons* #~(string-append #$ecryptfs-utils "/sbin/mount.ecryptfs_private") %setuid-programs)) (define %alpine-kernel (if nongnu-desktop? linux linux-libre)) (operating-system (kernel %alpine-kernel) (firmware %alpine-firmware) (initrd %alpine-initrd) (locale %alpine-locale) (locale-definitions %alpine-locale-definitions) (timezone %alpine-timezone) (keyboard-layout %alpine-keyboard-layout) (host-name %alpine-host-name) (setuid-programs %alpine-setuid-programs) (mapped-devices %alpine-mapped-devices) (users %alpine-users) (file-systems %alpine-file-systems) (swap-devices %alpine-swap-devices) (bootloader %alpine-bootloader) (packages %alpine-packages) (services %alpine-services) ;; Allow resolution of '.local' host names with mDNS. (name-service-switch %mdns-host-lookup-nss)) ;; TO SEE host-file ;; https://guix.gnu.org/manual/en/html_node/Networking-Services.html