From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id oDk0C+u4OGNiMgEAbAwnHQ (envelope-from ) for ; Sun, 02 Oct 2022 00:02:19 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id oN9ICuu4OGNsegAAG6o9tA (envelope-from ) for ; Sun, 02 Oct 2022 00:02:19 +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 8D33C2815F for ; Sun, 2 Oct 2022 00:02:18 +0200 (CEST) Received: from localhost ([::1]:48020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oekYr-0002pv-PB for larch@yhetil.org; Sat, 01 Oct 2022 18:02:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oekYc-0002pm-RN for guix-patches@gnu.org; Sat, 01 Oct 2022 18:02:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oekYc-0000at-Hj for guix-patches@gnu.org; Sat, 01 Oct 2022 18:02:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oekYc-0003ct-B2 for guix-patches@gnu.org; Sat, 01 Oct 2022 18:02:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58235] [PATCH] rakdo-build-system Resent-From: "Daniel Sockwell" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 01 Oct 2022 22:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58235 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58235@debbugs.gnu.org Cc: brown121407@posteo.ro, Maxime Devos , paul@apatience.com X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.166466169313900 (code B ref -1); Sat, 01 Oct 2022 22:02:02 +0000 Received: (at submit) by debbugs.gnu.org; 1 Oct 2022 22:01:33 +0000 Received: from localhost ([127.0.0.1]:45800 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oekY7-0003c7-Qh for submit@debbugs.gnu.org; Sat, 01 Oct 2022 18:01:33 -0400 Received: from lists.gnu.org ([209.51.188.17]:43874) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oekY5-0003bx-An for submit@debbugs.gnu.org; Sat, 01 Oct 2022 18:01:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oekY4-0002nh-U9 for guix-patches@gnu.org; Sat, 01 Oct 2022 18:01:28 -0400 Received: from out0.migadu.com ([94.23.1.103]:48946) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oekY0-0000ZA-JZ for guix-patches@gnu.org; Sat, 01 Oct 2022 18:01:28 -0400 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codesections.com; s=key1; t=1664661681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ySt7yoFDTiuvK20i6ADWnEu0qm68BOpWySC7MZkYgzo=; b=nsk2zjFjbPZkD6TsD5jeNbcMcCsPRxemVNmqM9jMEhB+JCpO+WVEYlg7TkYiTIqYZN5JjL 7AI9bE0cBiyg0Id7ziPl7NIv+gmj5RzHyoUQifEegjK/VIvq268aMiUx3UGXlztIILUDFQ r8S/wYZI+G+un4S8ME6rT5Fa3hJtd6ex6pbf1nX8INkEqmX9rJcIxCSprqSKBYLHaAZqAn 9HWFKoZogpGDvflkZy3zt7NH7KdvHw2dC1Pxhnb+LNAsUSaOyBdr4J3e1xHVobSYFRBdkQ oaKAX7DvXVjfajL7VGpap02qkRUx3MZNeDQqlW5RY5dJdFRXBCt72r/Vl454jw== Date: Sat, 01 Oct 2022 22:01:20 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. Message-ID: <7a3e89c7546867c54d76824ac8f47cb1@codesections.com> Received-SPF: pass client-ip=94.23.1.103; envelope-from=daniel@codesections.com; helo=out0.migadu.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 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-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" Reply-to: Daniel Sockwell X-ACL-Warn: , Daniel Sockwell via Guix-patches From: Daniel Sockwell via Guix-patches via X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664661738; h=from:from:sender:sender:reply-to: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=ySt7yoFDTiuvK20i6ADWnEu0qm68BOpWySC7MZkYgzo=; b=kvG5wtvjwznGjhqXo3fHz0LeP71I+hZIlnEQ/cCpp1dpSGV8PV2EfI9VUNYLANT/7qboZ4 IzvlGGk6Q6Qwkv5wIwUz2PjTH/8A9laNCc9yDBv59CjBaL9UcJKS2eJflN9zabN/B6+FP1 qLCbfuQjP5SOfAyplqxLN7rHoIb2rBnXvtr8z599vKgUxg9WPU/NZnOH18BL445SHWXnBz P8iUQR7+rtFRSOeqYnOmU04J8kNhG5gobQU72hNwpZJ5EcgcwsYEcB5ftGsBmIRQt4J/9M cfLsSX8Isqxxbf3KkUCuvtUf2ZedvtsiAyHmwWQuhPz0rFVGZAj2HuUbxQ5G6w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664661738; a=rsa-sha256; cv=none; b=b3YOzj9Cz+zze1vKlON2FQaTK8IDLctR5uDckUsqrX7M1V1DFgMTRdmjlX0FsXhLvP3Uh5 CcV2r+qf5JDQwng+LY71nr7vMUQajU2BavNgPxwITbzVyc0b2aq6W/PpianMD92cjT0l90 s1MyyjwOJqEEdryvdZQ4Vl/Dx92A4syZwmlwuBjahZWwScJjth/Itv/l+g3duyf4tPdH8S Be2AWdABIuT73zJdApUdUSr2nlSGM5wjfqGBMjUY5R80c5vOqY9LLGJZqgkhaP5T+bs9aL G4bmDP9okXufgRASY6tRNOYCiawnpu2QKpi4cmu+6Ua402bDlfzzIhGEY6YmSw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=codesections.com header.s=key1 header.b=nsk2zjFj; dmarc=pass (policy=none) header.from=gnu.org; 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: -2.14 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=codesections.com header.s=key1 header.b=nsk2zjFj; dmarc=pass (policy=none) header.from=gnu.org; 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: 8D33C2815F X-Spam-Score: -2.14 X-Migadu-Scanner: scn0.migadu.com X-TUID: BFrzbXuBWEZB I previously submitted patch #46352, which was an attempt to update=0Athe= Raku ecosystem and received very helpful feedback from Maxime=0ADevos. = While revising my patch based on that feedback, I realized=0Athat the iss= ue preventing updates to the Raku ecosystem were larger=0Athan I had real= ized.=0A=0AIn fact, I discovered that I wasn't the first person to try to= solve=0Athem: patch #55179 by Paul A. Patience was another attempt in Ap= ril.=0AAnd Paul _also_ wasn't the first attempt; his patch mentioned that= =0Ahe didn't know about patch #46352 by Alexandru-Sergiu Marton from =0AF= ebruary 2021.=0A=0AGiven that two previous patches had attempted to updat= e the Raku=0Aecosystem without success and that my patch was running into= some=0Aof the same issues that had been a problem for Paul, I decided to= =0Atake a step back and figure out what was posing such a problem.=0A=0AI= realized that the problem was that the rakudo-build-system didn't=0Ahave= a complete solution for handling Raku precompilation. To fix=0Athis, I = ended up rewiting the rakudo-build-system to add that support;=0Adoing so= seems to have resolved the issue.=0A=0AThis patch is part 1 of three, an= d contains only the changes to the=0Abuild system. The second patch will= have the changes to the core Raku=0Apackages that the rest of the ecosys= tem depend on (Rakudo, NQP, Zef,=0Aetc). Finally, the third will adapt t= he remaining ecosystem packages=0Ato the new version of the build system.= =0A=0AI hope that this 4th patch series will result in Guix being able to= =0Apackage an up-to-date version of Rakudo!=0A=0ABest regards,=0ADaniel = =0A=0A=0AFrom f03ba44cdab7c3a200cd8f71624848490fdd1099 Mon Sep 17 00:00:0= 0 2001=0AMessage-Id: =0AFrom: Daniel Sockwell =0ADate: Sat, 1 Oct 2022 17:24:20 -0400=0ASubject: [PATCH] build-sy= stem/rakudo: rewrite to support precomp=0A=0ASignificantly rewrite the Ra= kudo build system to support precompiling=0ARaku programs and to work wit= h modern versions of Rakudo. This has=0Apreviously been a significant bl= ocker to updating Raku programs, see=0A,=0A, and=0A.=0A=0A* guix/build/rakudo-build-system.scm: significant change= s=0A* guix/build-system/rakudo.scm: minor corresponding changes=0A---=0A = guix/build-system/rakudo.scm | 31 +--=0A guix/build/rakudo-build-s= ystem.scm | 392 +++++++++++++++++++++--------=0A 2 files changed, 309 ins= ertions(+), 114 deletions(-)=0A=0Adiff --git a/guix/build-system/rakudo.s= cm b/guix/build-system/rakudo.scm=0Aindex 05a4d9c2ad..b9c9d3c612 100644= =0A--- a/guix/build-system/rakudo.scm=0A+++ b/guix/build-system/rakudo.sc= m=0A@@ -54,7 +54,7 @@ (define (default-rakudo)=0A (define (default-prove6= )=0A "Return the default perl6-tap-harness package for tests."=0A (le= t ((module (resolve-interface '(gnu packages perl6))))=0A- (module-ref= module 'perl6-tap-harness)))=0A+ (module-ref module 'perl6-prove6)))= =0A =0A (define (default-zef)=0A "Return the default perl6-zef package.= "=0A@@ -62,19 +62,20 @@ (define (default-zef)=0A (module-ref module '= perl6-zef)))=0A =0A (define* (lower name=0A- #:key source = inputs native-inputs outputs=0A+ #:key source inputs nativ= e-inputs=0A+ outputs=0A system target=0A = (rakudo (default-rakudo))=0A (prove6 (defa= ult-prove6))=0A (zef (default-zef))=0A- (w= ith-prove6? #t)=0A- (with-zef? #t)=0A+ (tes= ts? #t)=0A+ (test-runner "zef")=0A #:allow= -other-keys=0A #:rest arguments)=0A "Return a bag for N= AME."=0A (define private-keywords=0A '(#:target #:rakudo #:prove6 #= :zef #:inputs #:native-inputs))=0A-=0A+ =0A (and (not target) = ;XXX: no cross-compilation=0A (bag=0A = (name name)=0A@@ -87,12 +88,14 @@ (define private-keywords=0A = ;; Keep the standard inputs of 'gnu-build-system'.=0A = ,@(standard-packages)))=0A (build-inputs `(= ("rakudo" ,rakudo)=0A- ,@(if with-prove6?=0A- = `(("perl6-tap-harness" ,prove6)=0A- = ,@(if with-zef?=0A- = `(("perl6-zef" ,zef))=0A- '(= )))=0A- '())=0A+ ,@= (cond ((not tests?)=0A+ '())=0A+ = ((and tests? (eq? test-runner "zef"))=0A+ = `(("test-runner-zef" ,zef))) =0A+ = ((and tests? (eq? test-runner "prove6"))=0A+ = `(("test-runner-prove6" ,prove6)))=0A+ = (else '()))=0A+ =0A = ,@native-inputs))=0A (outputs outputs)=0A = (build rakudo-build)=0A@@ -104,11 +107,10 @@ (define* (rakudo-build= name inputs=0A (search-paths '())=0A = (tests? #t)=0A (phases '%standard-phase= s)=0A- (outputs '("out"))=0A+ = outputs =0A (system (%current-system))=0A = (guile #f)=0A- (with-zef? #t)=0A- = (with-prove6? #t)=0A+ (test-ru= nner "zef")=0A (imported-modules %rakudo-build-sys= tem-modules)=0A (modules '((guix build rakudo-buil= d-system)=0A (guix build utils))))=0A@@= -125,6 +127,7 @@ (define builder=0A #:phases #$p= hases=0A #:system #$system=0A = #:tests? #$tests?=0A+ #:test-runner #$test-ru= nner=0A #:outputs #$(outputs->gexp outputs)=0A = #:inputs #$(input-tuples->gexp inputs)))))=0A =0Adi= ff --git a/guix/build/rakudo-build-system.scm b/guix/build/rakudo-build-s= ystem.scm=0Aindex 5cf1cc55bc..82f08f56c3 100644=0A--- a/guix/build/rakudo= -build-system.scm=0A+++ b/guix/build/rakudo-build-system.scm=0A@@ -22,132= +22,324 @@ (define-module (guix build rakudo-build-system)=0A #:use-mo= dule (guix build utils)=0A #:use-module (ice-9 ftw)=0A #:use-module (= ice-9 match)=0A+ #:use-module (ice-9 regex)=0A+ #:use-module (ice-9 rde= lim)=0A #:use-module (srfi srfi-1)=0A #:use-module (srfi srfi-26)=0A+= #:use-module (srfi srfi-34)=0A+ #:use-module (srfi srfi-35)=0A #:exp= ort (%standard-phases=0A rakudo-build))=0A =0A ;; Commentary:= =0A ;;=0A-;; Builder-side code of the standard Rakudo package build proce= dure.=0A+;; Builder-side code of the Rakudo build procedure for Raku pack= ages.=0A+;;=0A+;;=0A+;; The rakudo-build-system uses the Rakudo compiler = to compile and install Raku=0A+;; programs, and then uses a Raku test run= ner (e.g., Zef) to test those=0A+;; programs. The Rakudo build system is= an extension of the GNU build system=0A+;; that is customized ways to su= pport Raku packages, especially for=0A+;; precompilation. The Rakudo bui= ld system accepts one non-standard argument:=0A+;;=0A+;; #:test-runner -= The Test Anything Protocol program used to run tests.=0A+;; = (ignored if #:tests? #f)=0A+;; Valid values: "zef" - [default] U= se perl6-zef, which is closest to how =0A+;; te= sts are normally run in the Raku ecosystem.=0A+;; "prove6"= - Use perl6-prove6, a Raku TAP test runner=0A+;; "rakudo"= - Run tests directly via Rakudo (no TAP test runner)=0A+;;=0A+;; This bu= ild system configures Raku programs to write a metadata cache to=0A+;; $X= DG_DATA_HOME/raku/repo=0A+;;=0A+;; The above should be all you need to kn= ow to package Raku programs with the=0A+;; Rakudo build system; the rest = of this commentary provides background on the=0A+;; build system and Raku= precompilation generally.=0A+;;=0A+;; Raku's strategy for dependency man= agement is remarkably similar to Guix's:=0A+;; Raku compiles each program= into an immutable output; then, whenever that=0A+;; program's (recursive= ) inputs change, Raku generates a new output and=0A+;; redirects the rele= vant references to that new output. This gives Raku many=0A+;; of the sa= me advantages that Guix enjoys, including allowing simultaneous=0A+;; ins= tallation of multiple package versions.=0A+;;=0A+;; But the similarity be= tween Guix and Raku creates an issue for packaging Raku=0A+;; programs: R= aku expects to be able to manage its equivalent to /gnu/store/ by=0A+;; r= ecompiling Raku programs in their install location. This doesn't work wh= en=0A+;; those programs are installed in Guix's actual, read-only /gnu/st= ore/. Thus,=0A+;; integrating Raku and Guix requires some care.=0A+;;=0A= +;; Specifically, because Raku can't update precomp files in /gnu/store/,= Guix=0A+;; needs replace Raku as the director of Raku's precomp process,= including by=0A+;; guaranteeing that every Raku package is fully precomp= iled at install time.=0A+;; This is different from how Raku normally hand= les precomp (partly lazily, with=0A+;; some precomp delayed until a modul= e is first loaded).=0A+;;=0A+;; Accordingly, the Rakudo build system inst= alls all precomp files to the store.=0A+;; The only non-store data a Raku= package should generate is a metadata index=0A+;; consisting of *.repo-i= d files and *.lock files that gets written to=0A+;; $XDG_DATA_HOME/raku/r= epo. Raku reads this index to avoid the need to check=0A+;; input integr= ity, which is purely a performance optimization =E2=80=93 Raku=0A+;; auto= matically rebuilds the index if it's missing.=0A+;;=0A+;; The Rakudo buil= d system supports using Guix-installed packages in combination=0A+;; with= Zef-installed ones. (Zef is the LPM (language package manager) that=0A+= ;; Raku developers use, i.e., Raku's equivalent to Rust's Cargo or JavaSc= ript's=0A+;; NPM/Yarn/PNPM.) Programs installed via Zef have all their d= ata installed to=0A+;; the same ./raku/repo directory used for Guix-insta= lled packages' metadata.=0A+;; After installation, Zef-installed packages= be used interchangeably with Raku=0A+;; packages installed via Guix =E2= =80=93 though, of course, they lack access to=0A+;; rollbacks, build tran= sformations, and the rest of Guix's superpowers.=0A+;;=0A+;; Including Ra= ku precomp files in the Guix store creates one minor issue: it=0A+;; decr= eases the number of Raku packages that pass "guix build --check". This= =0A+;; shouldn't be the case: In theory, Raku precomp files are bit-for-b= it=0A+;; reproducible but, in practice, a few precomp files show (extreme= ly minor)=0A+;; differences. Until that's fixed, excluding precomp files= from Guix's store=0A+;; would let some Raku packages appear to be fully = reproducible. But doing that=0A+;; wouldn't *actually* help reproducibli= ty: those slightly non-reproducible=0A+;; precomp files would still be ge= nerated and executed outside the store.=0A+;;=0A+;; The Rakudo build syst= em does not yet have an importer, but creating one is=0A+;; conceptually = simple and is planned.=0A+;;=0A ;;=0A ;; Code:=0A =0A-(define* (check #:k= ey tests? inputs with-prove6? #:allow-other-keys)=0A- (if (and tests? (a= ssoc-ref inputs "perl6-tap-harness"))=0A- ;(if (and tests? with-prove6?)= =0A- (invoke "prove6" "-I=3Dlib" "t/")=0A- (format #t "test sui= te not run~%"))=0A- #t)=0A-=0A-(define* (install #:key inputs outputs wi= th-zef? #:allow-other-keys)=0A- "Install a given Perl6 package."=0A- (l= et* ((out (assoc-ref outputs "out"))=0A- (perl6 (string-append = out "/share/perl6")))=0A- (if (assoc-ref inputs "perl6-zef")=0A- ;(= if with-zef?=0A- (begin=0A- (let ((zef (string-append (as= soc-ref inputs "perl6-zef")=0A- "/bin/= zef")))=0A- (setenv "HOME" (getcwd))=0A- (mkdir-p p= erl6)=0A- (invoke zef "install" "--verbose" "."=0A- = ;; Don't install any of the following:=0A- "-= -/depends" "--/build-depends" "--/test-depends"=0A- (s= tring-append "--install-to=3D" perl6))=0A- (delete-file (strin= g-append perl6 "/repo.lock")))=0A- #t)=0A- (begin=0A- = (let ((inst (string-append (assoc-ref inputs "rakudo")=0A- = "/share/perl6/tools/install-dist.p6")))=0A- = (setenv "RAKUDO_RERESOLVE_DEPENDENCIES" "0")=0A- (se= tenv "RAKUDO_MODULE_DEBUG" "1") ; be verbose while building=0A- = (invoke inst (string-append "--to=3D" perl6) "--for=3Dsite"))))))=0A-= =0A-(define* (install-libs #:key outputs #:allow-other-keys)=0A- (let ((= out (assoc-ref outputs "out"))=0A- (lock "lib/.precomp/.lock"))= =0A- (when (file-exists? lock)=0A- (delete-file "lib/.precomp/.lo= ck"))=0A- (copy-recursively "lib" (string-append out "/share/perl6/lib= "))=0A- #t))=0A =0A-(define* (install-bins #:key outputs #:allow-other= -keys)=0A- (let ((out (assoc-ref outputs "out")))=0A- (when (file-ex= ists? "bin")=0A- (for-each (lambda (file)=0A- (inst= all-file file (string-append out "/bin"))=0A- (chmod (st= ring-append out "/" file) #o555))=0A- (find-files "bin" ".= *")))=0A- (when (file-exists? "sbin")=0A- (for-each (lambda (file= )=0A- (install-file file (string-append out "/sbin"))=0A= - (chmod (string-append out "/" file) #o555))=0A- = (find-files "sbin" ".*")))=0A- #t))=0A+(define (raku-input? i= nput)=0A+ "Test if an input appears to be a Rakudo program based on its = name."=0A+ (or (string-prefix? "raku-" (car input))=0A+ (string-pr= efix? "perl6-" (car input))))=0A+=0A+(define (with-vendor-path dir)=0A+ = "Append the /share/perl6/vendor path to a directory path"=0A+ (string-ap= pend dir "/share/perl6/vendor"))=0A+=0A+(define (inputs->raku-vendor-path= s inputs)=0A+ "Map a list of Guix inputs into a list of Raku vendor path= s."=0A+ (let* ((raku-inputs (filter raku-input? inputs))=0A+ (ra= ku-input-paths (map cdr raku-inputs)))=0A+ (map with-vendor-path raku-= input-paths)))=0A+=0A+(define (dir->inst dir-path)=0A+ "Produce a CompUn= it::Repository::Installation path from a directory path.=0A+Raku provides= several types of Repositories, most relevantly 'FileSystem' repos=0A+and= 'Installation' repos. Guix should use Installation repos, which support= =0A+installation of multiple versions. To specify an Installation repo, = the path=0A+should be prefixed with 'inst#'"=0A+ (string-append "inst#" = dir-path))=0A+=0A+(define (copy-raku-dependencies inputs out-dir)=0A+ "R= ecursively copy files from each Raku dependency to the out directory. Thi= s=0A+lets Rakudo find the precomp files without recursively checking the = integrity of=0A+each one (which is prohibitively slow). Copying the file= s doesn't increase disk=0A+usage thanks to Guix's deduplication via hard = links."=0A+ (let* ((raku-inputs (filter raku-input? inputs))=0A+ = (raku-input-paths (map (lambda (input)=0A+ = (with-vendor-path (cdr input)))=0A+ = raku-inputs)))=0A+ (mkdir-p out-dir)=0A+ (f= or-each=0A+ (lambda (source-dir)=0A+ (for-each make-fil= e-writable (find-files out-dir))=0A+ (copy-recursively source-d= ir out-dir))=0A+ raku-input-paths)))=0A+=0A+(define (set-reposito= ry-version repository-dir version)=0A+ "Set the repository format versio= n for a Raku repository. Raku repositories=0A+have used incompatible for= mats and an unspecified version defaults to v1; thus,=0A+Raku packages mu= st set the repo version. NOTE: the 'install-dist.raku' script=0A+cleans = up the version marker, so you may need to set the version again.=0A+Forge= tting to set the version currently triggers a cryptic error that includes= =0A+the text `cannot do '.open' on a directory'."=0A+ ;; see https://git= hub.com/Raku/old-issue-tracker/issues/6422=0A+ ;; TODO: Consider upstrea= ming a patch to provide a less cryptic error msg.=0A+ (let ((version-fil= e (open-output-file "version")))=0A+ (format version-file "~a\n" versi= on)=0A+ (close-port version-file)=0A+ (install-file "version" repos= itory-dir)))=0A+=0A+(define* (validate-keyword-arg keyword allowed-values= =0A+ #:key (keyword-name "a keyword argumen= t"))=0A+ "Check that the keyword argument has one of the allowed values.= "=0A+ (unless (member keyword allowed-values)=0A+ (let ((allowed-stri= ngs (map (cut format #f "~s" <>) allowed-values)))=0A+ (raise=0A+ = (condition=0A+ (&message (message=0A+ (format #f "In= valid value for ~a: '~s'"=0A+ keyword-name keywor= d)))=0A+ (&message (message=0A+ (format #f "Valid va= lues: '~a'."=0A+=20=20=20=20=20=20=20=20=20 (string-join a= llowed-strings "', '")))))))))=0A+=0A+(define (extract-provided-modules m= eta6)=0A+ "Extract the list of provided modules from a packages META6.js= on file."=0A+ ;; Could alternatively use (json->scm), at the cost of a b= uild dependency=0A+ (let* ((q-mark "\"")=0A+ (non-quote "[^\"]+"= )=0A+ (json-key (string-append q-mark "(" non-quote ")" q-mark ))= =0A+ (json-value (string-append q-mark non-quote q-mark))=0A+ = (json-key-value (make-regexp (string-append non-quote json-key=0A+ = non-quote json-value))= )=0A+ (json-provides-field "[,{]\\s*\"provides\"")=0A+ (p= rovides-value-regexp=0A+ (make-regexp=0A+ (string-appe= nd json-provides-field=0A+ "\\s*:\\s*"=0A+ = "\\{([^}]+)\\}")))=0A+ (provides-value (regex= p-exec provides-value-regexp meta6)))=0A+ (map (cut match:substring <>= 1)=0A+ (list-matches json-key-value=0A+ (m= atch:substring provides-value 1)))))=0A+=0A+;;; Phases=0A+=0A+(define* (s= etup-rakudo-env #:key inputs outputs #:allow-other-keys)=0A+ "Set variou= s RAKUDO* environment variables."=0A+ (let* ((out (assoc-ref outputs "ou= t"))=0A+ (dest (with-vendor-path out))=0A+ (rakudo-dir (a= ssoc-ref inputs "rakudo"))=0A+ (rakudo-home (string-append rakudo= -dir "/share/perl6"))=0A+ (raku-vendor-paths (inputs->raku-vendor= -paths inputs))=0A+ (raku-installations (map dir->inst raku-vendo= r-paths)))=0A+ =0A+ (setenv "HOME" (getcwd))=0A+ (setenv "RAKUDO= _HOME" rakudo-home)=0A+ (setenv "RAKUDO_RESOLVE_DEPENDENCIES" "0")=0A+= (setenv "RAKUDO_LOG_PRECOMP" "1")=0A+ (setenv "RAKUDO_MODULE_DEBU= G" "1")=0A+ (setenv "RAKULIB"=0A+ (string-append (dir->inst= dest) "," "home,"=0A+ (string-join raku-instal= lations ",")))))=0A+=0A+=0A+(define* (check #:key tests? test-runner inpu= ts #:allow-other-keys)=0A+ "Run the tests in ./t with the supplied #:tes= t-runner (default: zef) unless=0A+#:tests? is #f."=0A+ (validate-keyword= -arg test-runner '("zef" "prove6" "rakudo")=0A+ #:= keyword-name "test-runner")=0A+ (when tests?=0A+ (cond=0A+ ((eq? = test-runner "zef")=0A+ (let* ((zef-dir (assoc-ref inputs "test-runne= r-zef"))=0A+ (zef (string-append zef-dir "/bin/zef")))=0A+ = (invoke zef "test" ".")))=0A+ ((eq? test-runner "prove6")=0A+ = (let* ((prove6-dir (assoc-ref inputs "test-runner-prove6"))=0A+ = (prove6 (string-append prove6-dir "/bin/prove6")))=0A+ (invo= ke prove6 "-Ilib" "t/")))=0A+ ((eq? test-runner "rakudo")=0A+ (l= et* ((rakudo-dir (assoc-ref inputs "rakudo"))=0A+ (rakudo (st= ring-append rakudo-dir "/bin/rakudo")))=0A+ (for-each (cut invoke = rakudo "-Ilib" <>)=0A+ (find-files "t/")))))))=0A+=0A+(d= efine* (install #:key inputs outputs #:allow-other-keys)=0A+ "Install th= e code of a given Raku package."=0A+ (let* ((out (assoc-ref outputs "out= "))=0A+ (vendor-dir (with-vendor-path out))=0A+ (rakudo-d= ir (assoc-ref inputs "rakudo"))=0A+ (install-dist-script (string-= append rakudo-dir=0A+ "/share/perl6/tools/i= nstall-dist.raku")))=0A+=0A+ (copy-raku-dependencies inputs vendor-dir= )=0A+ (set-repository-version vendor-dir 2)=0A+=0A+ (invoke install= -dist-script=0A+ "--from=3D."=0A+ (string-append "-= -to=3D" vendor-dir)=0A+ "--for=3Dvendor"=0A+ "--bui= ld"=0A+ "--precompile")))=0A =0A (define* (install-resources #= :key outputs #:allow-other-keys)=0A- (let ((out (assoc-ref outputs "out= ")))=0A- (when (file-exists? "resources")=0A- (copy-recursively "= resources"=0A- (string-append out "/share/perl6/re= sources")))=0A- #t))=0A-=0A-(define* (wrap #:key inputs outputs #:allow-= other-keys)=0A- (define (list-of-files dir)=0A- (map (cut string-appe= nd dir "/" <>)=0A- (or (scandir dir (lambda (f)=0A- = (let ((s (stat (string-append dir "/" f))))=0A- = (and (eq? 'regular (stat:type s))=0A- = (not (wrapped-program? f))))))=0A- '())))=0A= -=0A- (define bindirs=0A- (append-map (match-lambda=0A- = ((_ . dir)=0A- (list (string-append dir "/bin")=0A- = (string-append dir "/sbin"))))=0A- o= utputs))=0A-=0A- ;; Do not require bash to be present in the package inp= uts=0A- ;; even when there is nothing to wrap.=0A- ;; Also, calculate (= sh) only once to prevent some I/O.=0A- (define %sh (delay (search-input-= file inputs "bin/bash")))=0A- (define (sh) (force %sh))=0A-=0A- (let* (= (out (assoc-ref outputs "out"))=0A- (var `("PERL6LIB" "," prefix= =0A- ,(cons (string-append out "/share/perl6/lib,"=0A- = out "/share/perl6/site/lib,"=0A- = out "/share/perl6/vendor/lib")=0A- = (search-path-as-string->list=0A- (o= r (getenv "PERL6LIB") "") #\,)))))=0A- (for-each (lambda (dir)=0A- = (let ((files (list-of-files dir)))=0A- (for-= each (cut wrap-program <> #:sh (sh) var)=0A- f= iles)))=0A- bindirs)=0A- #t))=0A+ "Install the resources= supplied by a Raku package. Resources are typically=0A+items such as co= nfiguration or data files; for details, see=0A+https://docs.raku.org/lang= uage/variables#%?RESOURCES"=0A+ (when (file-exists? "resources")=0A+ = (let* ((out (assoc-ref outputs "out"))=0A+ (resources-dir (str= ing-append out "/share/perl6/resources")))=0A+ (copy-recursively "re= sources" resources-dir))))=0A+=0A+(define* (install-bins #:key outputs #:= allow-other-keys)=0A+ "Install any binary programs supplied by a Raku pa= ckage."=0A+=0A+ (define (install-file-list file-list target-dir)=0A+ = (for-each (cut install-file <> target-dir) file-list))=0A+=0A+ (let* ((b= inary-dirs (filter file-exists? '("bin" "sbin")))=0A+ (out (asso= c-ref outputs "out")))=0A+ (when binary-dirs=0A+ (for-each (lambda= (binary-dir)=0A+ (install-file-list (find-files binary-d= ir)=0A+ (string-append out "/" binary-= dir)))=0A+ binary-dirs))))=0A+=0A+(define* (wrap-raku-progr= ams #:key inputs outputs #:allow-other-keys)=0A+ "Wrap executable Raku p= rograms to ensure they always uses the correct inputs =0A+(including the = correct Rakudo version) even if other versions are installed."=0A+=0A+ (= define (with-rakulib program rakulib)=0A+ (wrap-program program #:sh (= search-input-file inputs "bin/sh")=0A+ `("RAKULIB" "," p= refix ,rakulib)))=0A+=0A+ (let ((out (assoc-ref outputs "out")))=0A+ = (define bin-dirs=0A+ (filter directory-exists?=0A+ (lis= t (string-append out "/bin")=0A+ (string-append out "/= sbin"))))=0A+ (unless (eq? bin-dirs '())=0A+ (let* ((bin-files (f= old append '() (map find-files bin-dirs)))=0A+ (wrappable-bin= -files (filter (negate wrapped-program?) bin-files))=0A+ (rak= u-vendor-paths (inputs->raku-vendor-paths inputs))=0A+ (raku-= installations (map dir->inst raku-vendor-paths))=0A+ (current= -installation (dir->inst (with-vendor-path out)))=0A+ (xdg-da= ta-home-inst "inst#${XDG_DATA_HOME:-$HOME/.local/share}")=0A+ = (guix-pkg-index-file (string-append xdg-data-home-inst=0A+ = "/raku/repo")))=0A+ (for-each = (cut with-rakulib=0A+ <>=0A+ = (append (list current-installation)=0A+ rak= u-installations=0A+ (list guix-pkg-index-fi= le)))=0A+ wrappable-bin-files)))))=0A+=0A+(define* (prec= ompile #:key inputs outputs #:allow-other-keys)=0A+ "Fully precompile al= l Raku code."=0A+ (let ((provides (extract-provided-modules (read-string= (open-input-file "META6.json")))))=0A+ (let* ((out (assoc-ref outputs= "out"))=0A+ (rakudo-dir (assoc-ref inputs "rakudo"))=0A+ = (rakudo (string-append rakudo-dir "/bin/.rakudo-real")))=0A+= (setenv "RAKULIB" (dir->inst (with-vendor-path out)))=0A+ = (for-each (lambda (module)=0A+ (invoke rakudo=0A= + "-c" ; compile w/o running=0A+ = "-e" (string-append "use " module)))=0A+ = provides))))=0A =0A (define %standard-phases=0A- ;; No need for 'bo= otstrap, 'configure or 'build.=0A (modify-phases gnu:%standard-phases= =0A (delete 'bootstrap)=0A (delete 'configure)=0A (delete 'bu= ild)=0A+ (add-after 'unpack 'setup-rakudo-environment setup-rakudo-env= )=0A (replace 'check check)=0A (replace 'install install)=0A- = (add-before 'install 'install-lib-dir install-libs)=0A- (add-after 'in= stall-lib-dir 'install-resources install-resources)=0A+ (add-after 'in= stall 'install-resources install-resources)=0A (add-after 'install-re= sources 'install-binaries install-bins)=0A- ;; needs to be after 'inst= all-binaries and all 'install phases=0A- (add-after 'install 'wrap wra= p)))=0A+ ;; needs to be after 'install-binaries=0A+ (add-after 'ins= tall-binaries 'wrap-raku-programs wrap-raku-programs)=0A+ (add-after '= wrap-raku-programs 'precompile-raku-modules precompile)))=0A =0A (define*= (rakudo-build #:key inputs (phases %standard-phases)=0A = #:allow-other-keys #:rest args)=0A- "Build the given Perl6 packag= e, applying all of PHASES in order."=0A+ "Build the given Raku package, = applying all of PHASES in order."=0A (apply gnu:gnu-build=0A- #= :inputs inputs #:phases phases=0A+ #:inputs inputs=0A+ #:= phases phases=0A args))=0A =0A+=0A ;;; rakudo-build-system.scm e= nds here=0A-- =0A2.37.3