GNU bug report logs - #70265
Add docker cli Guix Home service and some docker authentication plugins

Previous Next

Package: guix-patches;

Reported by: paul <goodoldpaul <at> autistici.org>

Date: Sun, 7 Apr 2024 20:56:04 UTC

Severity: normal

Full log


Message #17 received at 70265 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Giacomo Leidi <goodoldpaul <at> autistici.org>
Cc: 70265 <at> debbugs.gnu.org, Andrew Tropin <andrew <at> trop.in>,
 Tanguy Le Carrour <tanguy <at> bioneland.org>, paren <at> disroot.org
Subject: Re: bug#70265: Add docker cli Guix Home service and some docker
 authentication plugins
Date: Sat, 04 May 2024 18:36:14 +0200
Hi,

Giacomo Leidi <goodoldpaul <at> autistici.org> skribis:

> * gnu/home/services/containers.scm (home-docker-cli-service-type): New
> variable;
> * doc/guix.texi: document it;
> * gnu/local.mk: add it.

Nice.  For the documentation part, the convention is something like:

  * doc/guix.texi (Miscellaneous Services)[Container Services]: New
  heading.

> +@cindex docker cli service, for Home

s/docker cli/Docker command-line interface/

> +The @code{(gnu home services containers)} module provides the following service:
> +
> +@defvar home-docker-cli-service-type
> +This service allows for configuring the Docker command line interface, for
> +example to make it aware of Guix provided plugins.
> +@end defvar
> +
> +For example, you can use it like this to make Docker safely store your registry
> +credentials with the system
> +@uref{https://wiki.gnome.org/Projects/Libsecret, libsecret} compatible Secret service:

Rather:

  @uref{https://wiki.gnome.org/Projects/Libsecret, libsecret-compatible}
  secret service:

(So that the parenthesized URL appears in the right place in Info and
PDF.)

> +@lisp
> +(use-modules (gnu packages docker))
> +
> +(service home-docker-cli-service-type
> +         (docker-cli-configuration
> +           (creds-store "secretservice")
> +           (cli-plugins
> +             (list docker-credential-secretservice))
> +           (extra-content ", \"auths\": @{\"https://index.docker.io/v1/\": @{@}@}")))

Sounds scary: how can I know as a user where that comma is going to be
stuck in the resulting file?  Providing partial JSON strings should
rather be avoided IMO.

Also, if that part is necessary, it should be explained.

> +(define (format-name name)
> +  (define without-dashes (string-replace-substring (symbol->string name) "-" " "))
> +  (define splitted (string-split without-dashes #\space))
> +  (string-replace-substring
> +   (apply string-append
> +          `(,(car splitted)
> +            ,@(map string-capitalize (cdr splitted))))
> +   " " ""))

Rather:

  (match split  ;past participate of “to split”
    ((head . rest)
     (string-concatenate (cons head (map string-capitalize rest)))))

See
<https://guix.gnu.org/manual/devel/en/html_node/Data-Types-and-Pattern-Matching.html>
for the rationale.

> +(define docker-cli-configuration->json-fields
> +  (lambda (config)
> +    (filter (compose not (lambda (f) (or (null? f) (and (string? f) (string-null? f)))))
> +            (map (lambda (f)

To improve readability, I’d make it:

  (filter-map (lambda (f)
                (match f
                  (() #f)
                  ("" #f)
                  (_ …)))
               docker-cli-configuration-fields)

> +(define (home-docker-cli-configuration-file config)
> +  `((".docker/config.json"
> +     ,(computed-file "docker-cli-config.json"
> +       #~(with-output-to-file #$output
> +           (lambda _
> +             (display
> +              (string-append "{"
> +                             (string-join (list #$@(docker-cli-configuration->json-fields config)) ",")
> +                             #$(docker-cli-configuration-extra-content config)

I think the comma should be automatically added when ‘extra-content’ is
non-empty.

A more general question: do you think this particular example (libsecret
plugin) could be solved in another way without involving Home?  (For
example by having a plugin search path in the package.)

Do you have other use cases in mind?

The reason I’m asking is that it feels heavyweight for what looks like
“basic” Docker configuration.  But maybe Docker is like this and a Home
service is what it takes to make it more easily configurable (I’m not
really familiar with Docker), in which case I’m all for this patch
series!

Thanks,
Ludo’.




This bug report was last modified 1 year and 29 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.