From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Thompson Subject: [PATCH] scripts: package: Add --install-from-file option. Date: Sun, 09 Aug 2015 11:59:19 -0400 Message-ID: <8737zs78rs.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOT0M-0004RJ-S2 for guix-devel@gnu.org; Sun, 09 Aug 2015 11:59:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZOT0L-00085V-Hr for guix-devel@gnu.org; Sun, 09 Aug 2015 11:59:22 -0400 Received: from mail.fsf.org ([208.118.235.13]:43390) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOT0L-00085Q-E9 for guix-devel@gnu.org; Sun, 09 Aug 2015 11:59:21 -0400 Received: from pool-71-126-57-109.bstnma.east.verizon.net ([71.126.57.109]:37031 helo=izanagi) by mail.fsf.org with esmtpsa (TLS-1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1ZOT0K-0004mJ-Qe for guix-devel@gnu.org; Sun, 09 Aug 2015 11:59:21 -0400 List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --=-=-= Content-Type: text/plain In my personal projects, I keep a 'package.scm' file in the root of the source tree for use with 'guix environment -l'. However, it's also handy to install that package by using 'guix package -e': guix package -e '(primitive-load "package.scm")' This patch adds a shorthand for this: guix package -f package.scm The motivation for this is to ultimately encourage other people to keep a 'package.scm' file in their own repos for building reproducible development environments and easily testing development snapshots, like what we do with our 'guix-devel' package. I'd like to add the same option for 'guix build', if this is approved. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-scripts-package-Add-install-from-file-option.patch >From 07c9b35facf810872f3bc8342e18b33033714adf Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 9 Aug 2015 11:35:51 -0400 Subject: [PATCH] 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. * doc/guix.texi ("invoking guix package"): Document it. --- doc/guix.texi | 31 +++++++++++++++++++++++++++++++ guix/scripts/package.scm | 10 ++++++++++ 2 files changed, 41 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index bcf07a6..dda478f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -1167,6 +1167,37 @@ 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 +(use-modules (guix packages) + (guix download) + (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) + (arguments `(#:configure-flags '("--enable-silent-rules"))) + (inputs `(("gawk" ,gawk))) + (synopsis "Hello, GNU world: An example GNU package") + (description "Guess what GNU Hello prints!") + (home-page "http://www.gnu.org/software/hello/") + (license gpl3+)) +@end example + @item --remove=@var{package} @dots{} @itemx -r @var{package} @dots{} Remove the specified @var{package}s. diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index b545ea2..23f1597 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)) -- 2.4.3 --=-=-= Content-Type: text/plain -- David Thompson GPG Key: 0FF1D807 --=-=-=--