From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Subject: Re: Store channel specification in profile Date: Mon, 24 Feb 2020 17:16:25 +0100 Message-ID: <87ftf0j6zq.fsf@gnu.org> References: <87blsyelgm.fsf@ambrevar.xyz> <87tv69bezo.fsf@gnu.org> <87zhg1xvmo.fsf@ambrevar.xyz> <874kx8gxh1.fsf@ambrevar.xyz> <87blreasgd.fsf@ambrevar.xyz> <87pnfpsgfx.fsf@gnu.org> <87a76rqu5j.fsf@ambrevar.xyz> <877e1vqowd.fsf@ambrevar.xyz> <87zhe4px2a.fsf@ambrevar.xyz> <87wo91p9yt.fsf@gnu.org> <87eev8gewx.fsf@ambrevar.xyz> <87pneq140d.fsf@gnu.org> <8736bldmzr.fsf@ambrevar.xyz> <87zhdp2p16.fsf@gnu.org> <87imkdky1w.fsf@ambrevar.xyz> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:39060) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6GPH-0002I7-E4 for guix-devel@gnu.org; Mon, 24 Feb 2020 11:16:32 -0500 In-Reply-To: <87imkdky1w.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Tue, 11 Feb 2020 15:18:03 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane-mx.org@gnu.org Sender: "Guix-devel" To: Pierre Neidhardt Cc: Guix Devel Hi Pierre, Pierre Neidhardt skribis: > Ludovic Court=C3=A8s writes: [...] >> What we lack is the ability to obtain a =E2=80=9Cmanifest.scm=E2=80=9D k= ind 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=3D? (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=3D version default-= version))) > (format #f "@~a" version) > "") > (if (string=3D out "out") > "" > (format #f ":~a" out))))) > (manifest-entries (profile-manifest where))) > string ;; 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-entrie= s 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=E2=80=99s a conflict (packages coming from different commits of the s= ame channel) could be done as a second step. Thanks, Ludo=E2=80=99.