From: "Ludovic Courtès" <ludo@gnu.org>
To: 74542@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>,
"Christopher Baines" <guix@cbaines.net>,
"Josselin Poiret" <dev@jpoiret.xyz>,
"Ludovic Courtès" <ludo@gnu.org>,
"Mathieu Othacehe" <othacehe@gnu.org>,
"Maxim Cournoyer" <maxim.cournoyer@gmail.com>,
"Simon Tournier" <zimon.toutoune@gmail.com>,
"Tobias Geerinckx-Rice" <me@tobias.gr>
Subject: [bug#74542] [PATCH v2 04/16] guix build: Add ‘--development’ option.
Date: Fri, 29 Nov 2024 10:40:07 +0100 [thread overview]
Message-ID: <298ce743d6908424e59c348444fa4d904935646d.1732872498.git.ludo@gnu.org> (raw)
In-Reply-To: <cover.1732615193.git.ludo@gnu.org>
* guix/scripts/build.scm (show-help, %options): Add ‘-D’.
(options->things-to-build): Change ‘append-map’ to a loop. Honor ‘-D’.
* tests/guix-build.sh: Add test.
* doc/guix.texi (Additional Build Options): Document it.
Change-Id: I99227aadfe861e43c001a4872292bd687b37f5d4
---
doc/guix.texi | 25 +++++++++
guix/scripts/build.scm | 119 ++++++++++++++++++++++++++++-------------
tests/guix-build.sh | 5 ++
3 files changed, 112 insertions(+), 37 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 26488b41c8..a9d0d044ae 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -13614,6 +13614,31 @@ Additional Build Options
(@pxref{The Store Monad}). The procedure must return a derivation as a
monadic value, which is then passed through @code{run-with-store}.
+@item --development
+@itemx -D
+Build the ``development environment'' (build dependencies) of the
+following package.
+
+For example, the following command builds the inputs of @code{hello},
+but @emph{not} @code{hello} itself, and also builds @code{guile}:
+
+@example
+guix build -D hello guile
+@end example
+
+Notice that @option{-D} (or @option{--development}) only applies to the
+immediately following package on the command line. Under the hood, it
+uses @code{package->development-manifest}
+(@pxref{package-development-manifest,
+@code{package->development-manifest}}).
+
+@quotation Note
+The effect of combining @option{--development} with @option{--target}
+(for cross-compilation) may not be what you expect: it will
+cross-compile all the dependencies of the given package when it is built
+natively.
+@end quotation
+
@item --source
@itemx -S
Build the source derivations of the packages, rather than the packages
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index 9e05bb532b..e8384c8d2d 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -438,6 +438,8 @@ (define (show-help)
-m, --manifest=FILE build the packages that the manifest given in FILE
evaluates to"))
(display (G_ "
+ -D, --development build the inputs of the following package"))
+ (display (G_ "
-S, --source build the packages' source derivations"))
(display (G_ "
--sources[=TYPE] build source derivations; TYPE may optionally be one
@@ -522,6 +524,9 @@ (define %options
(option '(#\m "manifest") #t #f
(lambda (opt name arg result)
(alist-cons 'manifest arg result)))
+ (option '(#\D "development") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'development? #t result)))
(option '(#\n "dry-run") #f #f
(lambda (opt name arg result)
(alist-cons 'dry-run? #t result)))
@@ -581,43 +586,83 @@ (define-public my-package
(for-each validate-type lst)
lst))
- (append-map (match-lambda
- (('argument . (? string? spec))
- (cond ((derivation-path? spec)
- (catch 'system-error
- (lambda ()
- ;; Ask for absolute file names so that .drv file
- ;; names passed from the user to 'read-derivation'
- ;; are absolute when it returns.
- (let ((spec (canonicalize-path spec)))
- (list (read-derivation-from-file spec))))
- (lambda args
- ;; Non-existent .drv files can be substituted down
- ;; the road, so don't error out.
- (if (= ENOENT (system-error-errno args))
- '()
- (apply throw args)))))
- ((store-path? spec)
- ;; Nothing to do; maybe for --log-file.
- '())
- (else
- (list (specification->package spec)))))
- (('file . file)
- (let ((file (or (and (string-suffix? ".json" file)
- (json->scheme-file file))
- file)))
- (ensure-list (load* file (make-user-module '())))))
- (('manifest . manifest)
- (map manifest-entry-item
- (manifest-entries
- (load* manifest
- (make-user-module '((guix profiles) (gnu)))))))
- (('expression . str)
- (ensure-list (read/eval str)))
- (('argument . (? derivation? drv))
- drv)
- (_ '()))
- opts))
+ (define system
+ (or (assoc-ref opts 'system) (%current-system)))
+
+ ;; Process OPTS in "the right order", meaning that if the user typed
+ ;; "-D hello", arrange to see the 'development? option before the "hello"
+ ;; spec.
+ (let loop ((opts (reverse opts))
+ (type 'regular)
+ (result '()))
+ (define (for-type obj)
+ ;; Return a list of objects corresponding to OBJ adjusted for TYPE.
+ (match type
+ ('regular
+ (list obj))
+ ('development
+ (if (package? obj)
+ (map manifest-entry-item
+ (manifest-entries
+ (package->development-manifest obj system)))
+ obj))))
+
+ (match opts
+ (()
+ (reverse result))
+ ((head . tail)
+ (match head
+ (('argument . (? string? spec))
+ (cond ((derivation-path? spec)
+ (catch 'system-error
+ (lambda ()
+ ;; Ask for absolute file names so that .drv file
+ ;; names passed from the user to 'read-derivation'
+ ;; are absolute when it returns.
+ (let ((spec (canonicalize-path spec)))
+ (loop tail 'regular
+ (cons (read-derivation-from-file spec)
+ result))))
+ (lambda args
+ ;; Non-existent .drv files can be substituted down
+ ;; the road, so don't error out.
+ (if (= ENOENT (system-error-errno args))
+ (loop tail 'regular result)
+ (apply throw args)))))
+ ((store-path? spec)
+ ;; Nothing to do; maybe for --log-file.
+ (loop tail type result))
+ (else
+ (loop tail 'regular
+ (append (for-type (specification->package spec))
+ result)))))
+ (('argument . (? derivation? drv))
+ (loop tail 'regular (cons drv result)))
+ (('file . file)
+ (let ((file (or (and (string-suffix? ".json" file)
+ (json->scheme-file file))
+ file)))
+ (loop tail 'regular
+ (append (append-map
+ for-type
+ (ensure-list (load* file (make-user-module '()))))
+ result))))
+ (('manifest . manifest)
+ (loop tail 'regular
+ (append (map manifest-entry-item
+ (manifest-entries
+ (load* manifest
+ (make-user-module '((guix profiles)
+ (gnu))))))
+ result)))
+ (('expression . str)
+ (loop tail 'regular
+ (append (append-map for-type (ensure-list (read/eval str)))
+ result)))
+ (('development? . #t)
+ (loop tail 'development result))
+ (_
+ (loop tail type result)))))))
(define (options->derivations store opts)
"Given OPTS, the result of 'args-fold', return a list of derivations to
diff --git a/tests/guix-build.sh b/tests/guix-build.sh
index 36eac2b7e0..3637bcdeb3 100644
--- a/tests/guix-build.sh
+++ b/tests/guix-build.sh
@@ -190,6 +190,11 @@ test `guix build -d --sources=transitive foo \
| grep -e 'foo\.tar\.gz' -e 'bar\.tar\.gz' -e 'bar\.dat' \
| wc -l` -eq 3
+# Building the inputs.
+guix build -D hello -n
+test `guix build -D hello -d \
+ | grep -e 'glibc.*\.drv$' -e 'gcc.*\.drv$' -e 'binutils.*\.drv$' \
+ | wc -l` -ge 3
# Unbound variable in thunked field.
cat > "$module_dir/foo.scm" <<EOF
--
2.46.0
next prev parent reply other threads:[~2024-11-29 9:42 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-26 10:32 [bug#74542] [PATCH 00/11] Improved tooling for package updates Ludovic Courtès
2024-11-26 10:33 ` [bug#74542] [PATCH 01/11] transformations: Export ‘package-with-upstream-version’ Ludovic Courtès
2024-11-26 15:00 ` Simon Tournier
2024-11-26 10:33 ` [bug#74542] [PATCH 02/11] gnu-maintenance: ‘import-html-release’ doesn’t abort upon HTTP 404 Ludovic Courtès
2024-11-26 15:09 ` Simon Tournier
2024-11-26 17:16 ` Ludovic Courtès
2024-11-27 17:05 ` Simon Tournier
2024-11-26 10:33 ` [bug#74542] [PATCH 03/11] gnu-maintenance: Savannah/Xorg updaters no longer abort on network errors Ludovic Courtès
2024-11-26 15:12 ` Simon Tournier
2024-11-26 10:33 ` [bug#74542] [PATCH 04/11] build: Add ‘--development’ option Ludovic Courtès
2024-11-26 15:26 ` Simon Tournier
2024-11-28 10:49 ` Ludovic Courtès
2024-11-26 10:33 ` [bug#74542] [PATCH 05/11] packages: Factorize ‘all-packages’ Ludovic Courtès
2024-11-27 18:45 ` Simon Tournier
2024-11-26 10:33 ` [bug#74542] [PATCH 06/11] guix build: Add ‘--dependents’ Ludovic Courtès
2024-11-27 19:12 ` Simon Tournier
2024-11-28 10:57 ` Ludovic Courtès
2024-11-26 10:33 ` [bug#74542] [PATCH 07/11] import: gnome: Keep going upon HTTP errors Ludovic Courtès
2024-11-26 15:26 ` Simon Tournier
2024-11-26 10:33 ` [bug#74542] [PATCH 08/11] gnu-maintenance: ‘gnu-ftp’ updater excludes GnuPG-hosted packages Ludovic Courtès
2024-11-26 15:28 ` Simon Tournier
2024-11-26 10:33 ` [bug#74542] [PATCH 09/11] gnu: Update updater properties for GnuPG-related packages Ludovic Courtès
2024-11-26 15:28 ` Simon Tournier
2024-11-26 10:33 ` [bug#74542] [PATCH 10/11] guix build: Validate that the file passed to ‘-m’ returns a manifest Ludovic Courtès
2024-11-26 15:36 ` Simon Tournier
2024-11-26 10:33 ` [bug#74542] [PATCH 11/11] etc: Add upgrade manifest Ludovic Courtès
2024-11-26 15:49 ` Simon Tournier
2024-11-26 17:18 ` Ludovic Courtès
2024-11-27 19:23 ` Simon Tournier
2024-11-26 14:42 ` [bug#74542] [PATCH 00/11] Improved tooling for package updates Ludovic Courtès
2024-11-26 16:04 ` Simon Tournier
2024-11-26 14:59 ` Simon Tournier
2024-11-26 17:21 ` Ludovic Courtès
2024-11-27 19:26 ` Simon Tournier
2024-11-26 16:32 ` Suhail Singh
2024-11-26 17:23 ` Ludovic Courtès
2024-11-29 9:40 ` [bug#74542] [PATCH v2 00/16] " Ludovic Courtès
2024-11-29 14:46 ` Maxim Cournoyer
2024-12-01 16:30 ` Ludovic Courtès
2024-11-29 15:17 ` Suhail Singh
2024-12-01 16:34 ` Ludovic Courtès
2024-11-29 15:23 ` Simon Tournier
2024-12-01 19:16 ` bug#74542: " Ludovic Courtès
2024-11-29 9:40 ` [bug#74542] [PATCH v2 01/16] transformations: Export ‘package-with-upstream-version’ Ludovic Courtès
2024-11-29 9:40 ` [bug#74542] [PATCH v2 02/16] gnu-maintenance: ‘import-html-release’ doesn’t abort upon HTTP 404 Ludovic Courtès
2024-11-29 14:42 ` Maxim Cournoyer
2024-11-29 9:40 ` [bug#74542] [PATCH v2 03/16] gnu-maintenance: Savannah/Xorg updaters no longer abort on network errors Ludovic Courtès
2024-11-29 9:40 ` Ludovic Courtès [this message]
2024-11-29 14:49 ` [bug#74542] [PATCH v2 04/16] guix build: Add ‘--development’ option Maxim Cournoyer
2024-11-29 9:40 ` [bug#74542] [PATCH v2 05/16] packages: Factorize ‘all-packages’ Ludovic Courtès
2024-11-29 14:53 ` Maxim Cournoyer
2024-12-01 16:37 ` Ludovic Courtès
2024-11-29 9:40 ` [bug#74542] [PATCH v2 06/16] guix build: Add ‘--dependents’ Ludovic Courtès
2024-11-29 9:40 ` [bug#74542] [PATCH v2 07/16] import: gnome: Keep going upon HTTP errors Ludovic Courtès
2024-11-29 9:40 ` [bug#74542] [PATCH v2 08/16] gnu-maintenance: ‘gnu-ftp’ updater excludes GnuPG-hosted packages Ludovic Courtès
2024-11-29 9:40 ` [bug#74542] [PATCH v2 09/16] gnu: Update updater properties for GnuPG-related packages Ludovic Courtès
2024-11-29 9:40 ` [bug#74542] [PATCH v2 10/16] gnu: gnutls: Change release monitoring URL Ludovic Courtès
2024-11-29 9:40 ` [bug#74542] [PATCH v2 11/16] gnu: git-minimal: Add ‘upstream-name’ property Ludovic Courtès
2024-11-29 9:40 ` [bug#74542] [PATCH v2 12/16] gnu-maintenance: ‘generic-html’ update honors <base href="…"> Ludovic Courtès
2024-11-29 9:40 ` [bug#74542] [PATCH v2 13/16] guix build: Validate that the file passed to ‘-m’ returns a manifest Ludovic Courtès
2024-11-29 9:40 ` [bug#74542] [PATCH v2 14/16] transformations: ‘package-with-upstream-version’ can preserve patches Ludovic Courtès
2024-11-29 9:40 ` [bug#74542] [PATCH v2 15/16] transformations: Add #:authenticate? to ‘package-with-upstream-version’ Ludovic Courtès
2024-11-29 9:40 ` [bug#74542] [PATCH v2 16/16] etc: Add upgrade manifest Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=298ce743d6908424e59c348444fa4d904935646d.1732872498.git.ludo@gnu.org \
--to=ludo@gnu.org \
--cc=74542@debbugs.gnu.org \
--cc=dev@jpoiret.xyz \
--cc=guix@cbaines.net \
--cc=maxim.cournoyer@gmail.com \
--cc=me@tobias.gr \
--cc=othacehe@gnu.org \
--cc=zimon.toutoune@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).