From 0d2794005caa627965fd6256f28f94e36cd4b5a0 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 9 Aug 2015 11:35:51 -0400 Subject: scripts: package: Add --install-from-file option. * 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. --- doc.am | 3 ++- doc/guix.texi | 16 ++++++++++++++++ doc/package-hello.scm | 18 ++++++++++++++++++ guix/scripts/package.scm | 10 ++++++++++ tests/guix-package.sh | 9 +++++++++ 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 doc/package-hello.scm diff --git a/doc.am b/doc.am index 02b80ec7b5..1f0b8328e1 100644 --- a/doc.am +++ b/doc.am @@ -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 \ diff --git a/doc/guix.texi b/doc/guix.texi index 2b61574c84..7c063bf359 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -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. diff --git a/doc/package-hello.scm b/doc/package-hello.scm new file mode 100644 index 0000000000..b3fcd4ff73 --- /dev/null +++ b/doc/package-hello.scm @@ -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+)) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index b545ea2672..23f1597856 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -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 (_ " @@ -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)) diff --git a/tests/guix-package.sh b/tests/guix-package.sh index b361b1ba00..bb1037044d 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -225,6 +225,15 @@ cat > "$module_dir/foo.scm"< "$module_dir/package.scm"<