all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Pierre Neidhardt <mail@ambrevar.xyz>
Cc: Guix Devel <guix-devel@gnu.org>
Subject: Re: Store channel specification in profile
Date: Mon, 24 Feb 2020 17:16:25 +0100	[thread overview]
Message-ID: <87ftf0j6zq.fsf@gnu.org> (raw)
In-Reply-To: <87imkdky1w.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Tue, 11 Feb 2020 15:18:03 +0100")

Hi Pierre,

Pierre Neidhardt <mail@ambrevar.xyz> skribis:

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

[...]

>> What we lack is the ability to obtain a “manifest.scm” kind of file
>> (code) that users can pick as a starting point in their migration
>> towards declarative deployment.
>
> You mean a script like the following?
>
> ;; Run with:
> ;;     guile -s FILE ~/.guix-profile
>
> (use-modules (guix profiles)
>              (gnu packages)             ; fold-packages
>              (guix packages)            ; package structure
>              (ice-9 match)
>              (ice-9 pretty-print))
>
>
> (define (packages-by-name name)
>   (fold-packages (lambda (package list)
>                    (if (string=? (package-name package) name)
>                        (cons package list)
>                        list))
>                  '()))
>
> (define (guix-manifest where)
>   (sort (map (lambda (entry)
>                (let* ((name (manifest-entry-name entry))
>                       (out (manifest-entry-output entry))
>                       (version (manifest-entry-version entry))
>                       (default-version (match (packages-by-name name)
>                                          ((first-name . rest)
>                                           (package-version
>                                            first-name))
>                                          (else #f))))
>                  (string-append name
>                                 (if (and default-version
>                                          (not (string= version default-version)))
>                                     (format #f "@~a" version)
>                                     "")
>                                 (if (string= out "out")
>                                     ""
>                                     (format #f ":~a" out)))))
>              (manifest-entries (profile-manifest where)))
>         string<?))

Yes!  That alone would already be a useful tool to migrate from the
“imperative” style to the declarative style.  I’m sure it’d be good
enough 90% of the time.

(Note: we should remove the ‘sort’ call here as the order of packages in
the manifest is significant when there are file collisions.)

How does that sound?  Would you like to integrate something like this,
maybe ‘guix package --export’ or something?

> ;; Thanks to Ivan Vilata-i-Balaguer for this:
> (define (guix-commit)
>   (let ((guix-manifest (profile-manifest (string-append (getenv "HOME") "/.config/guix/current"))))
>     (match (assq 'source (manifest-entry-properties (car (manifest-entries guix-manifest))))
>       (('source ('repository ('version 0) _ _
>                              ('commit commit) _ ...))
>        commit)
>       (_ #f))))
>
> (match (command-line)
>   ((_ where)
>    (format #t ";; commit: ~a\n" (guix-commit))
>    (pretty-print
>     `(specifications->manifest
>       ',(guix-manifest where))))

Emitting channel info as comments like this, and/or a warning when
there’s a conflict (packages coming from different commits of the same
channel) could be done as a second step.

Thanks,
Ludo’.

  reply	other threads:[~2020-02-24 16:16 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-26 14:55 Store channel specification in profile Pierre Neidhardt
2019-11-26 16:40 ` Konrad Hinsen
2019-11-26 19:12   ` Pierre Neidhardt
2019-11-26 19:35     ` Konrad Hinsen
2019-12-02 15:58       ` zimoun
2019-12-09 17:11   ` Ludovic Courtès
2019-12-09 17:21     ` Pierre Neidhardt
2019-12-12 19:50       ` zimoun
2019-12-12 22:35         ` Pierre Neidhardt
2019-12-13 12:16           ` zimoun
2019-12-19 16:12             ` Ludovic Courtès
2019-12-19 17:18               ` zimoun
2020-01-06 20:07         ` Pierre Neidhardt
2020-01-06 21:09           ` zimoun
2020-01-08 15:17             ` Pierre Neidhardt
2020-01-08 19:31               ` zimoun
2020-01-11 23:48               ` Ludovic Courtès
2020-01-13 14:02                 ` Pierre Neidhardt
2020-01-13 14:46                   ` zimoun
2020-01-13 14:37                 ` zimoun
2020-01-13 14:59                   ` Pierre Neidhardt
2020-01-13 15:53                     ` zimoun
2020-01-13 16:53                       ` Pierre Neidhardt
2020-01-30 19:24                         ` Pierre Neidhardt
2020-01-31  8:51                           ` zimoun
2020-01-31  9:21                           ` Konrad Hinsen
2020-01-31 11:21                             ` Pierre Neidhardt
2020-01-31 12:15                               ` Pierre Neidhardt
2020-01-31 16:01                                 ` Konrad Hinsen
2020-02-05 11:08                           ` Ludovic Courtès
2020-02-06 10:59                             ` Pierre Neidhardt
2020-02-07 21:28                               ` Ludovic Courtès
2020-02-08 17:09                                 ` Pierre Neidhardt
2020-02-11 14:10                                   ` Ludovic Courtès
2020-02-11 14:18                                     ` Pierre Neidhardt
2020-02-24 16:16                                       ` Ludovic Courtès [this message]
2020-02-25 10:32                                         ` Pierre Neidhardt
2020-03-03 21:43                                           ` zimoun
2020-03-04  8:09                                             ` Pierre Neidhardt
2020-03-04 13:24                                               ` zimoun
2020-03-03 21:49                                         ` zimoun

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=87ftf0j6zq.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=mail@ambrevar.xyz \
    /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.