unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: David Thompson <dthompson2@worcester.edu>
To: guix-devel@gnu.org
Subject: [PATCH] scripts: package: Add --install-from-file option.
Date: Sun, 09 Aug 2015 11:59:19 -0400	[thread overview]
Message-ID: <8737zs78rs.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me> (raw)

[-- Attachment #1: Type: text/plain, Size: 650 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-scripts-package-Add-install-from-file-option.patch --]
[-- Type: text/x-patch, Size: 3335 bytes --]

From 07c9b35facf810872f3bc8342e18b33033714adf Mon Sep 17 00:00:00 2001
From: David Thompson <dthompson2@worcester.edu>
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


[-- Attachment #3: Type: text/plain, Size: 38 bytes --]


-- 
David Thompson
GPG Key: 0FF1D807

             reply	other threads:[~2015-08-09 15:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-09 15:59 David Thompson [this message]
2015-08-10 14:22 ` [PATCH] scripts: package: Add --install-from-file option Alex Kost
2015-08-18 19:30 ` Ludovic Courtès
2015-08-19  0:17   ` Thompson, David
2015-08-19 22:38     ` Ludovic Courtès
2015-08-20  2:26       ` Thompson, David
2015-08-19  8:27 ` Amirouche Boubekki
2015-08-19  8:56   ` Amirouche Boubekki
2015-08-19 14:48     ` Claes Wallin (韋嘉誠)
2015-08-19 13:04   ` Thompson, David
2015-08-19 13:54     ` Taylan Ulrich Bayırlı/Kammer
2015-08-19 15:31     ` Amirouche Boubekki
2015-08-19 19:15       ` Alex Kost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8737zs78rs.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me \
    --to=dthompson2@worcester.edu \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).