(define-module (raingloom machines cloud-deploy-bootstrap)) (use-modules (gnu) (gnu system nss) (guix channels) (guix modules)) (use-service-modules admin networking shepherd ssh) (use-package-modules admin bootloaders certs gnome linux networking ssh tmux tls version-control) (define disk "/dev/vda") (define partition "2") (define ext-autoexpand-service-type (let ((name 'ext-autoexpand) (desc "Automatically expand ext2 root") (modules '((ice-9 popen)))) (shepherd-service-type name (lambda (config) (shepherd-service (documentation desc) (provision (list name)) (requirement '(file-systems)) (one-shot? #t) (start (with-imported-modules (source-module-closure modules) #~(begin (use-modules #$@modules) (let ((port (open-pipe* OPEN_WRITE #$(file-append util-linux "/sbin/sfdisk") ;; don't check if the block is in use ;; it is, and we don't care. "--no-reread" disk "-N" partition))) (display ",+" port) (close-port port)) (system* $#(file-append util-linux "/sbin/partx") "--update" disk) (system* #$(file-append e2fsprogs "/sbin/resize2fs") (string-append disk partition))))))) (description desc)))) (define-public %system (operating-system (host-name "cloud-deploy-bootstrap") (timezone "Europe/Budapest") (locale "en_US.utf8") (keyboard-layout (keyboard-layout "us")) (bootloader (bootloader-configuration (bootloader grub-bootloader) (targets '("/dev/vda")) (keyboard-layout keyboard-layout))) (file-systems (append (list (file-system (device (file-system-label "cloudimg-rootfs")) (mount-point "/") (type "btrfs"))) %base-file-systems)) ;; This is where we specify system-wide packages. (packages (append (list nss-certs tmux) %base-packages)) (services (append (list (service ext-autoexpand-service-type #f) (service dhcp-client-service-type) (service openssh-service-type (openssh-configuration (openssh openssh-sans-x) (permit-root-login #t) (authorized-keys `(("root" ,(local-file (string-append (getenv "HOME") "/.ssh/id_ed25519.pub")))))))) %base-services)) ;; Allow resolution of '.local' host names with mDNS. (name-service-switch %mdns-host-lookup-nss))) %system