all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 54393@debbugs.gnu.org
Subject: [bug#54393] [PATCH 0/2] Add 'guix manifest' to "translate" commands to manifests
Date: Mon, 04 Apr 2022 10:37:26 -0400	[thread overview]
Message-ID: <87sfqszzh5.fsf_-_@gmail.com> (raw)
In-Reply-To: <20220331110957.31829-3-ludo@gnu.org> ("Ludovic Courtès"'s message of "Thu, 31 Mar 2022 13:09:57 +0200")

Hello,

Ludovic Courtès <ludo@gnu.org> writes:

> * guix/scripts/shell.scm (show-help, %options): Add '--export-manifest'.
> (manifest-entry-version-prefix, manifest->code*)
> (export-manifest): New procedures.
> (guix-shell): Honor '--export-manifest'.
> * tests/guix-shell-export-manifest.sh: New file.
> * Makefile.am (SH_TESTS): Add it.
> * doc/guix.texi (Invoking guix shell): Document '--export-manifest'.
> (Invoking guix environment): Link to it.
> (Invoking guix pack): Likewise.

[...]

> +\f
> +;;;
> +;;; Exporting a manifest.
> +;;;
> +
> +(define (manifest-entry-version-prefix entry)
> +  "Search among all the versions of ENTRY's package that are available, and
> +return the shortest unambiguous version prefix for this package."
> +  (package-unique-version-prefix (manifest-entry-name entry)
> +                                 (manifest-entry-version entry)))
> +
> +(define (manifest->code* manifest extra-manifests)
> +  "Like 'manifest->code', but insert a 'concatenate-manifests' call that
> +concatenates MANIFESTS, a list of expressions."
> +  (if (null? (manifest-entries manifest))
> +      (match extra-manifests
> +        ((one) one)
> +        (lst   `(concatenate-manifests ,@extra-manifests)))
> +      (match (manifest->code manifest
> +                             #:entry-package-version
> +                             manifest-entry-version-prefix)
> +        (('begin exp ... last)
> +         `(begin
> +            ,@exp
> +            ,(match extra-manifests
> +               (() last)
> +               (_  `(concatenate-manifests
> +                     (list ,last ,@extra-manifests)))))))))

Should an "else" clause be added here with a more useful error message
that the default 'no match for x' or similar?  If that'd be totally
unexpected and a bug, then it's fine as-is.

> +(define (export-manifest opts port)
> +  "Write to PORT a manifest corresponding to OPTS."
> +  (define (manifest-lift proc)
> +    (lambda (entry)
> +      (match (manifest-entry-item entry)
> +        ((? package? p)
> +         (manifest-entry
> +           (inherit (package->manifest-entry (proc p)))
> +           (output (manifest-entry-output entry))))
> +        (_
> +         entry))))
> +
> +  (define (validated-spec spec)
> +    ;; Return SPEC if it's validate package spec.

As this is an action (proc), perhaps it should be named "validate-spec".
The comment doc should also be worded as "if SPEC is a valid package
spec" or similar.

The rest LGTM.

Thank you for addressing the suggestion to reuse an existing sub-command
to try to keep things neatly organized instead of extending the already
large set of them :-).

Maxim




  reply	other threads:[~2022-04-04 14:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14 21:50 [bug#54393] [PATCH 0/2] Add 'guix manifest' to "translate" commands to manifests Ludovic Courtès
2022-03-14 21:51 ` [bug#54393] [PATCH 1/2] packages: Add 'package-unique-version-prefix' Ludovic Courtès
2022-03-14 21:51   ` [bug#54393] [PATCH 2/2] Add 'guix manifest' Ludovic Courtès
2022-03-15  7:18 ` [bug#54393] [PATCH 0/2] Add 'guix manifest' to "translate" commands to manifests Liliana Marie Prikler
2022-03-15  9:27   ` Ludovic Courtès
2022-03-15  9:53     ` Liliana Marie Prikler
2022-03-15 15:17       ` Ludovic Courtès
2022-03-15  9:00 ` zimoun
2022-03-15  9:23   ` Ludovic Courtès
2022-03-15 10:21     ` zimoun
2022-03-15 19:38       ` Ludovic Courtès
2022-03-31 11:09         ` [bug#54393] [PATCH v2 1/3] packages: Add 'package-unique-version-prefix' Ludovic Courtès
2022-03-31 11:09           ` [bug#54393] [PATCH v2 2/3] environment: Export 'load-manifest' Ludovic Courtès
2022-03-31 11:09           ` [bug#54393] [PATCH v2 3/3] shell: Add '--export-manifest' Ludovic Courtès
2022-04-04 14:37             ` Maxim Cournoyer [this message]
2022-04-04 21:16               ` bug#54393: [PATCH 0/2] Add 'guix manifest' to "translate" commands to manifests Ludovic Courtès
2022-04-05  5:48                 ` [bug#54393] " zimoun
2022-04-06  8:08                   ` Ludovic Courtès
2022-03-31 11:10         ` [bug#54393] [PATCH v2 0/3] Add '--export-manifest' to 'guix shell' Ludovic Courtès
2022-03-15 16:50 ` [bug#54393] [PATCH 0/2] Add 'guix manifest' to "translate" commands to manifests Greg Hogan
2022-03-16  9:58   ` Ludovic Courtès

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=87sfqszzh5.fsf_-_@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=54393@debbugs.gnu.org \
    --cc=ludo@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.