guix build: Allow non-package objects in manifest.

* guix/scripts/build.scm (options->things-to-build)[manifest->packages]:
Remove.
Inline map of 'manifest-entry-item'.
* tests/guix-build.sh: Add test for "guix build -m" with non-package object.
This commit is contained in:
Ludovic Courtès 2020-03-03 10:34:35 +01:00
parent 3046e73b4c
commit 5a675b2c67
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 16 additions and 11 deletions

View file

@ -812,14 +812,6 @@ (define (ensure-list x)
(for-each validate-type lst) (for-each validate-type lst)
lst)) lst))
;; Note: Taken from (guix scripts refresh).
(define (manifest->packages manifest)
"Return the list of packages in MANIFEST."
(filter-map (lambda (entry)
(let ((item (manifest-entry-item entry)))
(if (package? item) item #f)))
(manifest-entries manifest)))
(append-map (match-lambda (append-map (match-lambda
(('argument . (? string? spec)) (('argument . (? string? spec))
(cond ((derivation-path? spec) (cond ((derivation-path? spec)
@ -844,8 +836,10 @@ (define (manifest->packages manifest)
(('file . file) (('file . file)
(ensure-list (load* file (make-user-module '())))) (ensure-list (load* file (make-user-module '()))))
(('manifest . manifest) (('manifest . manifest)
(manifest->packages (map manifest-entry-item
(load* manifest (make-user-module '((guix profiles) (gnu)))))) (manifest-entries
(load* manifest
(make-user-module '((guix profiles) (gnu)))))))
(('expression . str) (('expression . str)
(ensure-list (read/eval str))) (ensure-list (read/eval str)))
(('argument . (? derivation? drv)) (('argument . (? derivation? drv))

View file

@ -1,5 +1,5 @@
# GNU Guix --- Functional package management for GNU # GNU Guix --- Functional package management for GNU
# Copyright © 2012, 2013, 2014, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org> # Copyright © 2012, 2013, 2014, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2020 Marius Bakke <mbakke@fastmail.com> # Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
# #
# This file is part of GNU Guix. # This file is part of GNU Guix.
@ -317,6 +317,17 @@ EOF
test `guix build -d --manifest="$module_dir/manifest.scm" \ test `guix build -d --manifest="$module_dir/manifest.scm" \
| grep -e '-hello-' -e '-guix-' \ | grep -e '-hello-' -e '-guix-' \
| wc -l` -eq 2 | wc -l` -eq 2
# Building from a manifest that contains a non-package object.
cat > "$module_dir/manifest.scm"<<EOF
(manifest
(list (manifest-entry (name "foo") (version "0")
(item (computed-file "computed-thingie"
#~(mkdir (ungexp output)))))))
EOF
guix build -d -m "$module_dir/manifest.scm" \
| grep 'computed-thingie\.drv$'
rm "$module_dir"/*.scm rm "$module_dir"/*.scm
# Using 'GUIX_BUILD_OPTIONS'. # Using 'GUIX_BUILD_OPTIONS'.