From unknown Fri Jun 13 10:31:25 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#48999 <48999@debbugs.gnu.org> To: bug#48999 <48999@debbugs.gnu.org> Subject: Status: [PATCH] import: hackage: Accept local source for package. Reply-To: bug#48999 <48999@debbugs.gnu.org> Date: Fri, 13 Jun 2025 17:31:25 +0000 retitle 48999 [PATCH] import: hackage: Accept local source for package. reassign 48999 guix-patches submitter 48999 Xinglu Chen severity 48999 normal tag 48999 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 13 05:46:39 2021 Received: (at submit) by debbugs.gnu.org; 13 Jun 2021 09:46:39 +0000 Received: from localhost ([127.0.0.1]:42666 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lsMhT-00014m-79 for submit@debbugs.gnu.org; Sun, 13 Jun 2021 05:46:39 -0400 Received: from lists.gnu.org ([209.51.188.17]:55044) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lsMhQ-00014e-Ud for submit@debbugs.gnu.org; Sun, 13 Jun 2021 05:46:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsMhQ-0000i2-LK for guix-patches@gnu.org; Sun, 13 Jun 2021 05:46:36 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:53950 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 1lsMhN-00089e-Db for guix-patches@gnu.org; Sun, 13 Jun 2021 05:46:35 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1623577588; bh=13HwuM+W10K50OxZZqlbf5b4vPH1I4XgZpSAPa1+Rw0=; h=From:To:Subject:Date; b=cJCsMgxH/WYPOGp6qUhyJbJPhNKzCkfYBeZcEL09mGXMrqjmBMMN19mAGrE4yNNmM mHPsNACk67K++LdcNfEocRhLugQt9j2WousfzPqF5kQqzFALjR/zVjQGDV6Ava6cJK Nw4zhE5jWfEN0W8UtoS1HL9iScUQZPEcKM24ZtbU= To: guix-patches@gnu.org Subject: [PATCH] import: hackage: Accept local source for package. Message-Id: Date: Sun, 13 Jun 2021 11:46:18 +0200 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: 30 X-Spam_score: 3.0 X-Spam_bar: +++ X-Spam_report: (3.0 / 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.498, FROM_SUSPICIOUS_NTLD_FP=1.593, PDS_OTHER_BAD_TLD=1.997, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 2.8 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When developing a Haskell package it is often useful to have a Guix package definition for that package, previously one would have to write that package definition by hand, and if the .cabal file chan [...] Content analysis details: (2.8 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [209.51.188.17 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [209.51.188.17 listed in wl.mailspike.net] 1.6 FROM_SUSPICIOUS_NTLD_FP From abused NTLD 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 0.0 T_FILL_THIS_FORM_SHORT Fill in a short form with personal information X-Debbugs-Envelope-To: submit 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: 0.2 (/) When developing a Haskell package it is often useful to have a Guix package definition for that package, previously one would have to write that package definition by hand, and if the .cabal file changed one would manually update the Guix package definition. This commit allows one to specify a custom source for their package, meaning that one could programatically generate a Guix package definition for their local Haskell package. If the .cabal file changes, the generated package definition will also change accordingly. One could for instance write the following in a guix.scm file: (define-values (ghc-haskeme deps) (call-with-input-file "haskeme.cabal" (lambda (port) (hackage->guix-package "haskeme" #:port port #:source (local-file "." "haskeme-checkout" #:recursive? #t #:select? hg-predicate))))) ghc-haskeme Invoking =E2=80=98guix build -f guix.scm=E2=80=99 would then always build a= n up-to-date version of the package. * guix/import/hackage.scm (hackage-module->sexp): Add optional keyword argument =E2=80=98source=E2=80=99 (hackage->guix-package): Likewise. * tests/hackage.scm (eval-test-with-cabal): Likewise. ("hackage->guix-package local source"): New test. --- Without this I would have to manually write my Guix package definition, and manually update the =E2=80=98inputs=E2=80=99 field if I added a new dep= endency in my .cabal file. This patch offers something similar to pkgs.callCabal2nix (I could find any link to the docs, classic Nix) in Nixpkgs where i can just write the following --8<---------------cut here---------------start------------->8--- let haskellPackages =3D pkgs.haskell.packages.${compiler}.override { overrides =3D hpNew: hpOld: { haskeme =3D hpNew.callCabal2nix "haskeme" ./. { }; }; }; in { haskeme =3D haskellPackages.haskeme; } --8<---------------cut here---------------end--------------->8--- to get a Nix package definition of my Haskell package. guix/import/hackage.scm | 43 ++++++++++++++++++++++++++--------------- tests/hackage.scm | 28 +++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm index f94a1e7087..326ab92365 100644 --- a/guix/import/hackage.scm +++ b/guix/import/hackage.scm @@ -227,10 +227,13 @@ package being processed and is used to filter referen= ces to itself." dependencies)) =20 (define* (hackage-module->sexp cabal cabal-hash - #:key (include-test-dependencies? #t)) + #:key + (include-test-dependencies? #t) + (source #f)) "Return the `package' S-expression for a Cabal package. CABAL is the -representation of a Cabal file as produced by 'read-cabal'. CABAL-HASH is -the hash of the Cabal file." +representation of a Cabal file as produced by 'read-cabal'. CABAL-HASH is= the +hash of the Cabal file. If SOURCE is specified, it will be used as the so= urce +for the package." =20 (define name (cabal-package-name cabal)) @@ -294,20 +297,24 @@ the hash of the Cabal file." (() '()) (args `((arguments (,'quasiquote ,args)))))) =20 - (let ((tarball (with-store store - (download-to-store store source-url)))) + (let ((tarball (if source + #f + (with-store store + (download-to-store store source-url))))) (values `(package (name ,(hackage-name->package-name name)) (version ,version) - (source (origin - (method url-fetch) - (uri (string-append ,@(factorize-uri source-url version)= )) - (sha256 - (base32 - ,(if tarball - (bytevector->nix-base32-string (file-sha256 tarba= ll)) - "failed to download tar archive"))))) + (source ,(if source + source + `(origin + (method url-fetch) + (uri (string-append ,@(factorize-uri source-url ve= rsion))) + (sha256 + (base32 + ,(if tarball + (bytevector->nix-base32-string (file-sha256= tarball)) + "failed to download tar archive")))))) (build-system haskell-build-system) ,@(maybe-inputs 'inputs dependencies) ,@(maybe-inputs 'native-inputs native-dependencies) @@ -321,10 +328,12 @@ the hash of the Cabal file." (define* (hackage->guix-package package-name #:key (include-test-dependencies? #t) (port #f) + (source #f) (cabal-environment '())) "Fetch the Cabal file for PACKAGE-NAME from hackage.haskell.org, or, if = the -called with keyword parameter PORT, from PORT. Return the `package' -S-expression corresponding to that package, or #f on failure. +called with keyword parameter PORT, from PORT. If SOURCE is specified, us= e it +as the source for the package instead of trying to fetch a tarball. Return +the `package' S-expression corresponding to that package, or #f on failure. CABAL-ENVIRONMENT is an alist defining the environment in which the Cabal conditionals are evaluated. The accepted keys are: \"os\", \"arch\", \"im= pl\" and the name of a flag. The value associated with a flag has to be either= the @@ -338,7 +347,9 @@ respectively." (hackage-fetch-and-hash package-name)))) (and=3D> cabal-meta (compose (cut hackage-module->sexp <> cabal-hash #:include-test-dependencies? - include-test-dependencies?) + include-test-dependencies? + #:source + source) (cut eval-cabal <> cabal-environment))))) =20 (define hackage->guix-package/m ;memoized variant diff --git a/tests/hackage.scm b/tests/hackage.scm index 66a13d9881..54590dcece 100644 --- a/tests/hackage.scm +++ b/tests/hackage.scm @@ -22,6 +22,7 @@ #:use-module (guix import cabal) #:use-module (guix import hackage) #:use-module (guix tests) + #:use-module (guix gexp) #:use-module (srfi srfi-64) #:use-module (ice-9 match)) =20 @@ -186,9 +187,28 @@ library ('description (? string?)) ('license 'license:bsd-3))) =20 -(define* (eval-test-with-cabal test-cabal matcher #:key (cabal-environment= '())) +(define-package-matcher match-ghc-foo-local-source + ('package + ('name "ghc-foo") + ('version "1.0.0") + ('source + (? file-like?)) + ('build-system 'haskell-build-system) + ('inputs + ('quasiquote + (("ghc-http" ('unquote 'ghc-http))))) + ('home-page "http://test.org") + ('synopsis (? string?)) + ('description (? string?)) + ('license 'license:bsd-3))) + +(define* (eval-test-with-cabal test-cabal matcher + #:key (cabal-environment '()) (source #f)) (define port (open-input-string test-cabal)) - (matcher (hackage->guix-package "foo" #:port port #:cabal-environment ca= bal-environment))) + (matcher (hackage->guix-package "foo" + #:port port + #:cabal-environment cabal-environment + #:source source))) =20 (test-assert "hackage->guix-package test 1" (eval-test-with-cabal test-cabal-1 match-ghc-foo)) @@ -208,6 +228,10 @@ library (eval-test-with-cabal test-cabal-5 match-ghc-foo #:cabal-environment '(("impl" . "ghc-7.8")))) =20 +(test-assert "hackage->guix-package local source" + (eval-test-with-cabal test-cabal-1 match-ghc-foo-local-source + #:source (plain-file "dummy source" "source"))) + (define-package-matcher match-ghc-foo-6 ('package ('name "ghc-foo") base-commit: acb858881901aa28499f83f40d3e04d6e4749453 --=20 2.32.0 From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 29 05:44:51 2021 Received: (at 48999) by debbugs.gnu.org; 29 Jun 2021 09:44:51 +0000 Received: from localhost ([127.0.0.1]:53634 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyAIU-0003Xv-PT for submit@debbugs.gnu.org; Tue, 29 Jun 2021 05:44:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46748) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyAIS-0003XX-Mo for 48999@debbugs.gnu.org; Tue, 29 Jun 2021 05:44:48 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:49012) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyAIM-0005YN-Ia; Tue, 29 Jun 2021 05:44:42 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42522 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyAIM-0002gC-Aw; Tue, 29 Jun 2021 05:44:42 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Xinglu Chen Subject: Re: bug#48999: [PATCH] import: hackage: Accept local source for package. References: Date: Tue, 29 Jun 2021 11:44:40 +0200 In-Reply-To: (Xinglu Chen's message of "Sun, 13 Jun 2021 11:46:18 +0200") Message-ID: <87wnqdt37b.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.3 (/) X-Debbugs-Envelope-To: 48999 Cc: 48999@debbugs.gnu.org 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: -1.3 (-) Hi, Xinglu Chen skribis: > When developing a Haskell package it is often useful to have a Guix packa= ge > definition for that package, previously one would have to write that pack= age > definition by hand, and if the .cabal file changed one would manually upd= ate > the Guix package definition. > > This commit allows one to specify a custom source for their package, mean= ing > that one could programatically generate a Guix package definition for the= ir > local Haskell package. If the .cabal file changes, the generated package > definition will also change accordingly. One could for instance write the > following in a guix.scm file: > > (define-values (ghc-haskeme deps) > (call-with-input-file "haskeme.cabal" > (lambda (port) > (hackage->guix-package > "haskeme" > #:port port > #:source (local-file "." "haskeme-checkout" > #:recursive? #t > #:select? hg-predicate))))) > > ghc-haskeme > > Invoking =E2=80=98guix build -f guix.scm=E2=80=99 would then always build= an up-to-date > version of the package. > > * guix/import/hackage.scm (hackage-module->sexp): Add optional keyword > argument =E2=80=98source=E2=80=99 > (hackage->guix-package): Likewise. > * tests/hackage.scm (eval-test-with-cabal): Likewise. > ("hackage->guix-package local source"): New test. Looks like a nice improvement. What I don=E2=80=99t get is that this functionality doesn=E2=80=99t seem to= be available from the CLI, which the patch doesn=E2=80=99t change. Or am I missing something? Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 29 15:00:16 2021 Received: (at 48999) by debbugs.gnu.org; 29 Jun 2021 19:00:16 +0000 Received: from localhost ([127.0.0.1]:55385 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyIy0-0005J7-EQ for submit@debbugs.gnu.org; Tue, 29 Jun 2021 15:00:16 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:60042 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyIxy-0005Iq-3C for 48999@debbugs.gnu.org; Tue, 29 Jun 2021 15:00:15 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1624993208; bh=5b0KFqtsrE2dssXz3WVT6A/f/3RshwZdAtOgxNjM39M=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=dXI0hoEQUgwcn36ibACsRV2Boa/In9XBdHHkpLLINA7wTGSjEFD6oms7oGoC//iaV Qshse7Lhik1gzVDUJXvEiLMuh5pZMx8vDeq2p0d4tQRH5ShH54LYYMUSEf6jCe0CAc RcWUi0vDRYvEgVCJI/hBHHxTOuCusao1aPAqlRkI= To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#48999] [PATCH] import: hackage: Accept local source for package. In-Reply-To: <87wnqdt37b.fsf@gnu.org> References: <87wnqdt37b.fsf@gnu.org> Date: Tue, 29 Jun 2021 21:00:07 +0200 Message-ID: <874kdgbio8.fsf@yoctocell.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Spam-Score: 2.9 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On Tue, Jun 29 2021, Ludovic Courtès wrote: > Hi, > > Xinglu Chen skribis: > >> When developing a Haskell package it is often useful to have a Guix package >> definition for that package, previously one would have to writ [...] Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS X-Debbugs-Envelope-To: 48999 Cc: 48999@debbugs.gnu.org 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.9 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On Tue, Jun 29 2021, Ludovic Courtès wrote: > Hi, > > Xinglu Chen skribis: > >> When developing a Haskell package it is often useful to have a Guix package >> definition for that package, previously one would have to writ [...] Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 1.0 BULK_RE_SUSP_NTLD Precedence bulk and RE: from a suspicious TLD 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Tue, Jun 29 2021, Ludovic Court=C3=A8s wrote: > Hi, > > Xinglu Chen skribis: > >> When developing a Haskell package it is often useful to have a Guix pack= age >> definition for that package, previously one would have to write that pac= kage >> definition by hand, and if the .cabal file changed one would manually up= date >> the Guix package definition. >> >> This commit allows one to specify a custom source for their package, mea= ning >> that one could programatically generate a Guix package definition for th= eir >> local Haskell package. If the .cabal file changes, the generated package >> definition will also change accordingly. One could for instance write t= he >> following in a guix.scm file: >> >> (define-values (ghc-haskeme deps) >> (call-with-input-file "haskeme.cabal" >> (lambda (port) >> (hackage->guix-package >> "haskeme" >> #:port port >> #:source (local-file "." "haskeme-checkout" >> #:recursive? #t >> #:select? hg-predicate))))) >> >> ghc-haskeme >> >> Invoking =E2=80=98guix build -f guix.scm=E2=80=99 would then always buil= d an up-to-date >> version of the package. >> >> * guix/import/hackage.scm (hackage-module->sexp): Add optional keyword >> argument =E2=80=98source=E2=80=99 >> (hackage->guix-package): Likewise. >> * tests/hackage.scm (eval-test-with-cabal): Likewise. >> ("hackage->guix-package local source"): New test. > > Looks like a nice improvement. > > What I don=E2=80=99t get is that this functionality doesn=E2=80=99t seem = to be available > from the CLI, which the patch doesn=E2=80=99t change. Or am I missing > something? No, I don=E2=80=99t think this functionality is available from the CLI since =E2=80=98hackage->guix-package=E2=80=99 is not called with the #:source key= word argument. Once all the other importers (or those where it makes sense to do this) get this functionality, it would be a good idea to add an option for reading a .cabal/setup.py/whatever file and generating a package definition from that. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmDbbbcVHHB1YmxpY0B5 b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5ht4P/Rw4PHbyvzzc8DTqpSjo1KuRyYah u9TTtjED/QqWpZ+eIKtfgdAyCvFDGRDLcWcjaXG+l5i9+BLxXmQpeF5zFb+z9a5i /1EUlpz8i/vY4flX0uo/iz4xkmAtjoJo6sPZwWmEvlItHAMpCPe/5e7mlnzOw1wf DDBJP6DvMJSFtBGmdtW7HFYYMVHaVqw6xX3hUTkOTOc7XmvXEVPjYLPyB6r4fmH9 Wl62Eyhnu4ARYbNBVrrz9Ot7Zq1hwFQl5oqljti05TmA/Lhlz9HtN5ipNt0f5qCm Uy29UnvIwGFHPiEaF/rYhVEoZreXfFh9s1KrONoQOeF0aksEPakJk4b/qHbUVLWx GbOgrFUqAfRiqmZG1x2RYpe+O1EOEDe0ukeNJE9njBJv6svN4GvvJ3hHMOp3+7Ck jOv0w+FZ7MNqxd40dSiDTEbu2Oaj36XYG0gdIiF5dQvdrcUGes2sd8uC7ciMFg9E BvzWhMndiiTkn13ndFl2D6BvAdqDNHnZKPJ+ZVS2g7XSAH3gS6js0id0O4ku+dYY al5p2lLzjDaJGNrcrD17FVXPpDzKTzYQfi/6smWYL1uw6mTZT5aLokDdQ1Pydh8I OZ4s4+8MCQ9vWGAgfNe78IZuwwzdkMiAB7ZAKgb9yoyy99lb5nPQ0H20hubOfzRZ +BvRci5vmFZN5nm8 =QQ7p -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 30 05:17:20 2021 Received: (at 48999) by debbugs.gnu.org; 30 Jun 2021 09:17:20 +0000 Received: from localhost ([127.0.0.1]:56442 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyWLQ-0007dP-Ik for submit@debbugs.gnu.org; Wed, 30 Jun 2021 05:17:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35304) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyWLO-0007dD-NK for 48999@debbugs.gnu.org; Wed, 30 Jun 2021 05:17:19 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:32910) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyWLI-0007TT-TC; Wed, 30 Jun 2021 05:17:12 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42574 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyWLI-0005Gi-Li; Wed, 30 Jun 2021 05:17:12 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Xinglu Chen Subject: Re: [bug#48999] [PATCH] import: hackage: Accept local source for package. References: <87wnqdt37b.fsf@gnu.org> <874kdgbio8.fsf@yoctocell.xyz> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 12 Messidor an 229 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 30 Jun 2021 11:17:11 +0200 In-Reply-To: <874kdgbio8.fsf@yoctocell.xyz> (Xinglu Chen's message of "Tue, 29 Jun 2021 21:00:07 +0200") Message-ID: <877dibpv8o.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.3 (/) X-Debbugs-Envelope-To: 48999 Cc: 48999@debbugs.gnu.org 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: -1.3 (-) Hi, Xinglu Chen skribis: > On Tue, Jun 29 2021, Ludovic Court=C3=A8s wrote: > >> Hi, >> >> Xinglu Chen skribis: >> >>> When developing a Haskell package it is often useful to have a Guix pac= kage >>> definition for that package, previously one would have to write that pa= ckage >>> definition by hand, and if the .cabal file changed one would manually u= pdate >>> the Guix package definition. >>> >>> This commit allows one to specify a custom source for their package, me= aning >>> that one could programatically generate a Guix package definition for t= heir >>> local Haskell package. If the .cabal file changes, the generated packa= ge >>> definition will also change accordingly. One could for instance write = the >>> following in a guix.scm file: >>> >>> (define-values (ghc-haskeme deps) >>> (call-with-input-file "haskeme.cabal" >>> (lambda (port) >>> (hackage->guix-package >>> "haskeme" >>> #:port port >>> #:source (local-file "." "haskeme-checkout" >>> #:recursive? #t >>> #:select? hg-predicate))))) >>> >>> ghc-haskeme >>> >>> Invoking =E2=80=98guix build -f guix.scm=E2=80=99 would then always bui= ld an up-to-date >>> version of the package. >>> >>> * guix/import/hackage.scm (hackage-module->sexp): Add optional keyword >>> argument =E2=80=98source=E2=80=99 >>> (hackage->guix-package): Likewise. >>> * tests/hackage.scm (eval-test-with-cabal): Likewise. >>> ("hackage->guix-package local source"): New test. >> >> Looks like a nice improvement. >> >> What I don=E2=80=99t get is that this functionality doesn=E2=80=99t seem= to be available >> from the CLI, which the patch doesn=E2=80=99t change. Or am I missing >> something? > > No, I don=E2=80=99t think this functionality is available from the CLI si= nce > =E2=80=98hackage->guix-package=E2=80=99 is not called with the #:source k= eyword > argument. IOW, this functionality is not accessible, unless you use the Scheme API as in the example above, right? > Once all the other importers (or those where it makes sense to do > this) get this functionality, it would be a good idea to add an option > for reading a .cabal/setup.py/whatever file and generating a package > definition from that. =E2=80=98guix import hackage=E2=80=99 could support it even if other import= ers don=E2=80=99t have equivalent functionality, no? Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 30 10:20:34 2021 Received: (at 48999) by debbugs.gnu.org; 30 Jun 2021 14:20:34 +0000 Received: from localhost ([127.0.0.1]:58416 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyb4s-0003oj-3z for submit@debbugs.gnu.org; Wed, 30 Jun 2021 10:20:34 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]:39564) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyb4q-0003oW-Gs for 48999@debbugs.gnu.org; Wed, 30 Jun 2021 10:20:33 -0400 Received: by mail-wr1-f42.google.com with SMTP id f14so3495661wrs.6 for <48999@debbugs.gnu.org>; Wed, 30 Jun 2021 07:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding; bh=uPAlMGi6hQQuqKS5m8P7pJLgswkI9UoAInQ0cUZqlpk=; b=rQhvFvAuhOfl0kezeR2vO5fbXZKZt6yocI56upl5po8Qqo5wW9HYMdeGBG/Sp1oBVi luJswaZH18x1tY7ZrBCo1XHMK+u0xzfuiK4I7z2GTPsa6d3l15+X4aa2NH1HXzLsT06G la8shbKH4l8ZvxRwbuA3uX8yX3ivCEUId7QoTgzpJcreVr7jUwO94qvvYVKGLnvU7auh zr0rkYeF3kzHSDmmbdDVKi13K4d2o7zLgCJ2TLYu+bQ2e330xO157IZ0h3fiyItLmlc4 +WHStKwXw95U0giQq/VUAVXrb620Y8VuVPr9kMF/L6JzuBWpv7bf+q7lbniygVCxdjz0 w0KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=uPAlMGi6hQQuqKS5m8P7pJLgswkI9UoAInQ0cUZqlpk=; b=BBQNHaRfSxVWzZzNpjvZM9d9pkaiNZpljeKycM1LYkGZC1GJ4Qt5szty2C9XPU4iu3 SxCQRQ25LX3BWX5tKvqArX/S77glcHIooNXgLk9J1gghzgy8R+cTVx1SRjUTNopF7pmS veN+GwM8pHYNdXElJhcOEUXG3L+sWPb0p560RAPjUNcNE/J2+JScc/hkofwOHg2lxzkQ thqnoehAfqNCdB6D9liXppo/rC+Q6M4OzYoT5x2j8c/ieDECj+jpq787mc7CuXazc8ug wjx/A6XTUbu2yHE3ELsPnDCITR2EMSO6Y6fhGfzQpe8M86Pi603vvOG6tGcN91zpxfr+ hXQw== X-Gm-Message-State: AOAM533NL3gdsgXx/bvlPmszCyOAG2bua4s02HvxWQWqnLJhX6FrerjM SYg/AbKqXlQrq5gGkh4BjeJr4gDBxSs= X-Google-Smtp-Source: ABdhPJx2eW95V+hR6RLv88+eJtu+ybGfwJsbfzCyCo/GsezvTlILgrTrqEmpyd4m7HDAkg9pLg7XNQ== X-Received: by 2002:adf:f94c:: with SMTP id q12mr39441950wrr.417.1625062826612; Wed, 30 Jun 2021 07:20:26 -0700 (PDT) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id e12sm22508957wrw.34.2021.06.30.07.20.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 07:20:26 -0700 (PDT) From: zimoun To: Ludovic =?utf-8?Q?Court=C3=A8s?= , Xinglu Chen Subject: Re: [bug#48999] [PATCH] import: hackage: Accept local source for package. In-Reply-To: <877dibpv8o.fsf@gnu.org> References: <87wnqdt37b.fsf@gnu.org> <874kdgbio8.fsf@yoctocell.xyz> <877dibpv8o.fsf@gnu.org> Date: Wed, 30 Jun 2021 16:10:51 +0200 Message-ID: <86pmw3789g.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi, On Wed, 30 Jun 2021 at 11:17, Ludovic Courtès wrote: >>> Xinglu Chen skribis: >>>> (define-values (ghc-haskeme deps) >>>> (call-with-input-file "haskeme.cabal" >>>> (lambda (port) >>>> (hackage->guix-package >>>> "haskeme" >>>> #:port port >>>> #:source (local-file "." "haskeme [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zimon.toutoune[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.221.42 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.221.42 listed in wl.mailspike.net] X-Debbugs-Envelope-To: 48999 Cc: 48999@debbugs.gnu.org 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: 1.0 (+) Hi, On Wed, 30 Jun 2021 at 11:17, Ludovic Court=C3=A8s wrote: >>> Xinglu Chen skribis: >>>> (define-values (ghc-haskeme deps) >>>> (call-with-input-file "haskeme.cabal" >>>> (lambda (port) >>>> (hackage->guix-package >>>> "haskeme" >>>> #:port port >>>> #:source (local-file "." "haskeme-checkout" >>>> #:recursive? #t >>>> #:select? hg-predicate))))) >>>> >>>> ghc-haskeme >>>> >>>> Invoking =E2=80=98guix build -f guix.scm=E2=80=99 would then always bu= ild an up-to-date >>>> version of the package. [...] >>> What I don=E2=80=99t get is that this functionality doesn=E2=80=99t see= m to be available >>> from the CLI, which the patch doesn=E2=80=99t change. Or am I missing >>> something? >> >> No, I don=E2=80=99t think this functionality is available from the CLI s= ince >> =E2=80=98hackage->guix-package=E2=80=99 is not called with the #:source = keyword >> argument. > > IOW, this functionality is not accessible, unless you use the Scheme API > as in the example above, right? > >> Once all the other importers (or those where it makes sense to do >> this) get this functionality, it would be a good idea to add an option >> for reading a .cabal/setup.py/whatever file and generating a package >> definition from that. > > =E2=80=98guix import hackage=E2=80=99 could support it even if other impo= rters don=E2=80=99t > have equivalent functionality, no? >From my understanding, there are 2 levels: 1. simplify the Scheme snippet for developing local =E2=80=9Cforeign=E2=80= =9D package, i.e., =E2=80=9Cguix build -f guix.scm=E2=80=9D with a simpler =E2=80=99gui= x.scm=E2=80=99 file. 2. an option to import local package, e.g., =E2=80=9Cguix import hackage --path=3D.=E2=80=9D and this for (almost) all the importers. Cheers, simon From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 04 06:43:23 2021 Received: (at 48999) by debbugs.gnu.org; 4 Jul 2021 10:43:23 +0000 Received: from localhost ([127.0.0.1]:40395 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lzzat-0004nB-6Z for submit@debbugs.gnu.org; Sun, 04 Jul 2021 06:43:23 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:43838 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lzzas-0004mx-94 for 48999@debbugs.gnu.org; Sun, 04 Jul 2021 06:43:22 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1625395396; bh=XTrSNa4I8RT4loz7D3+82fxlmtdhAMbzSpUQ8Ha65I4=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=CyxUARXGEBtqJklgHlFPQxJtowfG/8FBypkaykFFtwByqSOsO5bHaT5q0zzQ0jRPN Ep+WG1nl54ZUfqpKS/ru8dT/uSFOX8diiY7s17mC0ui4Ar9FQyTblt5qO974uLK0xM LR2DtlXe9Qh82Jwuj+deVihC2Fl1YueXCe4tMzaM= To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#48999] [PATCH] import: hackage: Accept local source for package. In-Reply-To: <877dibpv8o.fsf@gnu.org> References: <87wnqdt37b.fsf@gnu.org> <874kdgbio8.fsf@yoctocell.xyz> <877dibpv8o.fsf@gnu.org> Date: Sun, 04 Jul 2021 12:43:11 +0200 Message-ID: <87h7hajr5s.fsf@yoctocell.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Spam-Score: 2.9 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On Wed, Jun 30 2021, Ludovic Courtès wrote: > Hi, > > Xinglu Chen skribis: > >> On Tue, Jun 29 2021, Ludovic Courtès wrote: >> >>> Hi, >>> >>> Xinglu Chen skribis: >>> >>>> When developing a Haskel [...] Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps X-Debbugs-Envelope-To: 48999 Cc: 48999@debbugs.gnu.org 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.9 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On Wed, Jun 30 2021, Ludovic Courtès wrote: > Hi, > > Xinglu Chen skribis: > >> On Tue, Jun 29 2021, Ludovic Courtès wrote: >> >>> Hi, >>> >>> Xinglu Chen skribis: >>> >>>> When developing a Haskel [...] Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 1.0 BULK_RE_SUSP_NTLD Precedence bulk and RE: from a suspicious TLD 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, Jun 30 2021, Ludovic Court=C3=A8s wrote: > Hi, > > Xinglu Chen skribis: > >> On Tue, Jun 29 2021, Ludovic Court=C3=A8s wrote: >> >>> Hi, >>> >>> Xinglu Chen skribis: >>> >>>> When developing a Haskell package it is often useful to have a Guix pa= ckage >>>> definition for that package, previously one would have to write that p= ackage >>>> definition by hand, and if the .cabal file changed one would manually = update >>>> the Guix package definition. >>>> >>>> This commit allows one to specify a custom source for their package, m= eaning >>>> that one could programatically generate a Guix package definition for = their >>>> local Haskell package. If the .cabal file changes, the generated pack= age >>>> definition will also change accordingly. One could for instance write= the >>>> following in a guix.scm file: >>>> >>>> (define-values (ghc-haskeme deps) >>>> (call-with-input-file "haskeme.cabal" >>>> (lambda (port) >>>> (hackage->guix-package >>>> "haskeme" >>>> #:port port >>>> #:source (local-file "." "haskeme-checkout" >>>> #:recursive? #t >>>> #:select? hg-predicate))))) >>>> >>>> ghc-haskeme >>>> >>>> Invoking =E2=80=98guix build -f guix.scm=E2=80=99 would then always bu= ild an up-to-date >>>> version of the package. >>>> >>>> * guix/import/hackage.scm (hackage-module->sexp): Add optional keyword >>>> argument =E2=80=98source=E2=80=99 >>>> (hackage->guix-package): Likewise. >>>> * tests/hackage.scm (eval-test-with-cabal): Likewise. >>>> ("hackage->guix-package local source"): New test. >>> >>> Looks like a nice improvement. >>> >>> What I don=E2=80=99t get is that this functionality doesn=E2=80=99t see= m to be available >>> from the CLI, which the patch doesn=E2=80=99t change. Or am I missing >>> something? >> >> No, I don=E2=80=99t think this functionality is available from the CLI s= ince >> =E2=80=98hackage->guix-package=E2=80=99 is not called with the #:source = keyword >> argument. > > IOW, this functionality is not accessible, unless you use the Scheme API > as in the example above, right? Yes. >> Once all the other importers (or those where it makes sense to do >> this) get this functionality, it would be a good idea to add an option >> for reading a .cabal/setup.py/whatever file and generating a package >> definition from that. > > =E2=80=98guix import hackage=E2=80=99 could support it even if other impo= rters don=E2=80=99t > have equivalent functionality, no? Sure, that could work too. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmDhkL8VHHB1YmxpY0B5 b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5v9gP/3ILbHXZ8Dr9zpUJfDufEUsCfQNF Ws2UNRvmE1AFvclQTOjnvZih2UcLUa/3IRlUryuGkAUAEMExapUx70UjZUhx3VWI LUZ52xvmnlCo1IbKOLmyTtY3fMEyUQChDw8CojUywj4xJOpW2VIIWEu4Vs4Q3IWs OQY5X4rByuVgQDxpzD31Rnf6uXmNPjSLa6Dudm/6g3PFffy6f7JahaRx5QDpBsOh I+vv1ejii1kEu8RAacg1y51i1CDq05/FmNAYzkXudfjqFOuK5XEwfYT/n+OuKtpH r3LDiycVjbxUuWiLGX/nnJxt7APAnuyrgCKonVONpiimpPgThsTdEs0MVIV+UHnY Bq4nV3STIsRPjPV/sa9vGbYPsX2ahwJunLMvrX9HV+REYtoDYYCnoGg6GdcHghV9 gcXppPNZtRun7FTG9ffA5a6K189fpwOHPykKBytvm4Vn35JBriBmB6EwoRsN5wyR B72q7MXRDfWh422HSWmhSzQKw4JLMTimegFnoQLopKI68zTqxoKI0lA9KeXPtm/x vjPugFRAVJnW7PX0ZhZn0NF52+PNjBnziSFh7M/46/hriHjDbm2U6jFdd1LmjHit m1/1yXIAdEtwaE+KDHwh8XR3G4MGXk6go6qUnpdJFa7TtbICCsdDTzFyHX6hT6R6 6LHJ1xJw8ROAsX8G =44ix -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 04 07:54:06 2021 Received: (at 48999) by debbugs.gnu.org; 4 Jul 2021 11:54:06 +0000 Received: from localhost ([127.0.0.1]:40452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m00hK-0000aC-C9 for submit@debbugs.gnu.org; Sun, 04 Jul 2021 07:54:06 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:45454 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m00hF-0000ZV-B9 for 48999@debbugs.gnu.org; Sun, 04 Jul 2021 07:54:05 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1625399635; bh=jrUqyumQKRk4wdUQhhBweIIPYeCJ2qERuzvGMB/+slI=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=rwYSJt92nKs3BUru8dEBLf1i8chWj0ZBY9rYtsaY9e4+0NrSxvgRqBC85uOdfVJ/y DSPYrlERGL5DYOK592Y9HgEetFrAGnXPCsaVFdIBi8bUFdyv+q8FmVSEJaVQJNHeX5 uUbaTFq9RDR6qTz5K3IRIGdLgh0ZkucBE7LpzXwQ= To: 48999@debbugs.gnu.org Subject: [PATCH v2 0/3] Import Haskell packages from the local filesystem In-Reply-To: References: Message-Id: Date: Sun, 04 Jul 2021 13:53:54 +0200 MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Spam-Score: 2.9 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Changes since v1: * Add ‘--path’ command line option for importing the package from the local filesystem. * Add ‘git-repository?’ and ‘hg-repository?’ procedures for correctly setting the #:select? keyword (‘git-predicate’ or ‘hg-predicate’) for ‘local-file’. Other VCS don’t have a â [...] Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] -0.0 SPF_PASS SPF: sender matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps X-Debbugs-Envelope-To: 48999 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , zimoun 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: 1.9 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Changes since v1: * Add ‘--path’ command line option for importing the package from the local filesystem. * Add ‘git-repository?’ and ‘hg-repository?’ procedures for correctly setting the #:select? keyword (‘git-predicate’ or ‘hg-predicate’) for ‘local-file’. Other VCS don’t have a â [...] Content analysis details: (1.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] -0.0 SPF_PASS SPF: sender matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Changes since v1: * Add =E2=80=98--path=E2=80=99 command line option for importing the packag= e from the local filesystem. * Add =E2=80=98git-repository?=E2=80=99 and =E2=80=98hg-repository?=E2=80= =99 procedures for correctly setting the #:select? keyword (=E2=80=98git-predicate=E2=80=99 or =E2=80= =98hg-predicate=E2=80=99) for =E2=80=98local-file=E2=80=99. Other VCS don=E2=80=99t have a =E2=80=98-p= redicate=E2=80=99 procedure, so I didn=E2=80=99t bother adding those. Patch [1/3] hasn=E2=80=99t changed since v1. Xinglu Chen (3): import: hackage: Accept local source for package. import: utils: Add predicates for checking VCS repositories. scripts: import: hackage: Add option to import package from local filesystem. guix/import/hackage.scm | 43 +++++++++++++++++++++------------ guix/import/utils.scm | 15 ++++++++++++ guix/scripts/import/hackage.scm | 43 +++++++++++++++++++++++++++------ tests/hackage.scm | 28 +++++++++++++++++++-- 4 files changed, 103 insertions(+), 26 deletions(-) base-commit: b65af6ed9120234cf655e8e76317558cfbd02477 =2D-=20 2.32.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmDhoVIVHHB1YmxpY0B5 b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5KgkQALA5ub5ARbFCFAuH6UTSRzI4ar+c t+v1H2OtFLh+O4JzpnPjHvJ9wXh2Kus88IBmfQ0O4kHibVW3IDleQXnXoXBlm2tK UoZEEZlfx2c+0vRzF+7YAYPZslOhwRoAIZJhDsL9P9kkYx6YsXJVNypUqK3ALo5S LAIKLAvWGRjbQKRaGg96auQp6q9awDfDCBRYgGY1MPuHi00mygpo8LgBJDH+xyQA 7J5FRcHPhoA1LbDtod5WEoqixkhbL1Wp9upkeQHVdFPiMH5g45a3PSYTepKP6ELc foA3Bo6ipuL6tFUYN+ITaBj0deV5aNY5KcnvCqj//0bcle2+1qBQwhb9nC2gvNdL BIM3EHJEDJRnSTeA5S+hMTb1MfjoZVXH+ej0US1rSRh4KcInpZkeg3vH3cRMkeyw 8ZP8FEr5PMX4puEUJ5nmyXqbqxLjvMlZcmIFQFPNCHtH6KfUK4HurY+AHi6BKWI5 PqR2ef6lsxRaKBZFWHipS/vg3CDWRHq99sBaQIeVztKudVvReSBrWlfypCtmVLqU aOZ2+KqlusThNE4yuXaT18RSUN1kFYyZzb9NTrsOsbRgKzJbr+nA+KePb/H1gpbc rtswGH3EcDMbxaty2c/fMI89Ei8ChrXCy+MWN9ok15KOE/QQFF3MiJKmmapyv31V EMGFdDfjufIkYzeY =m9X+ -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 04 07:54:11 2021 Received: (at 48999) by debbugs.gnu.org; 4 Jul 2021 11:54:11 +0000 Received: from localhost ([127.0.0.1]:40455 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m00hO-0000aU-J6 for submit@debbugs.gnu.org; Sun, 04 Jul 2021 07:54:10 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:45466 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m00hM-0000a2-PM for 48999@debbugs.gnu.org; Sun, 04 Jul 2021 07:54:09 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1625399643; bh=cmcvjkAs5+0r+k46+djafKT2CgLBJybMyMNJOZ1jCV8=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=UYG1fCzle7GH1q6wfwov5YHNoEx83V7GHAxrn5rPMRzgwrPH0da205KAgYgEj7Jan 9Fj11expo71nl2MWCslgXDBXE3hg3zMNqS9KXyEpJBW3oYAJ0qDQY4T1EzvwhweI4h 0D0/sEGsdwzn/pCeBVZUPKyxmG49nq15+YugvCf8= To: 48999@debbugs.gnu.org Subject: [PATCH v2 1/3] import: hackage: Accept local source for package. In-Reply-To: References: Message-Id: Date: Sun, 04 Jul 2021 13:54:02 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 2.9 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When developing a Haskell package it is often useful to have a Guix package definition for that package, previously one would have to write that package definition by hand, and if the .cabal file chan [...] Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] -0.0 SPF_PASS SPF: sender matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps 0.0 T_FILL_THIS_FORM_SHORT Fill in a short form with personal information X-Debbugs-Envelope-To: 48999 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , zimoun 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: 1.9 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When developing a Haskell package it is often useful to have a Guix package definition for that package, previously one would have to write that package definition by hand, and if the .cabal file chan [...] Content analysis details: (1.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] -0.0 SPF_PASS SPF: sender matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps When developing a Haskell package it is often useful to have a Guix package definition for that package, previously one would have to write that package definition by hand, and if the .cabal file changed one would manually update the Guix package definition. This commit allows one to specify a custom source for their package, meaning that one could programatically generate a Guix package definition for their local Haskell package. If the .cabal file changes, the generated package definition will also change accordingly. One could for instance write the following in a guix.scm file: (define-values (ghc-haskeme deps) (call-with-input-file "haskeme.cabal" (lambda (port) (hackage->guix-package "haskeme" #:port port #:source (local-file "." "haskeme-checkout" #:recursive? #t #:select? hg-predicate))))) ghc-haskeme Invoking =E2=80=98guix build -f guix.scm=E2=80=99 would then always build a= n up-to-date version of the package. * guix/import/hackage.scm (hackage-module->sexp): Add optional keyword argument =E2=80=98source=E2=80=99 (hackage->guix-package): Likewise. * tests/hackage.scm (eval-test-with-cabal): Likewise. ("hackage->guix-package local source"): New test. --- guix/import/hackage.scm | 43 ++++++++++++++++++++++++++--------------- tests/hackage.scm | 28 +++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm index f94a1e7087..326ab92365 100644 --- a/guix/import/hackage.scm +++ b/guix/import/hackage.scm @@ -227,10 +227,13 @@ package being processed and is used to filter referen= ces to itself." dependencies)) =20 (define* (hackage-module->sexp cabal cabal-hash - #:key (include-test-dependencies? #t)) + #:key + (include-test-dependencies? #t) + (source #f)) "Return the `package' S-expression for a Cabal package. CABAL is the -representation of a Cabal file as produced by 'read-cabal'. CABAL-HASH is -the hash of the Cabal file." +representation of a Cabal file as produced by 'read-cabal'. CABAL-HASH is= the +hash of the Cabal file. If SOURCE is specified, it will be used as the so= urce +for the package." =20 (define name (cabal-package-name cabal)) @@ -294,20 +297,24 @@ the hash of the Cabal file." (() '()) (args `((arguments (,'quasiquote ,args)))))) =20 - (let ((tarball (with-store store - (download-to-store store source-url)))) + (let ((tarball (if source + #f + (with-store store + (download-to-store store source-url))))) (values `(package (name ,(hackage-name->package-name name)) (version ,version) - (source (origin - (method url-fetch) - (uri (string-append ,@(factorize-uri source-url version)= )) - (sha256 - (base32 - ,(if tarball - (bytevector->nix-base32-string (file-sha256 tarba= ll)) - "failed to download tar archive"))))) + (source ,(if source + source + `(origin + (method url-fetch) + (uri (string-append ,@(factorize-uri source-url ve= rsion))) + (sha256 + (base32 + ,(if tarball + (bytevector->nix-base32-string (file-sha256= tarball)) + "failed to download tar archive")))))) (build-system haskell-build-system) ,@(maybe-inputs 'inputs dependencies) ,@(maybe-inputs 'native-inputs native-dependencies) @@ -321,10 +328,12 @@ the hash of the Cabal file." (define* (hackage->guix-package package-name #:key (include-test-dependencies? #t) (port #f) + (source #f) (cabal-environment '())) "Fetch the Cabal file for PACKAGE-NAME from hackage.haskell.org, or, if = the -called with keyword parameter PORT, from PORT. Return the `package' -S-expression corresponding to that package, or #f on failure. +called with keyword parameter PORT, from PORT. If SOURCE is specified, us= e it +as the source for the package instead of trying to fetch a tarball. Return +the `package' S-expression corresponding to that package, or #f on failure. CABAL-ENVIRONMENT is an alist defining the environment in which the Cabal conditionals are evaluated. The accepted keys are: \"os\", \"arch\", \"im= pl\" and the name of a flag. The value associated with a flag has to be either= the @@ -338,7 +347,9 @@ respectively." (hackage-fetch-and-hash package-name)))) (and=3D> cabal-meta (compose (cut hackage-module->sexp <> cabal-hash #:include-test-dependencies? - include-test-dependencies?) + include-test-dependencies? + #:source + source) (cut eval-cabal <> cabal-environment))))) =20 (define hackage->guix-package/m ;memoized variant diff --git a/tests/hackage.scm b/tests/hackage.scm index 53972fc643..3083a5d4df 100644 --- a/tests/hackage.scm +++ b/tests/hackage.scm @@ -22,6 +22,7 @@ #:use-module (guix import cabal) #:use-module (guix import hackage) #:use-module (guix tests) + #:use-module (guix gexp) #:use-module (srfi srfi-64) #:use-module (ice-9 match)) =20 @@ -186,9 +187,28 @@ library ('description (? string?)) ('license 'license:bsd-3))) =20 -(define* (eval-test-with-cabal test-cabal matcher #:key (cabal-environment= '())) +(define-package-matcher match-ghc-foo-local-source + ('package + ('name "ghc-foo") + ('version "1.0.0") + ('source + (? file-like?)) + ('build-system 'haskell-build-system) + ('inputs + ('quasiquote + (("ghc-http" ('unquote 'ghc-http))))) + ('home-page "http://test.org") + ('synopsis (? string?)) + ('description (? string?)) + ('license 'license:bsd-3))) + +(define* (eval-test-with-cabal test-cabal matcher + #:key (cabal-environment '()) (source #f)) (define port (open-input-string test-cabal)) - (matcher (hackage->guix-package "foo" #:port port #:cabal-environment ca= bal-environment))) + (matcher (hackage->guix-package "foo" + #:port port + #:cabal-environment cabal-environment + #:source source))) =20 (test-assert "hackage->guix-package test 1" (eval-test-with-cabal test-cabal-1 match-ghc-foo)) @@ -208,6 +228,10 @@ library (eval-test-with-cabal test-cabal-5 match-ghc-foo #:cabal-environment '(("impl" . "ghc-7.8")))) =20 +(test-assert "hackage->guix-package local source" + (eval-test-with-cabal test-cabal-1 match-ghc-foo-local-source + #:source (plain-file "dummy source" "source"))) + (define-package-matcher match-ghc-foo-6 ('package ('name "ghc-foo") --=20 2.32.0 From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 04 07:54:26 2021 Received: (at 48999) by debbugs.gnu.org; 4 Jul 2021 11:54:26 +0000 Received: from localhost ([127.0.0.1]:40458 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m00he-0000b3-1x for submit@debbugs.gnu.org; Sun, 04 Jul 2021 07:54:26 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:45484 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m00hc-0000an-93 for 48999@debbugs.gnu.org; Sun, 04 Jul 2021 07:54:24 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1625399658; bh=SUKiCktpIliPTlYO8GWL93wkIVLqZ5R0FlszaIM3rEs=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=Rb0aWdAPebKvEL/t+UpT2eCtw55cQXVCTxB+QEGz5Nr13MamNNHIV56uQwfoenaeD qAyU5fjH+bjQrz3OboC489mj93AEr8RbtP1Eqn0qb/TKGq/aZZiKxYb3YMpzTGC8N3 M8ExhT6vBPOcnpIyCzmrrzi/+JcUeUKutJCvTWSc= To: 48999@debbugs.gnu.org Subject: [PATCH v2 2/3] import: utils: Add predicates for checking VCS repositories. In-Reply-To: References: Message-Id: <6f3fa1769c57d6c81765939a40b1c505d0cefb66.1625399149.git.public@yoctocell.xyz> Date: Sun, 04 Jul 2021 13:54:18 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 2.9 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * guix/import/utils.scm (git-repository?, hg-repository?): New procedures. --- guix/import/utils.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/guix/import/utils.scm b/guix/import/utils.scm index d817318a91..bcf26ae363 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -8,6 +8,7 @@ ;;; Copyright © 2020 Helio Macha [...] Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] -0.0 SPF_PASS SPF: sender matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps X-Debbugs-Envelope-To: 48999 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , zimoun 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: 1.9 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * guix/import/utils.scm (git-repository?, hg-repository?): New procedures. --- guix/import/utils.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/guix/import/utils.scm b/guix/import/utils.scm index d817318a91..bcf26ae363 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -8,6 +8,7 @@ ;;; Copyright © 2020 Helio Macha [...] Content analysis details: (1.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] -0.0 SPF_PASS SPF: sender matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps * guix/import/utils.scm (git-repository?, hg-repository?): New procedures. --- guix/import/utils.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/guix/import/utils.scm b/guix/import/utils.scm index d817318a91..bcf26ae363 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -8,6 +8,7 @@ ;;; Copyright =C2=A9 2020 Helio Machado <0x2b3bfa0+guix@googlemail.com> ;;; Copyright =C2=A9 2020 Martin Becze ;;; Copyright =C2=A9 2021 Maxim Cournoyer +;;; Copyright =C2=A9 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -43,6 +44,7 @@ #:use-module (ice-9 rdelim) #:use-module (ice-9 receive) #:use-module (ice-9 regex) + #:use-module (ice-9 ftw) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-11) @@ -74,6 +76,9 @@ =20 guix-name =20 + git-repository? + hg-repository? +=20=20=20=20=20=20=20=20=20=20=20=20 recursive-import)) =20 (define (factorize-uri uri version) @@ -422,6 +427,16 @@ separated by PRED." (chr (char-downcase chr))) name))) =20 +(define (git-repository? directory) + "Check whether DIRECTORY is a Git repository." + (let ((contents (scandir directory))) + (if (member ".git" contents) #t #f))) + +(define (hg-repository? directory) + "Check whether DIRECTORY is a Hg repository." + (let ((contents (scandir directory))) + (if (member ".hg" contents) #t #f))) + (define (topological-sort nodes node-dependencies node-name) --=20 2.32.0 From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 04 07:54:30 2021 Received: (at 48999) by debbugs.gnu.org; 4 Jul 2021 11:54:30 +0000 Received: from localhost ([127.0.0.1]:40461 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m00hi-0000bM-AD for submit@debbugs.gnu.org; Sun, 04 Jul 2021 07:54:30 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:45494 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m00hf-0000as-3V for 48999@debbugs.gnu.org; Sun, 04 Jul 2021 07:54:28 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1625399661; bh=7C7QEzkflnhQc5ic1PfcaX7wJVpYn+YK5wpeZn2hic0=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=J7Q1N3UtN9As2vzxOiPsKCw0BNCLps8E1HumPc9IxX75lYEDBQbj6a6aKcrI3Fyzk ln5mGFVZM2osS1Xmp3YeTa7qnjQUkw9L4teup9sGOvfk+IN4flTbx1/AZiVH1P5pNf z3T8MHciLj4P7t9Pw54RKdd6mpowFLqw5xWYDygM= To: 48999@debbugs.gnu.org Subject: [PATCH v2 3/3] scripts: import: hackage: Add option to import package from local filesystem. In-Reply-To: References: Message-Id: <52f526989b25468210fa05e62580589f2c1cc4ea.1625399149.git.public@yoctocell.xyz> Date: Sun, 04 Jul 2021 13:54:20 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 2.9 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This adds a ‘--path’ option for importing a Haskell package from the local filesystem * guix/scripts/import/hackage.scm (show-help, %options): Add ‘-p’ and ‘--path’ options. (guix-import-hackage): Set the #:port and #:source keywords when the ‘--path’ option is used. --- gu [...] Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] -0.0 SPF_PASS SPF: sender matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps X-Debbugs-Envelope-To: 48999 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , zimoun 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: 1.9 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This adds a ‘--path’ option for importing a Haskell package from the local filesystem * guix/scripts/import/hackage.scm (show-help, %options): Add ‘-p’ and ‘--path’ options. (guix-import-hackage): Set the #:port and #:source keywords when the ‘--path’ option is used. --- gu [...] Content analysis details: (1.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] -0.0 SPF_PASS SPF: sender matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps This adds a =E2=80=98--path=E2=80=99 option for importing a Haskell package= from the local filesystem * guix/scripts/import/hackage.scm (show-help, %options): Add =E2=80=98-p=E2= =80=99 and =E2=80=98--path=E2=80=99 options. (guix-import-hackage): Set the #:port and #:source keywords when the =E2=80= =98--path=E2=80=99 option is used. --- guix/scripts/import/hackage.scm | 43 +++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/guix/scripts/import/hackage.scm b/guix/scripts/import/hackage.= scm index 906dca24b1..8728791b52 100644 --- a/guix/scripts/import/hackage.scm +++ b/guix/scripts/import/hackage.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2015 Federico Beffa ;;; Copyright =C2=A9 2018 Ricardo Wurmus +;;; Copyright =C2=A9 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -22,6 +23,7 @@ #:use-module (guix utils) #:use-module (guix packages) #:use-module (guix scripts) + #:use-module (guix import utils) #:use-module (guix import hackage) #:use-module (guix scripts import) #:use-module (srfi srfi-1) @@ -29,6 +31,7 @@ #:use-module (srfi srfi-37) #:use-module (ice-9 match) #:use-module (ice-9 format) + #:use-module (rnrs io ports) #:export (guix-import-hackage)) =20 @@ -62,6 +65,8 @@ version.\n")) (display (G_ " -s, --stdin read from standard input")) (display (G_ " + -p, --path=3DDIR use local directory as source")) + (display (G_ " -t, --no-test-dependencies don't include test-only dependencies")) (display (G_ " -V, --version display version information and exit")) @@ -87,6 +92,11 @@ version.\n")) (alist-cons 'read-from-stdin? #t (alist-delete 'read-from-stdin? result)))) + (option '(#\p "path") #t #f + (lambda (opt name arg result) + (alist-cons 'read-path arg + (alist-delete 'read-path + result)))) (option '(#\e "cabal-environment") #t #f (lambda (opt name arg result) (alist-cons 'cabal-environment (read/eval arg) @@ -113,22 +123,39 @@ version.\n")) %default-options)) =20 (define (run-importer package-name opts error-fn) - (let* ((arguments (list + (let* ((local-directory (assoc-ref opts 'read-path)) + (arguments (list package-name #:include-test-dependencies? (assoc-ref opts 'include-test-dependencies?) - #:port (if (assoc-ref opts 'read-from-stdin?) - (current-input-port) - #f) + #:port + (cond + ((assoc-ref opts 'read-from-stdin?) + (current-input-port)) + (local-directory + (open-file-input-port + (string-append local-directory + "/" package-name ".cabal"))) + (else #f)) + #:source + `(local-file ,local-directory + ,package-name + #:recursive? #t + #:select? ,(cond + ((git-repository? local-di= rectory) + 'git-predicate) + ((hg-repository? local-dir= ectory) + 'hg-predicate) + (else '(const #t)))) #:cabal-environment (assoc-ref opts 'cabal-environment))) (sexp (if (assoc-ref opts 'recursive) ;; Recursive import (map (match-lambda - ((and ('package ('name name) . rest) pkg) - `(define-public ,(string->symbol name) - ,pkg)) - (_ #f)) + ((and ('package ('name name) . rest) pkg) + `(define-public ,(string->symbol name) + ,pkg)) + (_ #f)) (apply hackage-recursive-import arguments)) ;; Single import (apply hackage->guix-package arguments)))) --=20 2.32.0