summaryrefslogtreecommitdiff
path: root/deployment
diff options
context:
space:
mode:
Diffstat (limited to 'deployment')
-rw-r--r--deployment/channels.scm24
-rw-r--r--deployment/services/admin.scm76
-rw-r--r--deployment/services/cuirass.scm3
-rw-r--r--deployment/specification.scm17
4 files changed, 90 insertions, 30 deletions
diff --git a/deployment/channels.scm b/deployment/channels.scm
index b75a39e..442257c 100644
--- a/deployment/channels.scm
+++ b/deployment/channels.scm
@@ -19,29 +19,35 @@
;;; If not, see <https://www.gnu.org/licenses/>.
(define-module (deployment channels)
- #:export (guix-with-channels
- master-channels
- test-channels)
+ #:export (guix-with-channels)
#:use-module (gnu packages package-management)
#:use-module (guix gexp)
#:use-module (sovereign channels))
-(define master-channels
- (list (default-guix-channel "master")
- (deployment-channel "master")
+(define-public master-channels
+ (list (deployment-channel "master")
+ (guix-channel "master")
;; (mnt-reform-nonguix "personal")
(nonguix-channel "master")
(rde-channel "master")
(sovereign-channel "master")))
-(define test-channels
- (list (default-guix-channel "test")
- (deployment-channel "test")
+(define-public test-channels
+ (list (deployment-channel "test")
+ (guix-channel "test")
;; (mnt-reform-nonguix "personal")
(nonguix-channel "test")
(rde-channel "master")
(sovereign-channel "test")))
+(define-public upstream-channels
+ (list (default-guix-channel "master")
+ (default-nonguix-channel "master")
+ ;; (default-mnt-reform-nonguix "personal")
+ (default-rde-channel "master")
+ (deployment-channel "master")
+ (sovereign-channel "master")))
+
(define (guix-with-channels channels)
(file-append (guix-for-channels channels) ; package output
"/bin/guix" ; relative path to the executable
diff --git a/deployment/services/admin.scm b/deployment/services/admin.scm
index 24103ef..cdd9dc9 100644
--- a/deployment/services/admin.scm
+++ b/deployment/services/admin.scm
@@ -19,23 +19,63 @@
;;; If not, see <https://www.gnu.org/licenses/>.
(define-module (deployment services admin)
- #:export (update-commands)
- #:use-module (deployment channels)
+ #:export (bash-aliases_service-record)
+ #:use-module (gnu home services)
#:use-module (gnu home services shells)
- #:use-module (gnu services))
+ #:use-module (gnu services)
+ #:use-module (guix ui))
-(define update-commands
- (simple-service
- 'update-commands
- home-bash-service-type
- (home-bash-extension
- (aliases
- `(("collect-garbage" . "gc -d 7d ")
- ("delete-generations" . "system delete-generations 7d ")
- ("guix" . ,(guix-with-channels master-channels))
- ("guix-test" . ,(guix-with-channels test-channels))
- ("pull" . " pull --fallback ")
- ("pull-down" . "pull --allow-downgrades --disable-authentication --fallback ")
- ("reconfigure" . "system reconfigure -e \"(@ (deployment system) $HOSTNAME)\" --fallback ")
- ("reconfigure-down" . "system reconfigure --allow-downgrades -e \"(@ (deployment system) $HOSTNAME)\" --fallback ")
- ("sudo" . "sudo "))))))
+;; Retention threshold for both generation scopes below.
+;; One scope is the system generations.
+;; The other is the machine-wide pruning of "guix gc -d".
+;; Fail here, at build time, on anything "guix ui" does not parse as a duration.
+;; With the argument absent, both commands fall back to unrooting every generation but the current one.
+;; An empty value must therefore never reach the command lines.
+(define retention-duration_string "7d")
+
+(unless (string->duration retention-duration_string)
+ (error "retention duration is not a duration string"
+ retention-duration_string))
+
+;; As root, "guix gc -d" unroots the profile and home-environment generations of every user older than the retention duration.
+;; It then collects garbage in the same invocation.
+(define collect-garbage_string
+ (string-append "sudo guix gc -d "
+ retention-duration_string))
+
+;; Unroots the system generations older than the retention duration and reinstalls the bootloader menu.
+;; The store space is reclaimed only by the garbage collection pass.
+(define system-delete-generations_string
+ (string-append "sudo guix system delete-generations "
+ retention-duration_string))
+
+;; Updates the user's guix only.
+;; The system-wide guix is deployed by CI through the channels mechanism.
+;; This pull therefore does not feed the reconfigure below.
+;; It stays unprivileged by design.
+(define pull_string "guix pull --fallback")
+
+;; Wrapped in "literal-string" in the alist below, so the serializer single-quotes the whole value.
+;; The guard stays literal while .bashrc is sourced and resolves at invocation.
+;; It fires only when the host name is empty, the kernel's own or one inherited from the environment.
+(define system-reconfigure_string
+ "sudo guix system reconfigure -e \"(@ (deployment system) ${HOSTNAME:?HOSTNAME is not set})\" --fallback")
+
+;; The generations unrooted above are reclaimed by the collection pass of "guix gc -d", so the collector runs last.
+;; The "&&" separators stop the chain before anything is unrooted or collected.
+(define upgrade_string
+ (string-append pull_string
+ " && " system-reconfigure_string
+ " && " system-delete-generations_string
+ " && " collect-garbage_string))
+
+(define bash-aliases_service-record
+ (simple-service 'bash-aliases
+ home-bash-service-type
+ (home-bash-extension
+ (aliases
+ `(("collect-garbage" . ,collect-garbage_string)
+ ("delete-generations" . ,system-delete-generations_string)
+ ("pull-guix" . ,pull_string)
+ ("reconfigure-system" . ,(literal-string system-reconfigure_string))
+ ("upgrade-system" . ,(literal-string upgrade_string)))))))
diff --git a/deployment/services/cuirass.scm b/deployment/services/cuirass.scm
index d06883a..f9a40c0 100644
--- a/deployment/services/cuirass.scm
+++ b/deployment/services/cuirass.scm
@@ -32,6 +32,7 @@
(define cuirass-rakan_configuration-record
(cuirass-configuration
(inherit sovereign:services:cuirass:cuirass_configuration-record)
- (specifications #~(list (ungexp deployment:specification:cuirass-deployment-test_specification-record)))))
+ (specifications #~(list (ungexp deployment:specification:cuirass-deployment-test_specification-record)
+ (ungexp deployment:specification:cuirass-deployment-upstream_specification-record)))))
;;; EOF
diff --git a/deployment/specification.scm b/deployment/specification.scm
index 6cbdc56..b76f267 100644
--- a/deployment/specification.scm
+++ b/deployment/specification.scm
@@ -19,7 +19,6 @@
;;; If not, see <https://www.gnu.org/licenses/>.
(define-module (deployment specification)
- #:export (cuirass-deployment-test_specification-record)
#:use-module ((deployment channels)
#:prefix deployment:channels:)
#:use-module ((guix channels)
@@ -29,7 +28,7 @@
`(list ,@(map guix:channels:channel->code
channels_list)))
-(define cuirass-deployment-test_specification-record
+(define-public cuirass-deployment-test_specification-record
`(specification
(name 'deployment-channel-test)
(build '(custom (deployment system)))
@@ -43,4 +42,18 @@
(is-active? #t)
(properties (list))))
+(define-public cuirass-deployment-upstream_specification-record
+ `(specification
+ (name 'deployment-channel-upstream)
+ (build '(custom (deployment system)))
+ (channels ,(channels->code deployment:channels:upstream-channels))
+ (build-outputs (list))
+ (notifications (list))
+ (period (* 24 60 60))
+ (priority 9)
+ (systems (list "x86_64-linux"
+ "aarch64-linux"))
+ (is-active? #t)
+ (properties (list))))
+
;;; EOF