From 7041fe0646a9603e7d1d6bde139a284146515917 Mon Sep 17 00:00:00 2001 From: Antero Mejr Date: Fri, 27 May 2022 13:13:28 -0400 Subject: packages: Add 'specifications->packages'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/packages.scm (specifications->packages): New procedure. * guix/scripts/home/import.scm (manifest+configuration-files->code): Use it. * tests/home-import.scm (match-home-environment-no-services) (match-home-environment-no-services-nor-packages) (match-home-environment-bash-service) (match-home-environment-bash-service-with-alias): Adjust 'packages' field accordingly. Co-authored-by: Ludovic Courtès --- gnu/packages.scm | 11 ++++++++++- guix/scripts/home/import.scm | 4 ++-- tests/home-import.scm | 13 +++++-------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/gnu/packages.scm b/gnu/packages.scm index 2ba838fd0a..ab722d00d8 100644 --- a/gnu/packages.scm +++ b/gnu/packages.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2014 Eric Bavier ;;; Copyright © 2016, 2017 Alex Kost ;;; Copyright © 2016 Mathieu Lirzin +;;; Copyright © 2022 Antero Mejr ;;; ;;; This file is part of GNU Guix. ;;; @@ -65,6 +66,7 @@ specification->package+output specification->location specifications->manifest + specifications->packages package-unique-version-prefix @@ -554,13 +556,20 @@ output." (package-full-name package) sub-drv)))))) +(define (specifications->packages specs) + "Given SPECS, a list of specifications such as \"emacs@25.2\" or +\"guile:debug\", return a list of package/output tuples." + ;; This procedure exists so users of 'guix home' don't have to write out the + ;; (map (compose list specification->package+output)... boilerplate. + (map (compose list specification->package+output) specs)) + (define (specifications->manifest specs) "Given SPECS, a list of specifications such as \"emacs@25.2\" or \"guile:debug\", return a profile manifest." ;; This procedure exists mostly so users of 'guix package -m' don't have to ;; fiddle with multiple-value returns. (packages->manifest - (map (compose list specification->package+output) specs))) + (specifications->packages specs))) (define (package-unique-version-prefix name version) "Search among all the versions of package NAME that are available, and diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index 575fe8f688..825ccb1e73 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2021 Andrew Tropin ;;; Copyright © 2021-2022 Ludovic Courtès ;;; Copyright © 2022 Arjan Adriaanse +;;; Copyright © 2022 Antero Mejr ;;; ;;; This file is part of GNU Guix. ;;; @@ -170,8 +171,7 @@ user's files to CONFIGURATION-DIRECTORY; the generated sexp refers to them." ,@(delete-duplicates (concatenate modules))) (home-environment - (packages (map (compose list specification->package+output) - ,packages)) + (packages (specifications->packages ,packages)) (services (list ,@services))))))))) (define* (import-manifest diff --git a/tests/home-import.scm b/tests/home-import.scm index ca8aa95431..d62a6de648 100644 --- a/tests/home-import.scm +++ b/tests/home-import.scm @@ -103,8 +103,8 @@ corresponding file." ('gnu 'services)) ('home-environment ('packages - ('map ('compose 'list 'specification->package+output) - ('list "guile@2.0.9" "gcc:lib" "glibc@2.19"))) + ('specifications->packages + ('list "guile@2.0.9" "gcc:lib" "glibc@2.19"))) ('services ('list))))) @@ -132,8 +132,7 @@ corresponding file." ('gnu 'services)) ('home-environment ('packages - ('map ('compose 'list 'specification->package+output) - ('list))) + ('specifications->packages ('list))) ('services ('list))))) @@ -147,8 +146,7 @@ corresponding file." ('gnu 'home 'services 'shells)) ('home-environment ('packages - ('map ('compose 'list 'specification->package+output) - ('list))) + ('specifications->packages ('list))) ('services ('list ('service 'home-bash-service-type @@ -168,8 +166,7 @@ corresponding file." ('gnu 'home 'services 'shells)) ('home-environment ('packages - ('map ('compose 'list 'specification->package+output) - ('list))) + ('specifications->packages ('list))) ('services ('list ('service 'home-bash-service-type -- cgit v1.2.3