[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Store channel specification in profile
From: |
Pierre Neidhardt |
Subject: |
Re: Store channel specification in profile |
Date: |
Tue, 11 Feb 2020 15:18:03 +0100 |
Ludovic Courtès <address@hidden> writes:
>> Same thing, what I had in mind was to store the version number in the
>> _serialized_ specifications.scm, as for the manifest.
>>
>> This way I believe we can support multiple version for specifications.scm.
>> Am I missing something?
>
> Then I don’t get how ‘specifications.scm’ would differ from ‘manifest’.
> In both cases we’re talking about a serialization format containing
> per-package provenance info, right?
The main differences:
- specifications.scm is a good fit to the --manifest argument.
- specifications.scm is human-editable because it does not contain
fields like the store path.
>> Yes, so I'll try to sum up what I want to achieve in one sentence:
>> "automate the textual serialization of profile specifications to
>> simplify their backup/deployment/reproduction".
>
> OK.
>
> To me, serialization is already automated: it’s the ‘manifest’ file.
>
> 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?
--8<---------------cut here---------------start------------->8---
;; 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<?))
;; 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))))
(_ (error "Please provide the path to a Guix profile.")))
--8<---------------cut here---------------end--------------->8---
--
Pierre Neidhardt
https://ambrevar.xyz/
signature.asc
Description: PGP signature