Skip to content

Commit

Permalink
scripts: package: Add --install-from-file option.
Browse files Browse the repository at this point in the history
* guix/scripts/package.scm (show-help): Add help text for --install-from-file
  option.
  (%options): Add --install-from-file option.
* tests/guix-package.sh: Test it.
* doc/guix.texi ("invoking guix package"): Document it.
* doc/package-hello.scm: New file.
* doc.am (EXTRA_DIST): Add it.
  • Loading branch information
davexunit committed Aug 20, 2015
1 parent 83bde59 commit 0d27940
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ EXTRA_DIST += \
doc/images/bootstrap-graph.eps \
doc/images/bootstrap-graph.pdf \
doc/images/coreutils-size-map.eps \
doc/environment-gdb.scm
doc/environment-gdb.scm \
doc/package-hello.scm

OS_CONFIG_EXAMPLES_TEXI = \
doc/os-config-bare-bones.texi \
Expand Down
16 changes: 16 additions & 0 deletions doc/guix.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,22 @@ Note that this option installs the first output of the specified
package, which may be insufficient when needing a specific output of a
multiple-output package.

@item --install-from-file=@var{file}
@itemx -f @var{file}
Install the package that the code within @var{file} evaluates to.

As an example, @var{file} might contain a definition like this
(@pxref{Defining Packages}):

@example
@verbatiminclude package-hello.scm
@end example

Developers may find it useful to include such a @file{package.scm} file
in the root of their project's source tree that can be used to test
development snapshots and create reproducible development environments
(@pxref{Invoking guix environment}).

@item --remove=@var{package} @dots{}
@itemx -r @var{package} @dots{}
Remove the specified @var{package}s.
Expand Down
18 changes: 18 additions & 0 deletions doc/package-hello.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(use-modules (guix)
(guix build-system gnu)
(guix licenses))

(package
(name "hello")
(version "2.8")
(source (origin
(method url-fetch)
(uri (string-append "mirror://gnu/hello/hello-" version
".tar.gz"))
(sha256
(base32 "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))))
(build-system gnu-build-system)
(synopsis "Hello, GNU world: An example GNU package")
(description "Guess what GNU Hello prints!")
(home-page "http://www.gnu.org/software/hello/")
(license gpl3+))
10 changes: 10 additions & 0 deletions guix/scripts/package.scm
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ Install, remove, or upgrade packages in a single transaction.\n"))
-e, --install-from-expression=EXP
install the package EXP evaluates to"))
(display (_ "
-f, --install-from-file=FILE
install the package that the code within FILE
evaluates to"))
(display (_ "
-r, --remove PACKAGE ...
remove PACKAGEs"))
(display (_ "
Expand Down Expand Up @@ -454,6 +458,12 @@ Install, remove, or upgrade packages in a single transaction.\n"))
(values (alist-cons 'install (read/eval-package-expression arg)
result)
#f)))
(option '(#\f "install-from-file") #t #f
(lambda (opt name arg result arg-handler)
(values (alist-cons 'install
(load* arg (make-user-module '()))
result)
#f)))
(option '(#\r "remove") #f #t
(lambda (opt name arg result arg-handler)
(let arg-handler ((arg arg) (result result))
Expand Down
9 changes: 9 additions & 0 deletions tests/guix-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ cat > "$module_dir/foo.scm"<<EOF
EOF
guix package -i emacs-foo-bar-patched -n

# Make sure installing from a file works.
cat > "$module_dir/package.scm"<<EOF
(use-modules (gnu))
(use-package-modules bootstrap)
%bootstrap-guile
EOF
guix package --bootstrap --install-from-file="$module_dir/package.scm"

# This one should not show up in searches since it's no supported on the
# current system.
test "`guix package -A super-non-portable-emacs`" = ""
Expand Down

0 comments on commit 0d27940

Please sign in to comment.