From d16d800de675002b700f7aec7309ee511dfc1563 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 9 Jan 2024 14:52:48 +0000 Subject: laminar: Move groups and jobs constructors into separate functions. * guix/forge/laminar.scm (laminar-groups, laminar-jobs): New functions. (forge-laminar-activation): Use laminar-groups and laminar-jobs. --- guix/forge/laminar.scm | 60 ++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 26 deletions(-) (limited to 'guix') diff --git a/guix/forge/laminar.scm b/guix/forge/laminar.scm index 61d1d20..65b3347 100644 --- a/guix/forge/laminar.scm +++ b/guix/forge/laminar.scm @@ -1,5 +1,5 @@ ;;; guix-forge --- Guix software forge meta-service -;;; Copyright © 2021, 2022 Arun Isaac +;;; Copyright © 2021–2022, 2024 Arun Isaac ;;; ;;; This file is part of guix-forge. ;;; @@ -67,6 +67,35 @@ (name forge-laminar-group-name) (regex forge-laminar-group-regex)) +(define (laminar-groups groups) + "Return a file-like object describing @var{groups}, a list of +@code{} objects." + (plain-file "laminar-groups" + (string-join (map (lambda (group) + (string-append (forge-laminar-group-name group) + "=" + (forge-laminar-group-regex group))) + groups) + "\n"))) + +(define (laminar-jobs jobs) + "Return a file-like object describing a directory of @var{jobs}, a list +of @var{} objects." + (file-union "laminar-jobs" + (append-map (lambda (job) + (let ((name (forge-laminar-job-name job)) + (run (forge-laminar-job-run job)) + (after (forge-laminar-job-after job))) + (cons (let ((run-name (string-append name ".run"))) + (list run-name + (program-file run-name run))) + (if after + (list (let ((after-name (string-append name ".after"))) + (list after-name + (program-file after-name after)))) + (list))))) + jobs))) + (define (forge-laminar-activation config) (let* ((state-directory (forge-laminar-configuration-state-directory config)) (configuration-directory (string-append state-directory "/cfg")) @@ -80,35 +109,14 @@ ;; Configure groups. (when (file-exists? #$groups-configuration) (delete-file #$groups-configuration)) - (symlink - #$(plain-file "laminar-groups" - (string-join (map (lambda (group) - (string-append (forge-laminar-group-name group) - "=" - (forge-laminar-group-regex group))) - (forge-laminar-configuration-groups config)) - "\n")) - #$groups-configuration) + (symlink #$(laminar-groups (forge-laminar-configuration-groups config)) + #$groups-configuration) ;; Create jobs directory and populate with job scripts. (mkdir-p #$(dirname jobs-directory)) (when (file-exists? #$jobs-directory) (delete-file #$jobs-directory)) - (symlink - #$(file-union "laminar-jobs" - (append-map (lambda (job) - (let ((name (forge-laminar-job-name job)) - (run (forge-laminar-job-run job)) - (after (forge-laminar-job-after job))) - (cons (let ((run-name (string-append name ".run"))) - (list run-name - (program-file run-name run))) - (if after - (list (let ((after-name (string-append name ".after"))) - (list after-name - (program-file after-name after)))) - (list))))) - (forge-laminar-configuration-jobs config))) - #$jobs-directory) + (symlink #$(laminar-jobs (forge-laminar-configuration-jobs config)) + #$jobs-directory) ;; Set permissions for laminar directory. (for-each (lambda (file) (let ((user (getpw "laminar"))) -- cgit v1.2.3