From fe56213027d9828c61fa06211458a23f32431e0b Mon Sep 17 00:00:00 2001 From: John Kehayias Date: Wed, 21 Jul 2021 00:20:29 +0200 Subject: guix: haskell-build-system: Always pass -package-db option. * guix/build/haskell-build-system.scm (run-setuphs): Pass -package-db option. Signed-off-by: Ricardo Wurmus --- guix/build/haskell-build-system.scm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'guix/build/haskell-build-system.scm') diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm index 28253ce2f0..171100ecf7 100644 --- a/guix/build/haskell-build-system.scm +++ b/guix/build/haskell-build-system.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2015 Paul van der Walt ;;; Copyright © 2018, 2020 Ricardo Wurmus ;;; Copyright © 2018 Alex Vong +;;; Copyright © 2021 John Kehayias ;;; ;;; This file is part of GNU Guix. ;;; @@ -63,13 +64,14 @@ ((file-exists? "Setup.lhs") "Setup.lhs") (else - #f)))) + #f))) + (pkgdb (string-append "-package-db=" %tmp-db-dir))) (if setup-file (begin (format #t "running \"runhaskell Setup.hs\" with command ~s \ and parameters ~s~%" command params) - (apply invoke "runhaskell" setup-file command params)) + (apply invoke "runhaskell" pkgdb setup-file command params)) (error "no Setup.hs nor Setup.lhs found")))) (define* (configure #:key outputs inputs tests? (configure-flags '()) -- cgit v1.2.3 From 7cdb65dc9cceebfd3a45eeb281530f91f1b43b81 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Fri, 17 Sep 2021 08:55:08 +0200 Subject: build-system/haskell: Do not rely on compiler name. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We’ve been relying on the compiler name matching its package subdir. Since we effectively only support GHC we can hard-code this and avoid issues with “ghc-next”. * guix/build/haskell-build-system.scm (make-ghc-package-database): Use GHC_PACKAGE_PATH. (register): Hard-code ghc prefix. --- guix/build/haskell-build-system.scm | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'guix/build/haskell-build-system.scm') diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm index 171100ecf7..7d50bae721 100644 --- a/guix/build/haskell-build-system.scm +++ b/guix/build/haskell-build-system.scm @@ -175,15 +175,8 @@ first match and return the content of the group." "Generate the GHC package database." (let* ((haskell (assoc-ref inputs "haskell")) (name-version (strip-store-file-name haskell)) - (input-dirs (match inputs - (((_ . dir) ...) - dir) - (_ '()))) ;; Silence 'find-files' (see 'evaluate-search-paths') - (conf-dirs (with-null-error-port - (search-path-as-list - `(,(string-append "lib/" name-version)) - input-dirs #:pattern ".*\\.conf.d$"))) + (conf-dirs (search-path-as-string->list (getenv "GHC_PACKAGE_PATH"))) (conf-files (append-map (cut find-files <> "\\.conf$") conf-dirs))) (mkdir-p %tmp-db-dir) (for-each (lambda (file) @@ -243,10 +236,11 @@ given Haskell package." (let* ((out (assoc-ref outputs "out")) (doc (assoc-ref outputs "doc")) (haskell (assoc-ref inputs "haskell")) - (name-verion (strip-store-file-name haskell)) + (name-version (strip-store-file-name haskell)) + (version (last (string-split name-version #\-))) (lib (string-append (or (assoc-ref outputs "lib") out) "/lib")) (config-dir (string-append lib - "/" name-verion + "/ghc-" version "/" name ".conf.d")) (id-rx (make-regexp "^id: *(.*)$")) (config-file (string-append out "/" name ".conf")) -- cgit v1.2.3 From a01daed62c24d62e8350ce15d7a19aed37289807 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Fri, 17 Sep 2021 10:17:33 +0200 Subject: build-system/haskell: Accept line breaks in config files. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Long id’s will break to the next line. * guix/build/haskell-build-system.scm (grep): Remove. (register): Modify regular expression to account for newlines between key and value, fail if package id is empty. --- guix/build/haskell-build-system.scm | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'guix/build/haskell-build-system.scm') diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm index 7d50bae721..4d0bf6f38a 100644 --- a/guix/build/haskell-build-system.scm +++ b/guix/build/haskell-build-system.scm @@ -143,17 +143,6 @@ and parameters ~s~%" (find-files lib "\\.a$")))) #t) -(define (grep rx port) - "Given a regular-expression RX including a group, read from PORT until the -first match and return the content of the group." - (let ((line (read-line port))) - (if (eof-object? line) - #f - (let ((rx-result (regexp-exec rx line))) - (if rx-result - (match:substring rx-result 1) - (grep rx port)))))) - (define* (setup-compiler #:key system inputs outputs #:allow-other-keys) "Setup the compiler environment." (let* ((haskell (assoc-ref inputs "haskell")) @@ -242,7 +231,7 @@ given Haskell package." (config-dir (string-append lib "/ghc-" version "/" name ".conf.d")) - (id-rx (make-regexp "^id: *(.*)$")) + (id-rx (make-regexp "^id:[ \n\t]+([^ \t\n]+)$" regexp/newline)) (config-file (string-append out "/" name ".conf")) (params (list (string-append "--gen-pkg-config=" config-file)))) @@ -250,8 +239,15 @@ given Haskell package." ;; The conf file is created only when there is a library to register. (when (file-exists? config-file) (mkdir-p config-dir) - (let ((config-file-name+id - (call-with-ascii-input-file config-file (cut grep id-rx <>)))) + (let* ((contents (call-with-input-file config-file read-string)) + (config-file-name+id (match:substring (first (list-matches id-rx contents)) 1))) + + (when (or + (and + (string? config-file-name+id) + (string-null? config-file-name+id)) + (not config-file-name+id)) + (error (format #f "The package id for ~a is empty. This is a bug." config-file))) ;; Remove reference to "doc" output from "lib" (or "out") by rewriting the ;; "haddock-interfaces" field and removing the optional "haddock-html" -- cgit v1.2.3 From b74ca403cbb11c60d57b6a0148d97c6572019754 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sun, 19 Sep 2021 11:10:16 +0200 Subject: build-system/haskell: Explain failure. Provide human-readable failure message and explain how to fix it. * guix/build/haskell-build-system.scm (register): Raise error if source file does not exist. --- guix/build/haskell-build-system.scm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'guix/build/haskell-build-system.scm') diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm index 4d0bf6f38a..ef6cb316ee 100644 --- a/guix/build/haskell-build-system.scm +++ b/guix/build/haskell-build-system.scm @@ -217,6 +217,8 @@ given Haskell package." (if (not (vhash-assoc id seen)) (let ((dep-conf (string-append src "/" id ".conf")) (dep-conf* (string-append dest "/" id ".conf"))) + (when (not (file-exists? dep-conf)) + (error (format #f "File ~a does not exist. This usually means the dependency ~a is missing. Was checking conf-file ~a." dep-conf id conf-file))) (copy-file dep-conf dep-conf*) ;XXX: maybe symlink instead? (loop (vhash-cons id #t seen) (append lst (conf-depends dep-conf)))) -- cgit v1.2.3