[PATCH] pull: Specify channels via command-line.

  • Done
  • quality assurance status badge
Details
3 participants
  • Oleg Pykhalov
  • Ludovic Courtès
  • Ricardo Wurmus
Owner
unassigned
Submitted by
Oleg Pykhalov
Severity
normal
O
O
Oleg Pykhalov wrote on 3 Feb 2019 12:37
(address . guix-patches@gnu.org)(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
20190203113749.14825-1-go.wigust@gmail.com
* 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(-)

Toggle diff (108 lines)
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
L
L
Ludovic Courtès wrote on 16 Feb 2019 17:10
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 34295@debbugs.gnu.org)
87h8d3hfy7.fsf@gnu.org
Hi Oleg,

Oleg Pykhalov <go.wigust@gmail.com> skribis:

Toggle quote (4 lines)
> * guix/scripts/pull.scm (show-help, %options): Add 'channel'.
> (channel-list): Use this.
> * doc/guix.texi (Invoking guix pull): Document this.

Why not, but I wonder if we really want to do this much on the command
line? Do you personally find it more convenient than having a
channels.scm file?

What do people think?

Toggle quote (6 lines)
> + (cond (channel-options
> + (let ((channels (map alist->channel channel-options)))
> + (if (null? (filter guix-channel? channels))
> + (append channels %default-channels)
> + channels)))

(null? (filter …)) → (not (any guix-channel? channels))

But note that %DEFAULT-CHANNELS possibly contains more than the 'guix
channel so this test is not quite accurate.

Thanks,
Ludo’.
R
R
Ricardo Wurmus wrote on 1 Feb 2022 15:46
[PATCH] pull: Specify channels via command-line.
(address . 34295@debbugs.gnu.org)
878ruu8wvu.fsf@elephly.net
Hi Oleg,

are you still interested in this patch?

I think it’s going just a little beyond what a command line option
should do, especially considering that with Bash an ad-hoc file handle
could be passed to the channels option.

--
Ricardo
O
O
Oleg Pykhalov wrote on 1 Feb 2022 17:27
(name . Ricardo Wurmus)(address . rekado@elephly.net)(address . 34295-done@debbugs.gnu.org)
87o83qeenf.fsf@gmail.com
Hi,

Apologies for this forgotten patch.

Ricardo Wurmus <rekado@elephly.net> writes:

Toggle quote (2 lines)
> are you still interested in this patch?

No.

Toggle quote (4 lines)
> I think it’s going just a little beyond what a command line option
> should do, especially considering that with Bash an ad-hoc file handle
> could be passed to the channels option.

OK, then I'll close the issue.

Thanks,
Oleg.
-----BEGIN PGP SIGNATURE-----

iQJIBAEBCgAyFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAmH5X1QUHGdvLndpZ3Vz
dEBnbWFpbC5jb20ACgkQFn+OpQAa+pxAAhAAyWCQxYJM5aXyYJ4WqHoxplo5LkH9
mSppkvJiKHFlKC7RHVhfLfB25CyywyiswJbxNBz95h6cppduHj+NEa0/0pDAZkAz
5e38lToqDYGI51LNaOwdaRcozmeA6WGLLCrKvuC/lRVS0ZkatXYDl0t0wldVUzdB
fMc/qelHG8t1q5B9hNQz9/Z3sY4WPV6QClWfJ4ujuxjqxsvqO1ziwFjdbYv2WEZy
f3XO8zLFibnaXMszoJb7nztxzy5Yg/u09V524o9JKoJ6M57jnxCxaZXWl2jSuJ4n
l2BQGJpXUcLGx8S3Qkm3tHH7fPHSAVGkqV3mEr9/2PmMChExO3Ge7OzHuT7Va2VT
Fc/9kFXpfnVHM4odT3lzh5/Xm7YEG3A84nqYu1KNrHwmZcMr6/exCsXYfrQTmFAU
03xOgG/p71aOf82WUNQabapTiySvsPRMcf/Ih9qzc2UDCVOSIupkvXgm6zmllbfT
589qaZZZSuMR6RpoeNyeqXscBxnhUqFXTanw4ubrOv32PBj4i0R9kAmHO87tg+W/
PuOeSvYVo+x1iT7rcM6YIi7+kjVUgFppJ9ImWPQCnoekm8uhqzvgyUDY1KUJgZXY
w5i4yaRWgxIo/zF1S8fcyIcLOVsZQVJ5kuGaEQdBaDlHHjetC8ZcqN7ZpB+F/HXc
egg79I6ihrMXeR0=
=uITx
-----END PGP SIGNATURE-----

Closed
?