diff options
author | Marius Bakke <marius@gnu.org> | 2021-10-31 22:52:06 +0100 |
---|---|---|
committer | Marius Bakke <marius@gnu.org> | 2022-11-03 20:00:30 +0100 |
commit | 706f25f24dab13dff69e7977b5d84269c1dfa293 (patch) | |
tree | 09f32832ab02b530a2f5cc98f984cfb610cac058 /gnu/services | |
parent | 614a92cae84dbfe0a4b34c3075d09e879cc98724 (diff) | |
download | guix-706f25f24dab13dff69e7977b5d84269c1dfa293.tar.gz |
services: ganeti: OS variants can be a directory.
* gnu/services/ganeti.scm (<ganeti-os>)[extension]: Default to #f. (ganeti-os->directory): Only add extension if set. Support a file-like object for VARIANTS. * doc/guix.texi (Virtualization Services): Document this change and add example. Update Ganeti URLs while at it.
Diffstat (limited to 'gnu/services')
-rw-r--r-- | gnu/services/ganeti.scm | 76 |
1 files changed, 44 insertions, 32 deletions
diff --git a/gnu/services/ganeti.scm b/gnu/services/ganeti.scm index 85adbd7362..d9770b1a29 100644 --- a/gnu/services/ganeti.scm +++ b/gnu/services/ganeti.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2020 Marius Bakke <marius@gnu.org> +;;; Copyright © 2020, 2022 Marius Bakke <marius@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -819,8 +819,9 @@ than 21 days from @file{/var/lib/ganeti/queue/archive}."))) (define-record-type* <ganeti-os> ganeti-os make-ganeti-os ganeti-os? (name ganeti-os-name) ;string - (extension ganeti-os-extension) ;string - (variants ganeti-os-variants ;list of <ganeti-os-variant> + (extension ganeti-os-extension ;#f | string + (default #f)) + (variants ganeti-os-variants ;<file-like> | list of <ganeti-os-variant> (default '()))) (define-record-type* <ganeti-os-variant> @@ -992,35 +993,46 @@ trap - EXIT (define (ganeti-os->directory os) "Return the derivation to build the configuration directory to be installed in /etc/ganeti/instance-$os for OS." - (let* ((name (ganeti-os-name os)) - (extension (ganeti-os-extension os)) - (variants (ganeti-os-variants os)) - (names (map ganeti-os-variant-name variants)) - (configs (map ganeti-os-variant-configuration variants))) - (with-imported-modules '((guix build utils)) - (define builder - #~(begin - (use-modules (guix build utils) - (ice-9 format) - (ice-9 match) - (srfi srfi-1)) - (mkdir-p #$output) - (unless (null? '#$names) - (let ((variants-dir (string-append #$output "/variants"))) - (mkdir-p variants-dir) - (call-with-output-file (string-append variants-dir "/variants.list") - (lambda (port) - (format port "~a~%" - (string-join '#$names "\n")))) - (for-each (match-lambda - ((name file) - (symlink file - (string-append variants-dir "/" name - #$extension)))) - - '#$(zip names configs)))))) - - (computed-file (string-append name "-os") builder)))) + (let ((name (ganeti-os-name os)) + (extension (ganeti-os-extension os)) + (variants (ganeti-os-variants os))) + (define builder + (with-imported-modules '((guix build utils)) + (if (file-like? variants) + #~(begin + (use-modules (guix build utils)) + (mkdir-p #$output) + (symlink #$variants + (string-append #$output "/variants"))) + #~(begin + (use-modules (guix build utils) + (ice-9 format) + (ice-9 match) + (srfi srfi-1)) + (mkdir-p #$output) + (let ((variants-dir (string-append #$output "/variants")) + (names '#$(map ganeti-os-variant-name variants)) + (configs '#$(map ganeti-os-variant-configuration variants))) + (mkdir-p variants-dir) + (unless (null? names) + (call-with-output-file (string-append variants-dir + "/variants.list") + (lambda (port) + (format port "~a~%" + (string-join names "\n")))) + (for-each (match-lambda + ((name file) + (let ((file-name + (if #$extension + (string-append name #$extension) + name))) + (symlink file + (string-append variants-dir "/" + file-name))))) + (zip names configs)))))))) + + (computed-file (string-append name "-os") builder + #:local-build? #t))) (define (ganeti-directory file-storage-file os) (let ((dirs (map ganeti-os->directory os)) |