summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2019-03-23 22:50:07 +0100
committerMarius Bakke <mbakke@fastmail.com>2019-03-23 22:50:07 +0100
commit3cb61ca85a634db2dcc2badaf3492440bf621d92 (patch)
tree72561a5f7056aa29cec7d50fb8b960b32b44a585 /guix
parenta60370727a77d1658307698276239c153d8279e8 (diff)
parentf92854fea150f0d47c4984f87bf21bd5f8051820 (diff)
downloadguix-patches-3cb61ca85a634db2dcc2badaf3492440bf621d92.tar
guix-patches-3cb61ca85a634db2dcc2badaf3492440bf621d92.tar.gz
Merge branch 'master' into staging
Diffstat (limited to 'guix')
-rw-r--r--guix/build-system/rakudo.scm155
-rw-r--r--guix/build/rakudo-build-system.scm145
-rw-r--r--guix/import/opam.scm2
-rw-r--r--guix/scripts/graph.scm31
4 files changed, 330 insertions, 3 deletions
diff --git a/guix/build-system/rakudo.scm b/guix/build-system/rakudo.scm
new file mode 100644
index 0000000000..a02e2bad3a
--- /dev/null
+++ b/guix/build-system/rakudo.scm
@@ -0,0 +1,155 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build-system rakudo)
+ #:use-module (guix store)
+ #:use-module (guix utils)
+ #:use-module (guix derivations)
+ #:use-module (guix search-paths)
+ #:use-module (guix build-system)
+ #:use-module (guix build-system gnu)
+ #:use-module (guix packages)
+ #:use-module (ice-9 match)
+ #:export (%rakudo-build-system-modules
+ rakudo-build
+ rakudo-build-system))
+
+;; Commentary:
+;;
+;; Standard build and install procedure for packages using the Rakudo
+;; build system to be installed as system libraries. This is
+;; implemented as an extension of `gnu-build-system'.
+;;
+;; Code:
+
+(define %rakudo-build-system-modules
+ ;; Build-side modules imported by default.
+ `((guix build rakudo-build-system)
+ ,@%gnu-build-system-modules))
+
+(define (default-rakudo)
+ "Return the default Rakudo package."
+
+ ;; Do not use `@' to avoid introducing circular dependencies.
+ (let ((module (resolve-interface '(gnu packages perl6))))
+ (module-ref module 'rakudo)))
+
+(define (default-prove6)
+ "Return the default perl6-tap-harness package for tests."
+ (let ((module (resolve-interface '(gnu packages perl6))))
+ (module-ref module 'perl6-tap-harness)))
+
+(define (default-zef)
+ "Return the default perl6-zef package."
+ (let ((module (resolve-interface '(gnu packages perl6))))
+ (module-ref module 'perl6-zef)))
+
+(define* (lower name
+ #:key source inputs native-inputs outputs
+ system target
+ (rakudo (default-rakudo))
+ (prove6 (default-prove6))
+ (zef (default-zef))
+ (with-prove6? #t)
+ (with-zef? #t)
+ #:allow-other-keys
+ #:rest arguments)
+ "Return a bag for NAME."
+ (define private-keywords
+ '(#:source #:target #:rakudo #:prove6 #:zef #:inputs #:native-inputs))
+
+ (and (not target) ;XXX: no cross-compilation
+ (bag
+ (name name)
+ (system system)
+ (host-inputs `(,@(if source
+ `(("source" ,source))
+ '())
+ ,@inputs
+
+ ;; Keep the standard inputs of 'gnu-build-system'.
+ ,@(standard-packages)))
+ (build-inputs `(("rakudo" ,rakudo)
+ ,@(if with-prove6?
+ `(("perl6-tap-harness" ,prove6)
+ ,@(if with-zef?
+ `(("perl6-zef" ,zef))
+ '()))
+ '())
+ ,@native-inputs))
+ (outputs outputs)
+ (build rakudo-build)
+ (arguments (strip-keyword-arguments private-keywords arguments)))))
+
+(define* (rakudo-build store name inputs
+ #:key
+ (search-paths '())
+ (tests? #t)
+ (phases '(@ (guix build rakudo-build-system)
+ %standard-phases))
+ (outputs '("out"))
+ (system (%current-system))
+ (guile #f)
+ (with-zef? #t)
+ (with-prove6? #t)
+ (imported-modules %rakudo-build-system-modules)
+ (modules '((guix build rakudo-build-system)
+ (guix build utils))))
+ "Build SOURCE using PERL6, and with INPUTS."
+ (define builder
+ `(begin
+ (use-modules ,@modules)
+ (rakudo-build #:name ,name
+ #:source ,(match (assoc-ref inputs "source")
+ (((? derivation? source))
+ (derivation->output-path source))
+ ((source)
+ source)
+ (source
+ source))
+ #:search-paths ',(map search-path-specification->sexp
+ search-paths)
+ #:phases ,phases
+ #:system ,system
+ #:tests? ,tests?
+ #:outputs %outputs
+ #:inputs %build-inputs)))
+
+ (define guile-for-build
+ (match guile
+ ((? package?)
+ (package-derivation store guile system #:graft? #f))
+ (#f ; the default
+ (let* ((distro (resolve-interface '(gnu packages commencement)))
+ (guile (module-ref distro 'guile-final)))
+ (package-derivation store guile system #:graft? #f)))))
+
+ (build-expression->derivation store name builder
+ #:system system
+ #:inputs inputs
+ #:modules imported-modules
+ #:outputs outputs
+ #:guile-for-build guile-for-build))
+
+(define rakudo-build-system
+ (build-system
+ (name 'rakudo)
+ (description "The standard Rakudo build system")
+ (lower lower)))
+
+;;; rakudo.scm ends here
diff --git a/guix/build/rakudo-build-system.scm b/guix/build/rakudo-build-system.scm
new file mode 100644
index 0000000000..dbdeb1ccd2
--- /dev/null
+++ b/guix/build/rakudo-build-system.scm
@@ -0,0 +1,145 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build rakudo-build-system)
+ #:use-module ((guix build gnu-build-system) #:prefix gnu:)
+ #:use-module (guix build utils)
+ #:use-module (ice-9 ftw)
+ #:use-module (ice-9 match)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
+ #:export (%standard-phases
+ rakudo-build))
+
+;; Commentary:
+;;
+;; Builder-side code of the standard Rakudo package build procedure.
+;;
+;; Code:
+
+(define* (check #:key tests? inputs with-prove6? #:allow-other-keys)
+ (if (and tests? (assoc-ref inputs "perl6-tap-harness"))
+ ;(if (and tests? with-prove6?)
+ (invoke "prove6" "-I=lib" "t/")
+ (format #t "test suite not run~%"))
+ #t)
+
+(define* (install #:key inputs outputs with-zef? #:allow-other-keys)
+ "Install a given Perl6 package."
+ (let* ((out (assoc-ref outputs "out"))
+ (perl6 (string-append out "/share/perl6")))
+ (if (assoc-ref inputs "perl6-zef")
+ ;(if with-zef?
+ (begin
+ (let ((zef (string-append (assoc-ref inputs "perl6-zef")
+ "/bin/zef")))
+ (setenv "HOME" (getcwd))
+ (mkdir-p perl6)
+ (invoke zef "install" "--verbose" "."
+ ;; Don't install any of the following:
+ "--/depends" "--/build-depends" "--/test-depends"
+ (string-append "--install-to=" perl6))
+ (delete-file (string-append perl6 "/repo.lock")))
+ #t)
+ (begin
+ (let ((inst (string-append (assoc-ref inputs "rakudo")
+ "/share/perl6/tools/install-dist.p6")))
+ (setenv "RAKUDO_RERESOLVE_DEPENDENCIES" "0")
+ (setenv "RAKUDO_MODULE_DEBUG" "1") ; be verbose while building
+ (invoke inst (string-append "--to=" perl6) "--for=site"))))))
+
+(define* (install-libs #:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out"))
+ (lock "lib/.precomp/.lock"))
+ (when (file-exists? lock)
+ (delete-file "lib/.precomp/.lock"))
+ (copy-recursively "lib" (string-append out "/share/perl6/lib"))
+ #t))
+
+(define* (install-bins #:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (when (file-exists? "bin")
+ (for-each (lambda (file)
+ (install-file file (string-append out "/bin"))
+ (chmod (string-append out "/" file) #o555))
+ (find-files "bin" ".*")))
+ (when (file-exists? "sbin")
+ (for-each (lambda (file)
+ (install-file file (string-append out "/sbin"))
+ (chmod (string-append out "/" file) #o555))
+ (find-files "sbin" ".*")))
+ #t))
+
+(define* (install-resources #:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (when (file-exists? "resources")
+ (copy-recursively "resources"
+ (string-append out "/share/perl6/resources")))
+ #t))
+
+(define* (wrap #:key inputs outputs #:allow-other-keys)
+ (define (list-of-files dir)
+ (map (cut string-append dir "/" <>)
+ (or (scandir dir (lambda (f)
+ (let ((s (stat (string-append dir "/" f))))
+ (eq? 'regular (stat:type s)))))
+ '())))
+
+ (define bindirs
+ (append-map (match-lambda
+ ((_ . dir)
+ (list (string-append dir "/bin")
+ (string-append dir "/sbin"))))
+ outputs))
+
+ (let* ((out (assoc-ref outputs "out"))
+ (var `("PERL6LIB" "," prefix
+ ,(cons (string-append out "/share/perl6/lib,"
+ out "/share/perl6/site/lib,"
+ out "/share/perl6/vendor/lib")
+ (search-path-as-string->list
+ (or (getenv "PERL6LIB") "") #\,)))))
+ (for-each (lambda (dir)
+ (let ((files (list-of-files dir)))
+ (for-each (cut wrap-program <> var)
+ files)))
+ bindirs)
+ #t))
+
+(define %standard-phases
+ ;; No need for 'bootstrap, 'configure or 'build.
+ (modify-phases gnu:%standard-phases
+ (delete 'bootstrap)
+ (delete 'configure)
+ (delete 'build)
+ (replace 'check check)
+ (replace 'install install)
+ (add-before 'install 'install-lib-dir install-libs)
+ (add-after 'install-lib-dir 'install-resources install-resources)
+ (add-after 'install-resources 'install-binaries install-bins)
+ ;; needs to be after 'install-binaries and all 'install phases
+ (add-after 'install 'wrap wrap)))
+
+(define* (rakudo-build #:key inputs (phases %standard-phases)
+ #:allow-other-keys #:rest args)
+ "Build the given Perl6 package, applying all of PHASES in order."
+ (apply gnu:gnu-build
+ #:inputs inputs #:phases phases
+ args))
+
+;;; rakudo-build-system.scm ends here
diff --git a/guix/import/opam.scm b/guix/import/opam.scm
index 7b2e832e92..36028a01d6 100644
--- a/guix/import/opam.scm
+++ b/guix/import/opam.scm
@@ -292,7 +292,7 @@ package in OPAM."
(define (opam-package? package)
"Return true if PACKAGE is an OCaml package from OPAM"
(and
- (equal? (build-system-name (package-build-system package)) 'ocaml)
+ (member (build-system-name (package-build-system package)) '(dune ocaml))
(not (string-prefix? "ocaml4" (package-name package)))))
(define (latest-release package)
diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm
index 8efeef3274..8fe81ad64b 100644
--- a/guix/scripts/graph.scm
+++ b/guix/scripts/graph.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -43,6 +43,7 @@
%bag-node-type
%bag-with-origins-node-type
%bag-emerged-node-type
+ %reverse-bag-node-type
%derivation-node-type
%reference-node-type
%referrer-node-type
@@ -110,11 +111,21 @@ name."
;;; Reverse package DAG.
;;;
+(define (all-packages) ;XXX: duplicated from (guix scripts refresh)
+ "Return the list of all the distro's packages."
+ (fold-packages (lambda (package result)
+ ;; Ignore deprecated packages.
+ (if (package-superseded package)
+ result
+ (cons package result)))
+ '()
+ #:select? (const #t))) ;include hidden packages
+
(define %reverse-package-node-type
;; For this node type we first need to compute the list of packages and the
;; list of back-edges. Since we want to do it only once, we use the
;; promises below.
- (let* ((packages (delay (fold-packages cons '())))
+ (let* ((packages (delay (all-packages)))
(back-edges (delay (run-with-store #f ;store not actually needed
(node-back-edges %package-node-type
(force packages))))))
@@ -219,6 +230,21 @@ GNU-BUILD-SYSTEM have zero dependencies."
bag-node-edges-sans-bootstrap)
%store-monad))))
+(define %reverse-bag-node-type
+ ;; Type for the reverse traversal of package nodes via the "bag"
+ ;; representation, which includes implicit inputs.
+ (let* ((packages (delay (package-closure (all-packages))))
+ (back-edges (delay (run-with-store #f ;store not actually needed
+ (node-back-edges %bag-node-type
+ (force packages))))))
+ (node-type
+ (name "reverse-bag")
+ (description "the reverse DAG of packages, including implicit inputs")
+ (convert nodes-from-package)
+ (identifier bag-node-identifier)
+ (label node-full-name)
+ (edges (lift1 (force back-edges) %store-monad)))))
+
;;;
;;; Derivation DAG.
@@ -375,6 +401,7 @@ package modules, while attempting to retain user package modules."
%bag-node-type
%bag-with-origins-node-type
%bag-emerged-node-type
+ %reverse-bag-node-type
%derivation-node-type
%reference-node-type
%referrer-node-type