summaryrefslogtreecommitdiff
path: root/guix/scripts/home
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-10-30 23:30:50 +0200
committerLudovic Courtès <ludo@gnu.org>2021-10-31 00:51:06 +0200
commit96728c54df365cc48f14a514b63616ff7a6d052b (patch)
treeb864c2a72312a2fe77019f4744d3b95b886fdae5 /guix/scripts/home
parentf3933ae40d4192fa3aeff95ac768bab86ade766f (diff)
home: import: Factorize triplicated 'version-spec' procedure.
* guix/scripts/package.scm (manifest-entry-version-prefix): New procedure, moved from... (export-manifest)[version-spec]: ... here. Adjust caller. * tests/home-import.scm (version-spec): Remove. (eval-test-with-home-environment): Use 'manifest-entry-version-prefix' instead. * guix/scripts/home/import.scm (import-manifest): Likewise.
Diffstat (limited to 'guix/scripts/home')
-rw-r--r--guix/scripts/home/import.scm23
1 files changed, 2 insertions, 21 deletions
diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index a51f7f504b..8f6b3b58aa 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -22,6 +22,7 @@
#:use-module (guix ui)
#:use-module (guix utils)
#:use-module (guix packages)
+ #:autoload (guix scripts package) (manifest-entry-version-prefix)
#:use-module (gnu packages)
#:use-module (ice-9 match)
#:use-module (ice-9 pretty-print)
@@ -241,28 +242,8 @@ containing PACKAGES, or SPECS (package specifications), and SERVICES."
manifest destination-directory
#:optional (port (current-output-port)))
"Write to PORT a <home-environment> corresponding to MANIFEST."
- (define (version-spec entry)
- (let ((name (manifest-entry-name entry)))
- (match (map package-version (find-packages-by-name name))
- ((_)
- ;; A single version of NAME is available, so do not specify the
- ;; version number, even if the available version doesn't match ENTRY.
- "")
- (versions
- ;; If ENTRY uses the latest version, don't specify any version.
- ;; Otherwise return the shortest unique version prefix. Note that
- ;; this is based on the currently available packages, which could
- ;; differ from the packages available in the revision that was used
- ;; to build MANIFEST.
- (let ((current (manifest-entry-version entry)))
- (if (every (cut version>? current <>)
- (delete current versions))
- ""
- (version-unique-prefix (manifest-entry-version entry)
- versions)))))))
-
(match (manifest->code manifest destination-directory
- #:entry-package-version version-spec
+ #:entry-package-version manifest-entry-version-prefix
#:home-environment? #t)
(('begin exp ...)
(format port (G_ "\