mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
scripts: build: Add --file option.
* guix/scripts/build.scm (show-help): Add help text for --file option. (%options): Add --file option. (options/resolve-packages): Handle 'file' options. * tests/guix-build.sh: Add tests. * doc/guix.texi ("invoking guix build"): Add doc.
This commit is contained in:
parent
5c7bdc9a7f
commit
34a1783fc1
3 changed files with 68 additions and 17 deletions
|
@ -3615,6 +3615,19 @@ The @var{options} may be zero or more of the following:
|
||||||
|
|
||||||
@table @code
|
@table @code
|
||||||
|
|
||||||
|
@item --file=@var{file}
|
||||||
|
@itemx -f @var{file}
|
||||||
|
|
||||||
|
Build the package or derivation that the code within @var{file}
|
||||||
|
evaluates to.
|
||||||
|
|
||||||
|
As an example, @var{file} might contain a package definition like this
|
||||||
|
(@pxref{Defining Packages}):
|
||||||
|
|
||||||
|
@example
|
||||||
|
@verbatiminclude package-hello.scm
|
||||||
|
@end example
|
||||||
|
|
||||||
@item --expression=@var{expr}
|
@item --expression=@var{expr}
|
||||||
@itemx -e @var{expr}
|
@itemx -e @var{expr}
|
||||||
Build the package or derivation @var{expr} evaluates to.
|
Build the package or derivation @var{expr} evaluates to.
|
||||||
|
|
|
@ -290,6 +290,9 @@ (define (show-help)
|
||||||
(display (_ "
|
(display (_ "
|
||||||
-e, --expression=EXPR build the package or derivation EXPR evaluates to"))
|
-e, --expression=EXPR build the package or derivation EXPR evaluates to"))
|
||||||
(display (_ "
|
(display (_ "
|
||||||
|
-f, --file=FILE build the package or derivation that the code within
|
||||||
|
FILE evaluates to"))
|
||||||
|
(display (_ "
|
||||||
-S, --source build the packages' source derivations"))
|
-S, --source build the packages' source derivations"))
|
||||||
(display (_ "
|
(display (_ "
|
||||||
--sources[=TYPE] build source derivations; TYPE may optionally be one
|
--sources[=TYPE] build source derivations; TYPE may optionally be one
|
||||||
|
@ -359,6 +362,9 @@ (define %options
|
||||||
(option '(#\e "expression") #t #f
|
(option '(#\e "expression") #t #f
|
||||||
(lambda (opt name arg result)
|
(lambda (opt name arg result)
|
||||||
(alist-cons 'expression arg result)))
|
(alist-cons 'expression arg result)))
|
||||||
|
(option '(#\f "file") #t #f
|
||||||
|
(lambda (opt name arg result)
|
||||||
|
(alist-cons 'file arg result)))
|
||||||
(option '(#\n "dry-run") #f #f
|
(option '(#\n "dry-run") #f #f
|
||||||
(lambda (opt name arg result)
|
(lambda (opt name arg result)
|
||||||
(alist-cons 'dry-run? #t result)))
|
(alist-cons 'dry-run? #t result)))
|
||||||
|
@ -422,13 +428,8 @@ (define (options/resolve-packages store opts)
|
||||||
(define system
|
(define system
|
||||||
(or (assoc-ref opts 'system) (%current-system)))
|
(or (assoc-ref opts 'system) (%current-system)))
|
||||||
|
|
||||||
(map (match-lambda
|
(define (object->argument obj)
|
||||||
(('argument . (? string? spec))
|
(match obj
|
||||||
(if (store-path? spec)
|
|
||||||
`(argument . ,spec)
|
|
||||||
`(argument . ,(specification->package spec))))
|
|
||||||
(('expression . str)
|
|
||||||
(match (read/eval str)
|
|
||||||
((? package? p)
|
((? package? p)
|
||||||
`(argument . ,p))
|
`(argument . ,p))
|
||||||
((? procedure? proc)
|
((? procedure? proc)
|
||||||
|
@ -445,6 +446,16 @@ (define system
|
||||||
(gexp->derivation "gexp" gexp
|
(gexp->derivation "gexp" gexp
|
||||||
#:system system)))))
|
#:system system)))))
|
||||||
`(argument . ,drv)))))
|
`(argument . ,drv)))))
|
||||||
|
|
||||||
|
(map (match-lambda
|
||||||
|
(('argument . (? string? spec))
|
||||||
|
(if (store-path? spec)
|
||||||
|
`(argument . ,spec)
|
||||||
|
`(argument . ,(specification->package spec))))
|
||||||
|
(('file . file)
|
||||||
|
(object->argument (load* file (make-user-module '()))))
|
||||||
|
(('expression . str)
|
||||||
|
(object->argument (read/eval str)))
|
||||||
(opt opt))
|
(opt opt))
|
||||||
opts))
|
opts))
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,33 @@ guix build -e "(begin
|
||||||
guix build -e '#~(mkdir #$output)' -d
|
guix build -e '#~(mkdir #$output)' -d
|
||||||
guix build -e '#~(mkdir #$output)' -d | grep 'gexp\.drv'
|
guix build -e '#~(mkdir #$output)' -d | grep 'gexp\.drv'
|
||||||
|
|
||||||
|
# Building from a package file.
|
||||||
|
cat > "$module_dir/package.scm"<<EOF
|
||||||
|
(use-modules (gnu))
|
||||||
|
(use-package-modules bootstrap)
|
||||||
|
|
||||||
|
%bootstrap-guile
|
||||||
|
EOF
|
||||||
|
guix build --file="$module_dir/package.scm"
|
||||||
|
|
||||||
|
# Building from a monadic procedure file.
|
||||||
|
cat > "$module_dir/proc.scm"<<EOF
|
||||||
|
(use-modules (guix gexp))
|
||||||
|
(lambda ()
|
||||||
|
(gexp->derivation "test"
|
||||||
|
(gexp (mkdir (ungexp output)))))
|
||||||
|
EOF
|
||||||
|
guix build --file="$module_dir/proc.scm" --dry-run
|
||||||
|
|
||||||
|
# Building from a gexp file.
|
||||||
|
cat > "$module_dir/gexp.scm"<<EOF
|
||||||
|
(use-modules (guix gexp))
|
||||||
|
|
||||||
|
(gexp (mkdir (ungexp output)))
|
||||||
|
EOF
|
||||||
|
guix build --file="$module_dir/gexp.scm" -d
|
||||||
|
guix build --file="$module_dir/gexp.scm" -d | grep 'gexp\.drv'
|
||||||
|
|
||||||
# Using 'GUIX_BUILD_OPTIONS'.
|
# Using 'GUIX_BUILD_OPTIONS'.
|
||||||
GUIX_BUILD_OPTIONS="--dry-run"
|
GUIX_BUILD_OPTIONS="--dry-run"
|
||||||
export GUIX_BUILD_OPTIONS
|
export GUIX_BUILD_OPTIONS
|
||||||
|
|
Loading…
Reference in a new issue