all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Oleg Pykhalov <go.wigust@gmail.com>
To: 34295@debbugs.gnu.org
Subject: [bug#34295] [PATCH] pull: Specify channels via command-line.
Date: Sun,  3 Feb 2019 14:37:49 +0300	[thread overview]
Message-ID: <20190203113749.14825-1-go.wigust@gmail.com> (raw)

* guix/scripts/pull.scm (show-help, %options): Add 'channel'.
(channel-list): Use this.
* doc/guix.texi (Invoking guix pull): Document this.
---
 doc/guix.texi         | 10 +++++++++-
 guix/scripts/pull.scm | 45 ++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 868f1959e8..ee854072e1 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -50,7 +50,7 @@ Copyright @copyright{} 2017 Andy Wingo@*
 Copyright @copyright{} 2017, 2018 Arun Isaac@*
 Copyright @copyright{} 2017 nee@*
 Copyright @copyright{} 2018 Rutger Helling@*
-Copyright @copyright{} 2018 Oleg Pykhalov@*
+Copyright @copyright{} 2018, 2019 Oleg Pykhalov@*
 Copyright @copyright{} 2018 Mike Gerwitz@*
 Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
 Copyright @copyright{} 2018 Gábor Boskovits@*
@@ -3564,6 +3564,14 @@ but it supports the following options:
 Download code from the specified @var{url}, at the given @var{commit} (a valid
 Git commit ID represented as a hexadecimal string), or @var{branch}.
 
+@item --channel=@var{name},@var{url}[,@var{branch}][,@var{commit}]
+Specify channels via command-line arguments ignoring @file{channels.scm}.
+
+@example
+guix pull --channel=guix,https://git.savannah.gnu.org/git/guix.git,branch=staging \
+          --channel=my-personal-packages,https://example.org/personal-packages.git
+@end example
+
 @cindex @file{channels.scm}, configuration file
 @cindex configuration file for channels
 These options are provided for convenience, but you can also specify your
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 683ab3f059..36c4967596 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013, 2014, 2015, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
+;;; Copyright © 2019 Oleg Pykhalov <go.wigust@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -76,6 +77,9 @@
 Download and deploy the latest version of Guix.\n"))
   (display (G_ "
       --verbose          produce verbose output"))
+  (display (G_ "
+      --channel=CHANNEL,URL[,branch][,commit]
+                         deploy the CHANNEL at URL"))
   (display (G_ "
   -C, --channels=FILE    deploy the channels defined in FILE"))
   (display (G_ "
@@ -128,6 +132,20 @@ Download and deploy the latest version of Guix.\n"))
          (option '("branch") #t #f
                  (lambda (opt name arg result)
                    (alist-cons 'ref `(branch . ,arg) result)))
+         (option '("channel") #t #f
+                 (lambda (opt name arg result . rest)
+                   (let ((list->alist (match-lambda
+                                        ((key value)
+                                         (cons key value)))))
+                     (alist-cons 'channel
+                                 (match (map (cut string-split <> #\=)
+                                             (string-split arg #\,))
+                                   (((name) (url) args ...)
+                                    (map list->alist
+                                         `(("name" ,name)
+                                           ("url" ,url)
+                                           ,@args))))
+                                 result))))
          (option '(#\p "profile") #t #f
                  (lambda (opt name arg result)
                    (alist-cons 'profile (canonicalize-profile arg)
@@ -477,8 +495,33 @@ transformations specified in OPTS (resulting from '--url', '--commit', or
           result
           (leave (G_ "'~a' did not return a list of channels~%") file))))
 
+  (define alist->channel
+    (match-lambda
+      ((_ meta ...)
+       (channel
+        (name (string->symbol (assoc-ref meta "name")))
+        (url (assoc-ref meta "url"))
+        (branch (or (assoc-ref meta "branch") "master"))
+        (commit (assoc-ref meta "commit"))))))
+
+  (define (guix-channel? channel)
+    (case (channel-name channel)
+      ((guix) #t)
+      (else #f)))
+
+  (define channel-options
+    (filter (match-lambda
+              (('channel args ...) #t)
+              (_ #f))
+            opts))
+
   (define channels
-    (cond (file
+    (cond (channel-options
+           (let ((channels (map alist->channel channel-options)))
+             (if (null? (filter guix-channel? channels))
+                 (append channels %default-channels)
+                 channels)))
+          (file
            (load-channels file))
           ((file-exists? default-file)
            (load-channels default-file))
-- 
2.20.1

             reply	other threads:[~2019-02-03 11:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-03 11:37 Oleg Pykhalov [this message]
2019-02-16 16:10 ` [bug#34295] [PATCH] pull: Specify channels via command-line Ludovic Courtès
2022-02-01 14:46 ` Ricardo Wurmus
2022-02-01 16:27   ` bug#34295: " Oleg Pykhalov

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

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

  git send-email \
    --in-reply-to=20190203113749.14825-1-go.wigust@gmail.com \
    --to=go.wigust@gmail.com \
    --cc=34295@debbugs.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.