diff options
author | Franz Geffke <franz@pantherx.org> | 2023-11-06 20:08:14 +0000 |
---|---|---|
committer | Franz Geffke <franz@pantherx.org> | 2023-11-06 20:08:14 +0000 |
commit | 47b4c9c854915df93893dbaa993accfacf9027fe (patch) | |
tree | 4f9b1742d63fcfbc94cc6b8d84f76c4d00c3a0b7 /px/services/disk.scm | |
parent | 0b426d7b7ed8e176bf464ef9e0683f74a6c9d20f (diff) |
rewrite: apply guix-reference formatting; cleanup some module imports
Diffstat (limited to 'px/services/disk.scm')
-rw-r--r-- | px/services/disk.scm | 111 |
1 files changed, 67 insertions, 44 deletions
diff --git a/px/services/disk.scm b/px/services/disk.scm index ca10546..abbd7cb 100644 --- a/px/services/disk.scm +++ b/px/services/disk.scm @@ -25,7 +25,6 @@ #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (create-swap-space-service - disk-init-configuration disk-init-service-type)) @@ -35,29 +34,35 @@ ;; (define (create-swap-space-service size) - (simple-service 'create-swap-space - activation-service-type + (simple-service 'create-swap-space activation-service-type (with-imported-modules '((guix build utils)) - #~(begin - (use-modules (guix build utils)) - (let ((swapfile "/swapfile")) - (when (not (file-exists? swapfile)) - (invoke #+(file-append util-linux "/bin/fallocate") "-l" #$size swapfile) - (chmod swapfile #o600) - (invoke #+(file-append util-linux "/sbin/mkswap") swapfile) - )))))) + #~(begin + (use-modules (guix build utils)) + (let ((swapfile "/swapfile")) + (when (not (file-exists? + swapfile)) + (invoke #+(file-append + util-linux + "/bin/fallocate") + "-l" + #$size swapfile) + (chmod swapfile #o600) + (invoke #+(file-append + util-linux + "/sbin/mkswap") + swapfile))))))) ;; ;; Disk initiation service ;; primarily for ARM ;; -(define-record-type* <disk-init-configuration> - disk-init-configuration make-disk-init-configuration +(define-record-type* <disk-init-configuration> disk-init-configuration + make-disk-init-configuration disk-init-configuration? - (device disk-init-configuration-device) - (index disk-init-configuration-index) - (target disk-init-configuration-target) + (device disk-init-configuration-device) + (index disk-init-configuration-index) + (target disk-init-configuration-target) (swap-size disk-init-configuration-swap-size (default #f)) (swap-path disk-init-configuration-swap-path @@ -65,35 +70,53 @@ (define disk-init-activation (match-lambda - (($ <disk-init-configuration> device index target swap-size swap-path) + (($ <disk-init-configuration> + device + index + target + swap-size + swap-path) (with-imported-modules '((guix build utils)) - #~(begin - (use-modules (guix build utils)) - (let ((lock-file "/etc/disk-init.lock")) - (when (not (file-exists? lock-file)) - ;; resize root partition - ;; workaround to fix growpart execution - (setenv "PATH" (string-append "/run/current-system/profile/bin:" (getenv "PATH"))) - (invoke #+(file-append cloud-utils "/bin/growpart") #$device #$index) - (invoke #+(file-append e2fsprogs "/sbin/resize2fs") #$target) - (invoke #+(file-append coreutils "/bin/sync")) + #~(begin + (use-modules (guix build utils)) + (let ((lock-file "/etc/disk-init.lock")) + (when (not (file-exists? lock-file)) + ;; resize root partition + ;; workaround to fix growpart execution + (setenv "PATH" + (string-append + "/run/current-system/profile/bin:" + (getenv "PATH"))) + (invoke #+(file-append cloud-utils + "/bin/growpart") + #$device + #$index) + (invoke #+(file-append e2fsprogs + "/sbin/resize2fs") + #$target) + (invoke #+(file-append coreutils + "/bin/sync")) + + ;; create swap-file + (when (and #$swap-size + (not (file-exists? #$swap-path))) + (invoke #+(file-append util-linux + "/bin/fallocate") + "-l" + #$swap-size + #$swap-path) + (chmod #$swap-path #o600) + (invoke #+(file-append util-linux + "/sbin/mkswap") + #$swap-path)) - ;; create swap-file - (when (and #$swap-size - (not (file-exists? #$swap-path))) - (invoke #+(file-append util-linux "/bin/fallocate") - "-l" #$swap-size #$swap-path) - (chmod #$swap-path #o600) - (invoke #+(file-append util-linux "/sbin/mkswap") #$swap-path)) - - (call-with-output-file lock-file - (lambda (port) - (display "disk image initiated\n" port)))))))))) + (call-with-output-file lock-file + (lambda (port) + (display "disk image initiated\n" port)))))))))) (define disk-init-service-type - (service-type - (name 'disk-init) - (extensions (list - (service-extension activation-service-type - disk-init-activation))) - (description "Resize root partition on first boot and create swapfile"))) + (service-type (name 'disk-init) + (extensions (list (service-extension activation-service-type + disk-init-activation))) + (description + "Resize root partition on first boot and create swapfile"))) |