From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id UAJXJM+wh2HQxAAAgWs5BA (envelope-from ) for ; Sun, 07 Nov 2021 11:56:15 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 6MoEIM+wh2E3WAAA1q6Kng (envelope-from ) for ; Sun, 07 Nov 2021 10:56:15 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2381E11037 for ; Sun, 7 Nov 2021 11:56:15 +0100 (CET) Received: from localhost ([::1]:44084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mjfqQ-0004Wx-BI for larch@yhetil.org; Sun, 07 Nov 2021 05:56:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mjfqE-0004Tc-VZ for guix-patches@gnu.org; Sun, 07 Nov 2021 05:56:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:40320) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mjfqE-0006B4-GY for guix-patches@gnu.org; Sun, 07 Nov 2021 05:56:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mjfqD-0003JS-UG; Sun, 07 Nov 2021 05:56:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51655] [PATCH] build-system: haskell: Add =?UTF-8?Q?=E2=80=98package-with-explicit-haskell=E2=80=99?= procedure. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: lars@6xq.net, guix-patches@gnu.org Resent-Date: Sun, 07 Nov 2021 10:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51655 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51655@debbugs.gnu.org Cc: Lars-Dominik Braun X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Lars-Dominik Braun Received: via spool by submit@debbugs.gnu.org id=B.163628254212702 (code B ref -1); Sun, 07 Nov 2021 10:56:01 +0000 Received: (at submit) by debbugs.gnu.org; 7 Nov 2021 10:55:42 +0000 Received: from localhost ([127.0.0.1]:51864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mjfpt-0003In-Dn for submit@debbugs.gnu.org; Sun, 07 Nov 2021 05:55:41 -0500 Received: from lists.gnu.org ([209.51.188.17]:45730) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mjfpp-0003Ie-PR for submit@debbugs.gnu.org; Sun, 07 Nov 2021 05:55:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mjfpp-0004Q8-IS for guix-patches@gnu.org; Sun, 07 Nov 2021 05:55:37 -0500 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:34970 helo=mail.yoctocell.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mjfpm-00062X-OO for guix-patches@gnu.org; Sun, 07 Nov 2021 05:55:37 -0500 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1636282526; bh=1AbHFgRMuasz+k+7TOSLmKejvj3I1cIXwV211QsB9AU=; h=From:To:Subject:Date; b=iaVKIOYn8sKqEHueXmyuDIRkdS/ORoVjRgvYtpSgT5yTs9BP8qroPb323k6elvNDd yf5SshEXFZJkKe2kdoMiNCeMia4+smkYXDa/1DV6JAf11HlDB8aGia2QmPqvrav5yD 4smeRO3kjyMnHV2dgif0QXBbbCHWTdod4VSsmbs4= Message-Id: <7f7b889aebed4c17e3a021883bfed1d67c564109.1636216701.git.public@yoctocell.xyz> Date: Sun, 07 Nov 2021 11:55:25 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=87.96.130.155; envelope-from=public@yoctocell.xyz; helo=mail.yoctocell.xyz X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.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, FROM_SUSPICIOUS_NTLD=0.001, FROM_SUSPICIOUS_NTLD_FP=1.997, PDS_OTHER_BAD_TLD=0.001, PDS_RDNS_DYNAMIC_FP=0.001, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TO_NO_BRKTS_DYNIP=0.252 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1636282575; h=from:from:sender:sender: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:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=vI1mt0VWTCAQhG3/pkuSDctSKSo7JrG6HfhQO+1xJS4=; b=QdKEcp1fwpMzjqhcqJ+nbSxIEX4+ZwZnEX621rozI5Rq4LvV3YL8gyOpiULUQv1xxYmiwG ofrtCmffP4k8bSIUONGX/sIg8msBmWXA54oE7dSe54FQMoyI6EhxHJpS3vux7rVtJ8xQ0b almoR+hCNaXUdJwW/hH+0ZnC9A6YdoSsA2xRTeE33JJaS4/Mu3ZeT6cmb7Hi7BqfOkNf/q XRSRCvIDQRF77KR26KGD5fYDKRgrrvaFbqFksiK0C4T/78L/w7XwV+HjShgy7DXXSuEMxO 3/SWWo9o+C3S8Q1QYBPm4ztgwPS/iKbS5tikCyK92Z7EZQc9qwyLUGfoox118A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1636282575; a=rsa-sha256; cv=none; b=kGsFFfDj6k53PQR6Vfy04yrKDAvK5N1xlsHHB9o+9k226Nn0lnAoiNjIVD77FSbni97Glf p2VXfD8D6Zg03nOwZCZF3TzI88T3gOqWQaVpnscPTuyBv+0aV41vrIFotN3b+MMLHy+Y4/ TXxfNnZwX7i4/lo2wStI6p7viCPaw3fwUWzyU7ekVPJtV6/PvFY0IoUcHzWVVmZp+acXFH yKbgzFhZLCGRThAwiFfzeomGh+b4hF8tnT28GoDI1Cr6EHFSBWFD+9MsbYho9zGGkwWx5P oLnP48S29hbbloUlP1ZCXdb8efyIQVBILK06OSyynAesAYkFukSrgf9O92fIyQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=iaVKIOYn; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -0.32 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=iaVKIOYn; dmarc=fail reason="SPF not aligned (relaxed)" header.from=yoctocell.xyz (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 2381E11037 X-Spam-Score: -0.32 X-Migadu-Scanner: scn0.migadu.com X-TUID: AlWe/am/HxRK * guix/packages.scm (package-with-explicit-compiler): New procedure; factorized from =E2=80=98package-with-explicit-python=E2=80=99. * guix/build-system/python.scm (package-with-explicit-python): Use =E2=80=98package-with-explicit-compiler=E2=80=99. * guix/build-system/haskell.scm (package-with-explicit-haskell): New proced= ure. * doc/guix.texi (Defining Package Variants): Document it. --- doc/guix.texi | 37 ++++++++++++++++++ guix/build-system/haskell.scm | 8 ++++ guix/build-system/python.scm | 71 +++++++---------------------------- guix/packages.scm | 55 +++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 58 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index ea1973f02c..95fa5ab103 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -7717,6 +7717,43 @@ applied to implicit inputs as well. @end deffn =20 +@deffn {Scheme Procedure} package-with-explicit-compiler @var{compiler} @ +@var{keyword} @var{build-system} @var{old-prefix} @var{new-prefix} @ +[#:variant-property #f] +Return a procedure of one argument, @var{p}. The procedure creates a +package with the same fields as @var{p}, which is assumed to use +@var{build-system}, such that it is compiled with @var{compiler} +instead. @var{keyword} is a symbol whose name is the name of the +keyword for explicitly specifying a compiler, e.g., @code{python} for +@code{python-build-system}. The inputs are changed recursively +accordingly. If the name of @var{p} starts with @var{old-prefix}, this +is replaced by @var{new-prefix}; otherwise, @var{new-prefix} is +prepended to the name. + +When @var{variant-property} is present, it is used as a key to search +for pre-defined variants of this transformation recorded in the +@code{properties} field of packages. The property value must be the +promise of a package. This is a convenient way for package writers to +force the transformation to use pre-defined variants. + +You can for example define a procedure which given a Haskell package, +builds it and all of its recursive dependencies with GHC 8.8. + +@lisp +(use-modules (guix build-system haskell)) + +(define (default-haskell-8.8) + ;; Lazily resolve the binding to avoid a circular dependency. + (let ((haskell (resolve-interface '(gnu packages haskell)))) + (module-ref haskell 'ghc-8.8))) + +(define package-with-haskell-8.8 + (package-with-explicit-haskell (delay (default-haskell-8.8)) + "ghc-" "ghc-8.8-" + #:variant-property 'ghc-8.8-variant)) +@end lisp=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 +@end deffn + =20 @node Build Systems @section Build Systems diff --git a/guix/build-system/haskell.scm b/guix/build-system/haskell.scm index 18a584f782..8656e5f318 100644 --- a/guix/build-system/haskell.scm +++ b/guix/build-system/haskell.scm @@ -2,6 +2,7 @@ ;;; Copyright =C2=A9 2015 Federico Beffa ;;; Copyright =C2=A9 2020 Timothy Sample ;;; Copyright =C2=A9 2020 Simon Tournier +;;; Copyright =C2=A9 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -31,6 +32,7 @@ (define-module (guix build-system haskell) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:export (%haskell-build-system-modules + package-with-explicit-haskell haskell-build haskell-build-system)) =20 @@ -190,4 +192,10 @@ (define haskell-build-system (description "The standard Haskell build system") (lower lower))) =20 +(define* (package-with-explicit-haskell haskell old-prefix new-prefix + #:key variant-property) + (package-with-explicit-compiler haskell 'haskell haskell-build-system + old-prefix new-prefix + #:variant-property variant-property)) + ;;; haskell.scm ends here diff --git a/guix/build-system/python.scm b/guix/build-system/python.scm index 80895162f8..3d8b437d11 100644 --- a/guix/build-system/python.scm +++ b/guix/build-system/python.scm @@ -70,64 +70,6 @@ (define (default-python2) (let ((python (resolve-interface '(gnu packages python)))) (module-ref python 'python-2))) =20 -(define* (package-with-explicit-python python old-prefix new-prefix - #:key variant-property) - "Return a procedure of one argument, P. The procedure creates a package= with -the same fields as P, which is assumed to use PYTHON-BUILD-SYSTEM, such th= at -it is compiled with PYTHON instead. The inputs are changed recursively -accordingly. If the name of P starts with OLD-PREFIX, this is replaced by -NEW-PREFIX; otherwise, NEW-PREFIX is prepended to the name. - -When VARIANT-PROPERTY is present, it is used as a key to search for -pre-defined variants of this transformation recorded in the 'properties' f= ield -of packages. The property value must be the promise of a package. This i= s a -convenient way for package writers to force the transformation to use -pre-defined variants." - (define package-variant - (if variant-property - (lambda (package) - (assq-ref (package-properties package) - variant-property)) - (const #f))) - - (define (transform p) - (cond - ;; If VARIANT-PROPERTY is present, use that. - ((package-variant p) - =3D> force) - - ;; Otherwise build the new package object graph. - ((eq? (package-build-system p) python-build-system) - (package/inherit p - (location (package-location p)) - (name (let ((name (package-name p))) - (string-append new-prefix - (if (string-prefix? old-prefix name) - (substring name - (string-length old-prefix)) - name)))) - (arguments - (let ((python (if (promise? python) - (force python) - python))) - (ensure-keyword-arguments (package-arguments p) - `(#:python ,python)))))) - (else p))) - - (define (cut? p) - (or (not (eq? (package-build-system p) python-build-system)) - (package-variant p))) - - (package-mapping transform cut?)) - -(define package-with-python2 - ;; Note: delay call to 'default-python2' until after the 'arguments' fie= ld - ;; of packages is accessed to avoid a circular dependency when evaluating - ;; the top-level of (gnu packages python). - (package-with-explicit-python (delay (default-python2)) - "python-" "python2-" - #:variant-property 'python2-variant)) - (define (strip-python2-variant p) "Remove the 'python2-variant' property from P." (package/inherit p @@ -220,4 +162,17 @@ (define python-build-system (description "The standard Python build system") (lower lower))) =20 +(define* (package-with-explicit-python python old-prefix new-prefix + #:key variant-property) + (package-with-explicit-compiler python 'python python-build-system + old-prefix new-prefix + #:variant-property variant-property)) +(define package-with-python2 + ;; Note: delay call to 'default-python2' until after the 'arguments' fie= ld + ;; of packages is accessed to avoid a circular dependency when evaluating + ;; the top-level of (gnu packages python). + (package-with-explicit-python (delay (default-python2)) + "python-" "python2-" + #:variant-property 'python2-variant)) + ;;; python.scm ends here diff --git a/guix/packages.scm b/guix/packages.scm index 4b6098bb8d..81c5701886 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -130,6 +130,7 @@ (define-module (guix packages) package-with-extra-patches package-with-c-toolchain package/inherit + package-with-explicit-compiler =20 transitive-input-references =20 @@ -951,6 +952,60 @@ (define (package-with-c-toolchain package toolchain) (package/inherit package (build-system (build-system-with-c-toolchain bs toolchain))))) =20 +(define* (package-with-explicit-compiler compiler keyword build-system + old-prefix new-prefix + #:key variant-property) + "Return a procedure of one argument, P. The procedure creates a package= with +the same fields as P, which is assumed to use BUILD-SYSTEM, such that it is +compiled with COMPILER instead. KEYWORD is a symbol whose name is the nam= e of +the keyword for explicitly specifying a compiler, e.g., 'python' for +'python-build-system'. The inputs are changed recursively accordingly. If +the name of P starts with OLD-PREFIX, this is replaced by NEW-PREFIX; +otherwise, NEW-PREFIX is prepended to the name. + +When VARIANT-PROPERTY is present, it is used as a key to search for +pre-defined variants of this transformation recorded in the 'properties' f= ield +of packages. The property value must be the promise of a package. This i= s a +convenient way for package writers to force the transformation to use +pre-defined variants." + (define package-variant + (if variant-property + (lambda (package) + (assq-ref (package-properties package) + variant-property)) + (const #f))) + + (define (transform p) + (cond + ;; If VARIANT-PROPERTY is present, use that. + ((package-variant p) + =3D> force) + + ;; Otherwise build the new package object graph. + ((eq? (package-build-system p) build-system) + (package/inherit p + (location (package-location p)) + (name (let ((name (package-name p))) + (string-append new-prefix + (if (string-prefix? old-prefix name) + (substring name + (string-length old-prefix)) + name)))) + (arguments + (let ((compiler (if (promise? compiler) + (force compiler) + compiler))) + (ensure-keyword-arguments (package-arguments p) + `(,(symbol->keyword keyword) + ,compiler)))))) + (else p))) + + (define (cut? p) + (or (not (eq? (package-build-system p) build-system)) + (package-variant p))) + + (package-mapping transform cut?)) + (define (transitive-inputs inputs) "Return the closure of INPUTS when considering the 'propagated-inputs' edges. Omit duplicate inputs, except for those already present in INPUTS base-commit: 1ffc0a6be3c1613b2d99ceea098174d1f11f6f3f --=20 2.33.0