From debbugs-submit-bounces@debbugs.gnu.org Fri May 27 13:14:11 2022 Received: (at submit) by debbugs.gnu.org; 27 May 2022 17:14:11 +0000 Received: from localhost ([127.0.0.1]:35718 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nudXL-0002hp-Bp for submit@debbugs.gnu.org; Fri, 27 May 2022 13:14:11 -0400 Received: from lists.gnu.org ([209.51.188.17]:45930) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nudXG-0002hd-HL for submit@debbugs.gnu.org; Fri, 27 May 2022 13:14:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nudXG-0007sF-CF for guix-patches@gnu.org; Fri, 27 May 2022 13:14:02 -0400 Received: from mout-p-202.mailbox.org ([2001:67c:2050:0:465::202]:45024) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1nudXD-0001mG-Ef for guix-patches@gnu.org; Fri, 27 May 2022 13:14:01 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4L8rxY0nMtz9scn for ; Fri, 27 May 2022 19:13:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1653671633; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tvduaqSz4uEFMEcRBuQZqDw7D+oT1P7IXqDmkKyk/XI=; b=FgGGEEJOe9ZSWv25C5pN0iGnp+Kp1/cqpsp4y6zSBl1MTIFqqXGwTE28DEdmwxJgYmwUo7 TJEnKEAU4e+rLbRk7CJlXDSudTTkwP0FaJh2YsOOF7cP453SkMel5FGYHF8jlNnlMwrYPn g+YTfIM2aCLWmMqzpJCXzaIirDdgKubsDMzakIdI0a+CicSKvYc+kjjzQQFielkdrIErmF SFpLaeDdLgAaPQ1T62NoBFJevFWKX/arG5HY2OdPr5TRGGCtDAyTo3oPFl2bj2PA0FiYcn 8jEVVUCH2j3OU12/NGAXccOXyOdZDl/qqYtruj8FXHC/1FjaXSWRdbgt5BdS+g== From: Antero Mejr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1653671631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tvduaqSz4uEFMEcRBuQZqDw7D+oT1P7IXqDmkKyk/XI=; b=i4nKSF8k02TCh2zizND4V4PYJv3u5mWmcC8Dz3Xzu7OwobgcewvDTBkTxKXo6Kf3uw8mE5 40axzBDdhRtFXoT/l5mLqY0Bug9moshXeoKCLWO/RHQ2AS9bouMB3JL3FsO24dGkkfGiFD yLtnR2EX3GA2H9U1iE/zHdz7gWOKlz28Sxnt9GyQwKAraQq+FHL9sF6So/HQJgN00zqgov 9EC9+oOibEyqwcCR2yxzsJYsTKhILr0K/17nH3ZudiNBBA8OeRwtHjyrtd8JpWA2cWld8I zsPrmZzaWlphi7PXfli07PTt9Le/6V3POfjufdgo3WwOW+syPoJgmp3Tc19pxg== To: guix-patches@gnu.org Subject: [PATCH] packages: Add 'specifications->packages'. Date: Fri, 27 May 2022 13:13:28 -0400 Message-Id: <20220527171328.18174-1-antero@mailbox.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-MBO-RS-META: crz4qgno37wtnmf6gpjdruajj6o6ppkz X-MBO-RS-ID: 8f7444ce8de42bcb0b4 Received-SPF: pass client-ip=2001:67c:2050:0:465::202; envelope-from=antero@mailbox.org; helo=mout-p-202.mailbox.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Antero Mejr X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) * gnu/packages.scm (specifications->packages): New procedure. * guix/scripts/home/import.scm (manifest+configuration-files->code): Use it. --- Users of 'guix home' may not know the Scheme 'map' and 'compose' procedures. However 'guix home import' creates boilerplate with those procedures. Add 'specificiations->packages' procedure to make it more like a guix manifest. 'specfications->packages' can also help with guix system declarations. gnu/packages.scm | 11 ++++++++++- guix/scripts/home/import.scm | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gnu/packages.scm b/gnu/packages.scm index 2ba838fd0a..0cc22e64f9 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 @@ (define-module (gnu packages) specification->package+output specification->location specifications->manifest + specifications->packages package-unique-version-prefix @@ -554,13 +556,20 @@ (define* (specification->package+output spec #:optional (output "out")) (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 packages." + ;; 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 @@ (define (manifest+configuration-files->code manifest ,@(delete-duplicates (concatenate modules))) (home-environment - (packages (map (compose list specification->package+output) - ,packages)) + (packages (specifications->packages ,packages)) (services (list ,@services))))))))) (define* (import-manifest -- 2.36.1