From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id aFZsJeWfTGIuugAAgWs5BA (envelope-from ) for ; Tue, 05 Apr 2022 22:00:37 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id OCY0IuWfTGLV8wAAauVa8A (envelope-from ) for ; Tue, 05 Apr 2022 22:00:37 +0200 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 9FB37298F0 for ; Tue, 5 Apr 2022 22:00:36 +0200 (CEST) Received: from localhost ([::1]:52962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nbpLv-0000R8-IE for larch@yhetil.org; Tue, 05 Apr 2022 16:00:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nbkuY-0000rA-Iu for guix-patches@gnu.org; Tue, 05 Apr 2022 11:16:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:33735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nbkuY-0003ha-3N for guix-patches@gnu.org; Tue, 05 Apr 2022 11:16:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nbkuX-00031F-Ue for guix-patches@gnu.org; Tue, 05 Apr 2022 11:16:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries Resent-From: Philip Munksgaard Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 05 Apr 2022 15:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 54729 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54729@debbugs.gnu.org Cc: Philip Munksgaard X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164917175110930 (code B ref -1); Tue, 05 Apr 2022 15:16:01 +0000 Received: (at submit) by debbugs.gnu.org; 5 Apr 2022 15:15:51 +0000 Received: from localhost ([127.0.0.1]:55865 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nbkuM-0002pp-AT for submit@debbugs.gnu.org; Tue, 05 Apr 2022 11:15:51 -0400 Received: from lists.gnu.org ([209.51.188.17]:47680) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nbkuH-0002k1-9F for submit@debbugs.gnu.org; Tue, 05 Apr 2022 11:15:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nbkuF-0000g3-FW for guix-patches@gnu.org; Tue, 05 Apr 2022 11:15:45 -0400 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:36817) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nbku9-0003Yo-DR for guix-patches@gnu.org; Tue, 05 Apr 2022 11:15:39 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 804DA3201F94; Tue, 5 Apr 2022 11:15:33 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 05 Apr 2022 11:15:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=munksgaard.me; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to; s=fm1; bh=TqaJK+0aFPwcav/bZEWojcBBg2eUcA1CH70sE1 Qwu4U=; b=pp0lYF7TtnWG6sSuLjT9R5VHlTe4z+I60ONRnWcwWDmv8vcRdlKGK7 bIBwS6qEPpGoyL3BiMJFh6Sn5RVI9yGkrU0a6io1rZrIJo/lGdMFN4pW2E1bUc0h YyNryJVUOVvDfego6vPL1iJ8L627xlNjWrAvCT3ABvyRA+DZkgPAmz0Mbpdrh2t/ NjXyVUzNzk/fdFZk17ufXrlG9cn7QnqlqEBFj9JqBasFoJyph+neq2P3Mx+vYzaW ELcT2DuB/SjyXhEIMi48/arTFhIG+TiICoWjXUnOpmKqvJBeD+CHdH88aqNGxmgE INvbl5Jozsanv+MagS+09Co/IurdIy8A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=TqaJK+0aFPwcav/bZEWojcBBg2eUc A1CH70sE1Qwu4U=; b=b3u8mXQx4jlabL03lc6/f+pPccsjWLkRsvMhub8R9j0jR fGcMO4+t7TiUevZnwQH4nc4CTXU9QfUv1kv2kypUmMxXVzUQNHVs98rf199n4iR3 Pb9icRqSKcZ/ENbGatiN/RDR4lXi8/Voanc/7pe1ly1tE6LmHb7TtwNpAHO7hUWF qkbqvoketaeVUlHrLsiGJAk+BSKJw9T/AyyFcZXFOpdsnjmqlZz/WLxKIyrCM0m+ uFNiMRDM3vEWEc2mzeIyU9dnoUvbyEFXOb56ITiWv85ZnyczYKBnQlADuFhnQi0K uYz3ve2sFHZeHNewnN4i0ArFavXi418qHpam/uV5Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudejgedgkeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheprfhhihhlihhpucfouhhnkhhsghgrrghrugcuoehphhhilhhiphes mhhunhhkshhgrggrrhgurdhmvgeqnecuggftrfgrthhtvghrnhepveevkefhuedvtdffhf ekffeljefhueevjeejteeiteetudfhueffjefggeefveelnecuffhomhgrihhnpehgnhhu rdhorhhgpdhhrghskhgvlhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepphhhihhlihhpsehmuhhnkhhsghgrrghrugdrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 5 Apr 2022 11:15:31 -0400 (EDT) From: Philip Munksgaard Date: Tue, 5 Apr 2022 17:15:29 +0200 Message-Id: <8a396a9803fc35ee63f01e608f87ffb16863bc6d.1649171729.git.philip@munksgaard.me> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=64.147.123.20; envelope-from=philip@munksgaard.me; helo=wout4-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Tue, 05 Apr 2022 15:58:02 -0400 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 X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1649188837; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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=TqaJK+0aFPwcav/bZEWojcBBg2eUcA1CH70sE1Qwu4U=; b=CuGSMhKhjMJBCX4oa/gxPTP9HDwmi+vepJbQXflE/0A25Py6iCa3y89tFYnPs9mnoOk+n9 TeLlH68CWyckSGXNTHf7A4SW/TCCv8uQr8KVYQ6Ca5j2pN+5McIpxY3Uz3YHgzSxjONa87 GK8NzCwn+z5+QV5AZWXWSAk+RHPpdZN3J/KuA1ua3hL5vTy7K9a5i+m8qbUOjoNQTecL2V eaBqJIrnxJKKxVhhM2CqONJM+89l5ljPV4VKSkXQoUoGv4BSvVnN2hUkI3lpXigywxnbmD SRHqb4vEbGHw6jhFkLaib2tKA86AIip5VhNLkLf7ibLtyj4uzpL55lCQ1T5CCg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1649188837; a=rsa-sha256; cv=none; b=fDGsDdrO1cxkiS1K6Ej+vYFq41OnkvLXP8neYxabLgGqCoiAy61vmg1711V9dw9fiiQ8+r fwKLPjZ9hFiN927eVCoPRvAUwqzFLQpB4oJq/yj2FycR1HSzb9QuvILFHCCG+XQ6C/eDLW 3XnenHsjl4YmvqQthUd/aNUWLDGbAMTrD6sA/GPl6qGHQa0NcO9RLZl5jTPKWCxxgKIpNS NvU7aEFS8WVNnp59vyG6YpXchCk9qRZUFIuuA+yKc+S2wgTqrQuPOxAxda07+mVMaZH/f3 D5kyrfsbg0Wbmmhso0RsHcz0oDThAn6922yieS0gHHE4dJTvzPyzA8a2S5KVKA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=munksgaard.me header.s=fm1 header.b=pp0lYF7T; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm3 header.b=b3u8mXQx; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 1.23 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=munksgaard.me header.s=fm1 header.b=pp0lYF7T; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm3 header.b=b3u8mXQx; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 9FB37298F0 X-Spam-Score: 1.23 X-Migadu-Scanner: scn0.migadu.com X-TUID: 69MJFaCGLNN9 As discussed in #53655 [0], haskell-build-system.scm does not currently support packages which contain multiple libraries, such as attoparsec [1]. Such libraries are often used for internal or convenience libraries, as detailed in the documentation [2]. The current state of affairs means that attoparsec and any other libraries with similar structure cannot be built on guix, nor can any library or executable that depends on such a library. Instead of assuming that `runhaskell Setup.hs --gen-pkg-config=...` always outputs a single file, we detect whether the result was a directory. If so, we need to handle each file independently in lexicographic order by calling the new private function `install-from-config-file`. Because `install-transitive-deps` can now be called multiple times for each call to `register`, it has also been amended to support the files already installed. 0: https://issues.guix.gnu.org/53655 1: https://hackage.haskell.org/package/attoparsec-0.14.4/attoparsec.cabal 2: https://downloads.haskell.org/cabal/Cabal-3.0.0.0/doc/users-guide/installing-packages.html#cmdoption-setup-register-gen-pkg-config --- guix/build/haskell-build-system.scm | 34 ++++++++++++++++++----------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm index ef6cb316ee..e827e23aba 100644 --- a/guix/build/haskell-build-system.scm +++ b/guix/build/haskell-build-system.scm @@ -217,11 +217,13 @@ (define* (register #:key name system inputs outputs #:allow-other-keys) (if (not (vhash-assoc id seen)) (let ((dep-conf (string-append src "/" id ".conf")) (dep-conf* (string-append dest "/" id ".conf"))) - (when (not (file-exists? dep-conf)) + (unless (file-exists? dep-conf*) + (when (not (file-exists? dep-conf)) (error (format #f "File ~a does not exist. This usually means the dependency ~a is missing. Was checking conf-file ~a." dep-conf id conf-file))) - (copy-file dep-conf dep-conf*) ;XXX: maybe symlink instead? - (loop (vhash-cons id #t seen) - (append lst (conf-depends dep-conf)))) + (copy-file dep-conf dep-conf*) ;XXX: maybe symlink instead? + + (loop (vhash-cons id #t seen) + (append lst (conf-depends dep-conf*))))) (loop seen tail)))))) (let* ((out (assoc-ref outputs "out")) @@ -234,13 +236,12 @@ (define* (register #:key name system inputs outputs #:allow-other-keys) "/ghc-" version "/" name ".conf.d")) (id-rx (make-regexp "^id:[ \n\t]+([^ \t\n]+)$" regexp/newline)) - (config-file (string-append out "/" name ".conf")) + (config-output (string-append out "/" name ".conf")) (params - (list (string-append "--gen-pkg-config=" config-file)))) + (list (string-append "--gen-pkg-config=" config-output)))) (run-setuphs "register" params) - ;; The conf file is created only when there is a library to register. - (when (file-exists? config-file) - (mkdir-p config-dir) + + (define (install-from-config-file config-file) (let* ((contents (call-with-input-file config-file read-string)) (config-file-name+id (match:substring (first (list-matches id-rx contents)) 1))) @@ -270,10 +271,17 @@ (define* (register #:key name system inputs outputs #:allow-other-keys) (install-transitive-deps config-file %tmp-db-dir config-dir) (rename-file config-file (string-append config-dir "/" - config-file-name+id ".conf")) - (invoke "ghc-pkg" - (string-append "--package-db=" config-dir) - "recache"))) + config-file-name+id ".conf")))) + + ;; The conf file is created only when there is a library to register. + (when (file-exists? config-output) + (mkdir-p config-dir) + (if (file-is-directory? config-output) + (for-each install-from-config-file (find-files config-output)) + (install-from-config-file config-output)) + (invoke "ghc-pkg" + (string-append "--package-db=" config-dir) + "recache")) #t)) (define* (check #:key tests? test-target #:allow-other-keys) -- 2.35.1