packages: Add `native-search-paths' field and honor it.

* guix/packages.scm (<search-path-specification>): New record type.
  (search-path-specification->sexp): New procedure.
  (<package>)[native-search-paths]: New field.
  (package-derivation): Accumulate the search paths, and pass them
  as #:search-paths toe BUILDER.
* guix/build-system/gnu.scm (gnu-build): Add #:search-paths.  Compute
  `implicit-search-paths'.  Pass #:search-paths in BUILDER.
* guix/build-system/perl.scm (perl-build): Add #:search-paths, pass it
  to BUILDER with the search paths of PERL.
* guix/build-system/cmake.scm (cmake-build): Add #:search-paths, pass it
  to BUILDER.
* guix/build-system/trivial.scm (trivial-build): Add #:search-paths,
  ignore it.
* guix/build/gnu-build-system.scm (set-paths): Add #:search-paths.
  Remove explicit settings of CPATH, LIBRARY_PATH, and PKG_CONFIG_PATH.
  Instead, walk SEARCH-PATHS and call `set-path-environment-variable'
  for them.
* guix/build/perl-build-system.scm (perl-build): Remove PERL5LIB setting.
* tests/packages.scm ("search paths"): New test.
* gnu/packages/bootstrap.scm (%bootstrap-guile)[raw]: Add
  #:search-paths.
  (%bootstrap-gcc): Add `native-search-paths' field.
* gnu/packages/perl.scm (perl): Likewise.
* gnu/packages/pkg-config.scm (pkg-config): Likewise.
* gnu/packages/glib.scm (intltool): Remove `arguments'.
* gnu/packages/avahi.scm (avahi): Remove #:phases.
This commit is contained in:
Ludovic Courtès 2013-03-30 22:56:38 +01:00
parent 5cfdb4bcac
commit a18eda2747
14 changed files with 145 additions and 57 deletions

View file

@ -48,19 +48,7 @@ (define-public avahi
"--disable-xmltoman" "--disable-xmltoman"
"--enable-tests" "--enable-tests"
"--disable-qt3" "--disable-qt4" "--disable-qt3" "--disable-qt4"
"--disable-gtk" "--disable-gtk3") "--disable-gtk" "--disable-gtk3")))
#:phases (alist-cons-before
'configure 'set-perl-path
(lambda* (#:key inputs #:allow-other-keys)
;; FIXME: Remove this phase when proper support for search
;; paths is available.
(let ((xml-parser (assoc-ref inputs
"intltool/perl-xml-parser")))
(setenv "PERL5LIB"
(string-append xml-parser
"/lib/perl5/site_perl"))
#t))
%standard-phases)))
(inputs (inputs
`(("expat" ,expat) `(("expat" ,expat)
("glib" ,glib) ("glib" ,glib)

View file

@ -154,7 +154,8 @@ (define %bootstrap-guile
(let ((raw (build-system (let ((raw (build-system
(name "raw") (name "raw")
(description "Raw build system with direct store access") (description "Raw build system with direct store access")
(build (lambda* (store name source inputs #:key outputs system) (build (lambda* (store name source inputs
#:key outputs system search-paths)
(define (->store file) (define (->store file)
(add-to-store store file #t "sha256" (add-to-store store file #t "sha256"
(or (search-bootstrap-binary file (or (search-bootstrap-binary file
@ -352,6 +353,13 @@ (define %bootstrap-gcc
("i686-linux" ("i686-linux"
(base32 (base32
"06wqs0xxnpw3hn0xjb4c9cs0899p1xwkcysa2rvzhvpra0c5vsg2"))))))))) "06wqs0xxnpw3hn0xjb4c9cs0899p1xwkcysa2rvzhvpra0c5vsg2")))))))))
(native-search-paths
(list (search-path-specification
(variable "CPATH")
(directories '("include")))
(search-path-specification
(variable "LIBRARY_PATH")
(directories '("lib" "lib64")))))
(synopsis "Bootstrap binaries of the GNU Compiler Collection") (synopsis "Bootstrap binaries of the GNU Compiler Collection")
(description #f) (description #f)
(home-page #f) (home-page #f)

View file

@ -131,6 +131,14 @@ (define-public gcc-4.7
"install")))) "install"))))
%standard-phases))))) %standard-phases)))))
(native-search-paths
(list (search-path-specification
(variable "CPATH")
(directories '("include")))
(search-path-specification
(variable "LIBRARY_PATH")
(directories '("lib" "lib64")))))
(properties `((gcc-libc . ,(assoc-ref inputs "libc")))) (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
(synopsis "The GNU Compiler Collection") (synopsis "The GNU Compiler Collection")
(description (description

View file

@ -142,18 +142,6 @@ (define-public intltool
(base32 (base32
"0r1vkvy5xzqk01yl6a0xlrry39bra24alkrx6279b77hc62my7jd")))) "0r1vkvy5xzqk01yl6a0xlrry39bra24alkrx6279b77hc62my7jd"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(arguments
'(#:phases (alist-cons-before
'configure 'set-perl-path
(lambda* (#:key inputs #:allow-other-keys)
;; FIXME: Remove this phase when proper support for search
;; paths is available.
(let ((xml-parser (assoc-ref inputs "perl-xml-parser")))
(setenv "PERL5LIB"
(string-append xml-parser
"/lib/perl5/site_perl"))
#t))
%standard-phases)))
(native-inputs `(("pkg-config" ,pkg-config))) (native-inputs `(("pkg-config" ,pkg-config)))
(propagated-inputs (propagated-inputs
`(("gettext" ,guix:gettext) `(("gettext" ,guix:gettext)

View file

@ -63,6 +63,9 @@ (define-public perl
(string-append "-Dloclibpth=" libc "/lib"))))) (string-append "-Dloclibpth=" libc "/lib")))))
%standard-phases))) %standard-phases)))
(inputs `(("patch/no-sys-dirs" ,(search-patch "perl-no-sys-dirs.patch")))) (inputs `(("patch/no-sys-dirs" ,(search-patch "perl-no-sys-dirs.patch"))))
(native-search-paths (list (search-path-specification
(variable "PERL5LIB")
(directories '("lib/perl5/site_perl")))))
(synopsis "Implementation of the Perl programming language") (synopsis "Implementation of the Perl programming language")
(description (description
"Perl 5 is a highly capable, feature-rich programming language with over "Perl 5 is a highly capable, feature-rich programming language with over

View file

@ -36,6 +36,11 @@ (define-public pkg-config
"05wc5nwkqz7saj2v33ydmz1y6jdg659dll4jjh91n41m63gx0qsg")))) "05wc5nwkqz7saj2v33ydmz1y6jdg659dll4jjh91n41m63gx0qsg"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(arguments `(#:configure-flags '("--with-internal-glib"))) (arguments `(#:configure-flags '("--with-internal-glib")))
(native-search-paths
(list (search-path-specification
(variable "PKG_CONFIG_PATH")
(directories '("lib/pkgconfig" "lib64/pkgconfig"
"share/pkgconfig")))))
(home-page "http://www.freedesktop.org/wiki/Software/pkg-config") (home-page "http://www.freedesktop.org/wiki/Software/pkg-config")
(license gpl2+) (license gpl2+)
(synopsis "a helper tool used when compiling applications and (synopsis "a helper tool used when compiling applications and

View file

@ -38,6 +38,7 @@ (define-module (guix build-system cmake)
(define* (cmake-build store name source inputs (define* (cmake-build store name source inputs
#:key (guile #f) #:key (guile #f)
(outputs '("out")) (configure-flags ''()) (outputs '("out")) (configure-flags ''())
(search-paths '())
(make-flags ''()) (make-flags ''())
(patches ''()) (patch-flags ''("--batch" "-p1")) (patches ''()) (patch-flags ''("--batch" "-p1"))
(cmake (@ (gnu packages cmake) cmake)) (cmake (@ (gnu packages cmake) cmake))
@ -70,6 +71,8 @@ (define builder
#:system ,system #:system ,system
#:outputs %outputs #:outputs %outputs
#:inputs %build-inputs #:inputs %build-inputs
#:search-paths ',(map search-path-specification->sexp
search-paths)
#:patches ,patches #:patches ,patches
#:patch-flags ,patch-flags #:patch-flags ,patch-flags
#:phases ,phases #:phases ,phases

View file

@ -159,7 +159,9 @@ (define standard-inputs
(define* (gnu-build store name source inputs (define* (gnu-build store name source inputs
#:key (guile #f) #:key (guile #f)
(outputs '("out")) (configure-flags ''()) (outputs '("out"))
(search-paths '())
(configure-flags ''())
(make-flags ''()) (make-flags ''())
(patches ''()) (patch-flags ''("--batch" "-p1")) (patches ''()) (patch-flags ''("--batch" "-p1"))
(out-of-source? #f) (out-of-source? #f)
@ -189,6 +191,21 @@ (define* (gnu-build store name source inputs
between both, because for Guile's own modules like (ice-9 foo), we want between both, because for Guile's own modules like (ice-9 foo), we want
to use GUILE's own version of it, rather than import the user's one, to use GUILE's own version of it, rather than import the user's one,
which could lead to gratuitous input divergence." which could lead to gratuitous input divergence."
(define implicit-inputs
(and implicit-inputs?
(parameterize ((%store store))
(standard-inputs system))))
(define implicit-search-paths
(if implicit-inputs?
(append-map (match-lambda
((_ (? package? p) _ ...)
(package-native-search-paths p))
(_
'()))
implicit-inputs)
'()))
(define builder (define builder
`(begin `(begin
(use-modules ,@modules) (use-modules ,@modules)
@ -198,6 +215,9 @@ (define builder
#:system ,system #:system ,system
#:outputs %outputs #:outputs %outputs
#:inputs %build-inputs #:inputs %build-inputs
#:search-paths ',(map search-path-specification->sexp
(append implicit-search-paths
search-paths))
#:patches ,patches #:patches ,patches
#:patch-flags ,patch-flags #:patch-flags ,patch-flags
#:phases ,phases #:phases ,phases
@ -231,8 +251,7 @@ (define guile-for-build
'()) '())
,@inputs ,@inputs
,@(if implicit-inputs? ,@(if implicit-inputs?
(parameterize ((%store store)) implicit-inputs
(standard-inputs system))
'())) '()))
#:outputs outputs #:outputs outputs
#:modules imported-modules #:modules imported-modules

View file

@ -38,6 +38,7 @@ (define-module (guix build-system perl)
(define* (perl-build store name source inputs (define* (perl-build store name source inputs
#:key #:key
(perl (@ (gnu packages perl) perl)) (perl (@ (gnu packages perl) perl))
(search-paths '())
(tests? #t) (tests? #t)
(make-maker-flags ''()) (make-maker-flags ''())
(phases '(@ (guix build perl-build-system) (phases '(@ (guix build perl-build-system)
@ -53,6 +54,9 @@ (define* (perl-build store name source inputs
(guix build utils)))) (guix build utils))))
"Build SOURCE using PERL, and with INPUTS. This assumes that SOURCE "Build SOURCE using PERL, and with INPUTS. This assumes that SOURCE
provides a `Makefile.PL' file as its build system." provides a `Makefile.PL' file as its build system."
(define perl-search-paths
(package-native-search-paths perl))
(define builder (define builder
`(begin `(begin
(use-modules ,@modules) (use-modules ,@modules)
@ -60,6 +64,9 @@ (define builder
#:source ,(if (and source (derivation-path? source)) #:source ,(if (and source (derivation-path? source))
(derivation-path->output-path source) (derivation-path->output-path source)
source) source)
#:search-paths ',(map search-path-specification->sexp
(append perl-search-paths
search-paths))
#:make-maker-flags ,make-maker-flags #:make-maker-flags ,make-maker-flags
#:system ,system #:system ,system
#:test-target "test" #:test-target "test"

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -26,7 +26,9 @@ (define-module (guix build-system trivial)
#:export (trivial-build-system)) #:export (trivial-build-system))
(define* (trivial-build store name source inputs (define* (trivial-build store name source inputs
#:key outputs guile system builder (modules '())) #:key
outputs guile system builder (modules '())
search-paths)
"Run build expression BUILDER, an expression, for SYSTEM. SOURCE is "Run build expression BUILDER, an expression, for SYSTEM. SOURCE is
ignored." ignored."
(define guile-for-build (define guile-for-build

View file

@ -48,26 +48,22 @@ (define (first-subdirectory dir)
#f #f
dir)) dir))
(define* (set-paths #:key inputs (define* (set-paths #:key inputs (search-paths '())
#:allow-other-keys) #:allow-other-keys)
(define input-directories (define input-directories
(match inputs (match inputs
(((_ . dir) ...) (((_ . dir) ...)
dir))) dir)))
(set-path-environment-variable "PATH" '("bin") (set-path-environment-variable "PATH" '("bin" "sbin")
input-directories)
(set-path-environment-variable "CPATH" '("include")
input-directories)
(set-path-environment-variable "LIBRARY_PATH" '("lib" "lib64")
input-directories) input-directories)
;; FIXME: Eventually move this to the `search-paths' field of the (for-each (match-lambda
;; `pkg-config' package. ((env-var (directories ...) separator)
(set-path-environment-variable "PKG_CONFIG_PATH" (set-path-environment-variable env-var directories
'("lib/pkgconfig" "lib64/pkgconfig" input-directories
"share/pkgconfig") #:separator separator)))
input-directories) search-paths)
;; Dump the environment variables as a shell script, for handy debugging. ;; Dump the environment variables as a shell script, for handy debugging.
(system "export > environment-variables")) (system "export > environment-variables"))

View file

@ -50,10 +50,6 @@ (define %standard-phases
(define* (perl-build #:key inputs (phases %standard-phases) (define* (perl-build #:key inputs (phases %standard-phases)
#:allow-other-keys #:rest args) #:allow-other-keys #:rest args)
"Build the given Perl package, applying all of PHASES in order." "Build the given Perl package, applying all of PHASES in order."
(set-path-environment-variable "PERL5LIB" '("lib/perl5/site_perl")
(match inputs
(((_ . path) ...)
path)))
(apply gnu:gnu-build (apply gnu:gnu-build
#:inputs inputs #:phases phases #:inputs inputs #:phases phases
args)) args))

View file

@ -37,6 +37,11 @@ (define-module (guix packages)
origin-file-name origin-file-name
base32 base32
<search-path-specification>
search-path-specification
search-path-specification?
search-path-specification->sexp
package package
package? package?
package-name package-name
@ -49,6 +54,7 @@ (define-module (guix packages)
package-native-inputs package-native-inputs
package-propagated-inputs package-propagated-inputs
package-outputs package-outputs
package-native-search-paths
package-search-paths package-search-paths
package-synopsis package-synopsis
package-description package-description
@ -104,8 +110,22 @@ (define-syntax base32
((_ str) ((_ str)
#'(nix-base32-string->bytevector str))))) #'(nix-base32-string->bytevector str)))))
;; A package. ;; The specification of a search path.
(define-record-type* <search-path-specification>
search-path-specification make-search-path-specification
search-path-specification?
(variable search-path-specification-variable)
(directories search-path-specification-directories)
(separator search-path-specification-separator (default ":")))
(define (search-path-specification->sexp spec)
"Return an sexp representing SPEC, a <search-path-specification>. The sexp
corresponds to the arguments expected by `set-path-environment-variable'."
(match spec
(($ <search-path-specification> variable directories separator)
`(,variable ,directories ,separator))))
;; A package.
(define-record-type* <package> (define-record-type* <package>
package make-package package make-package
package? package?
@ -128,10 +148,13 @@ (define-record-type* <package>
(outputs package-outputs ; list of strings (outputs package-outputs ; list of strings
(default '("out"))) (default '("out")))
(search-paths package-search-paths ; list of (ENV-VAR (DIRS ...))
(default '())) ; tuples; see ; lists of
; `set-path-environment-variable' ; <search-path-specification>,
; (aka. "setup-hook") ; for native and cross
; inputs
(native-search-paths package-native-search-paths (default '()))
(search-paths package-search-paths (default '()))
(synopsis package-synopsis) ; one-line description (synopsis package-synopsis) ; one-line description
(description package-description) ; one or two paragraphs (description package-description) ; one or two paragraphs
@ -292,16 +315,22 @@ (define expand-input
(($ <package> name version source (= build-system-builder builder) (($ <package> name version source (= build-system-builder builder)
args inputs propagated-inputs native-inputs self-native-input? args inputs propagated-inputs native-inputs self-native-input?
outputs) outputs)
;; TODO: For `search-paths', add a builder prologue that calls (let* ((inputs (package-transitive-inputs package))
;; `set-path-environment-variable'. (input-drvs (map expand-input inputs))
(let ((inputs (map expand-input (paths (delete-duplicates
(package-transitive-inputs package)))) (append-map (match-lambda
((_ (? package? p) _ ...)
(package-native-search-paths
p))
(_ '()))
inputs))))
(apply builder (apply builder
store (package-full-name package) store (package-full-name package)
(and source (and source
(package-source-derivation store source system)) (package-source-derivation store source system))
inputs input-drvs
#:search-paths paths
#:outputs outputs #:system system #:outputs outputs #:system system
(args)))))))) (args))))))))

View file

@ -22,6 +22,7 @@ (define-module (test-packages)
#:use-module (guix utils) #:use-module (guix utils)
#:use-module (guix derivations) #:use-module (guix derivations)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix build-system)
#:use-module (guix build-system trivial) #:use-module (guix build-system trivial)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (gnu packages) #:use-module (gnu packages)
@ -138,6 +139,41 @@ (define-syntax-rule (dummy-package name* extra-fields ...)
(let ((p (pk 'drv d (derivation-path->output-path d)))) (let ((p (pk 'drv d (derivation-path->output-path d))))
(eq? 'hello (call-with-input-file p read)))))) (eq? 'hello (call-with-input-file p read))))))
(test-assert "search paths"
(let* ((p (make-prompt-tag "return-search-paths"))
(s (build-system
(name "raw")
(description "Raw build system with direct store access")
(build (lambda* (store name source inputs
#:key outputs system search-paths)
search-paths))))
(x (list (search-path-specification
(variable "GUILE_LOAD_PATH")
(directories '("share/guile/site/2.0")))
(search-path-specification
(variable "GUILE_LOAD_COMPILED_PATH")
(directories '("share/guile/site/2.0")))))
(a (package (inherit (dummy-package "guile"))
(build-system s)
(native-search-paths x)))
(b (package (inherit (dummy-package "guile-foo"))
(build-system s)
(inputs `(("guile" ,a)))))
(c (package (inherit (dummy-package "guile-bar"))
(build-system s)
(inputs `(("guile" ,a)
("guile-foo" ,b))))))
(let-syntax ((collect (syntax-rules ()
((_ body ...)
(call-with-prompt p
(lambda ()
body ...)
(lambda (k search-paths)
search-paths))))))
(and (null? (collect (package-derivation %store a)))
(equal? x (collect (package-derivation %store b)))
(equal? x (collect (package-derivation %store c)))))))
(unless (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)) (unless (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV))
(test-skip 1)) (test-skip 1))
(test-assert "GNU Make, bootstrap" (test-assert "GNU Make, bootstrap"