From 62f8399e6ac76af85ed72157bea2885d531c06fb Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 24 Nov 2024 00:32:36 +0100 Subject: [PATCH] =?UTF-8?q?pack:=20Add=20=E2=80=98--file=3DFILE=E2=80=99?= =?UTF-8?q?=20with=20the=20same=20meaning=20as=20for=20=E2=80=98guix=20bui?= =?UTF-8?q?ld=E2=80=99.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/pack.scm (%options): add --file=FILE, but no shorthand (that’s already taken for format). * doc/guix.texi (Invoking guix pack): Document it. Change-Id: I87797fccdf218ead3b7f471a84034e8a8d566245 Signed-off-by: Ludovic Courtès --- doc/guix.texi | 8 ++++++++ guix/scripts/pack.scm | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index ba9b75f3705..0d461fb96a5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -7276,6 +7276,14 @@ This has the same purpose as the same-named option in @command{guix build} (@pxref{Additional Build Options, @option{--expression} in @command{guix build}}). +@item --file=@var{file} +build a pack the code within @var{file} evaluates to. + +This has the same purpose as the same-named option in @command{guix +build} (@pxref{Additional Build Options, @option{--file} in +@command{guix build}}), but it has no shorthand, because @option{-f} +already means @option{--format}. + @anchor{pack-manifest} @item --manifest=@var{file} @itemx -m @var{file} diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 26ba80b80d8..58cd55b129b 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -30,6 +30,7 @@ (define-module (guix scripts pack) #:use-module (guix scripts) + #:autoload (guix import json) (json->scheme-file) #:use-module (guix ui) #:use-module (guix gexp) #:use-module (guix utils) @@ -1530,6 +1531,9 @@ libfakechroot.so and related ld.so machinery as a fallback." (lambda (opt name arg result) (alist-cons 'derivation-only? #t result))) + (option '("file") #t #f + (lambda (opt name arg result) + (alist-cons 'file arg result))) (option '(#\f "format") #t #f (lambda (opt name arg result) (alist-cons 'format (string->symbol arg) result))) @@ -1620,6 +1624,8 @@ Create a bundle of PACKAGE.\n")) (show-deb-format-options) (show-rpm-format-options) (newline) + (display (G_ " + --file=FORMAT build a pack the code within FILE evaluates to")) (display (G_ " -f, --format=FORMAT build a pack in the given FORMAT")) (display (G_ " @@ -1684,6 +1690,11 @@ Create a bundle of PACKAGE.\n")) list)) (('expression . exp) (read/eval-package-expression exp)) + (('file . file) + (let ((file (or (and (string-suffix? ".json" file) + (json->scheme-file file)) + file))) + (load* file (make-user-module '())))) (x #f))) (define (manifest-from-args store opts)