job: Add load-path field to <job-spec>.

pull/3/head
Mathieu Lirzin 2016-07-02 01:51:56 +02:00
parent b185505db0
commit 94f910355c
4 changed files with 36 additions and 24 deletions

View File

@ -72,15 +72,22 @@ DIR if required."
commit commit
(string-append "origin/" branch))))))))) (string-append "origin/" branch)))))))))
(define (set-load-path! cachedir spec)
"Set %LOAD-PATH to match what is specified in SPEC."
(let* ((name (job-spec-name spec))
(path (job-spec-load-path spec))
(dir (string-join (list cachedir name path) "/")))
(format #t "prepending ~s to the load path~%" dir)
(set! %load-path (cons dir %load-path))))
(define (evaluate store db cachedir spec) (define (evaluate store db cachedir spec)
"Evaluate and build package derivations. Return a list a jobs." "Evaluate and build package derivations. Return a list a jobs."
(save-module-excursion (save-module-excursion
(lambda () (lambda ()
(set-current-module %user-module) (set-current-module %user-module)
(let ((dir (string-append cachedir "/" (job-spec-name spec)))) ;; Handle both relative and absolute file names for SPEC-FILE.
(format #t "prepending ~s to the load path~%" dir) (with-directory-excursion cachedir
(set! %load-path (cons dir %load-path))) (primitive-load (job-spec-file spec)))))
(primitive-load (job-spec-file spec))))
(let* ((proc (module-ref %user-module (job-spec-proc spec))) (let* ((proc (module-ref %user-module (job-spec-proc spec)))
(jobs (proc store (job-spec-arguments spec)))) (jobs (proc store (job-spec-arguments spec))))
(map (λ (job) (map (λ (job)
@ -140,6 +147,9 @@ DIR if required."
(for-each (for-each
(λ (spec) (λ (spec)
(fetch-repository cachedir spec) (fetch-repository cachedir spec)
(let ((old-path %load-path))
(and (job-spec-load-path spec)
(set-load-path! cachedir spec))
(let ((store ((guix-variable 'store 'open-connection)))) (let ((store ((guix-variable 'store 'open-connection))))
(dynamic-wind (dynamic-wind
(const #t) (const #t)
@ -150,6 +160,7 @@ DIR if required."
(set-build-options store #:use-substitutes? #f) (set-build-options store #:use-substitutes? #f)
(build-packages store db jobs))) (build-packages store db jobs)))
(lambda () (lambda ()
((guix-variable 'store 'close-connection) store))))) ((guix-variable 'store 'close-connection) store)
(set! %load-path old-path))))))
specs) specs)
(sleep (string->number interval)))))))))) (sleep (string->number interval))))))))))

View File

@ -22,6 +22,7 @@ abs_top_builddir="`cd "@abs_top_builddir@" > /dev/null; pwd`"
GUILE_LOAD_COMPILED_PATH="$abs_top_builddir/src${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH" GUILE_LOAD_COMPILED_PATH="$abs_top_builddir/src${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH"
GUILE_LOAD_PATH="$abs_top_builddir/src:$abs_top_srcdir/src${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH" GUILE_LOAD_PATH="$abs_top_builddir/src:$abs_top_srcdir/src${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH"
export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH
PATH="$abs_top_builddir/bin:$PATH" PATH="$abs_top_builddir/bin:$PATH"
export PATH export PATH
@ -29,10 +30,4 @@ export PATH
CUIRASS_CACHEDIR="$abs_top_builddir/cache" CUIRASS_CACHEDIR="$abs_top_builddir/cache"
export CUIRASS_CACHEDIR export CUIRASS_CACHEDIR
# Append Guix cloned repository to Guile load paths.
guixdir="$CUIRASS_CACHEDIR/guix"
GUILE_LOAD_COMPILED_PATH="$guixdir:$GUILE_LOAD_COMPILED_PATH"
GUILE_LOAD_PATH="$guixdir:$GUILE_LOAD_PATH"
export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH
exec "$@" exec "$@"

View File

@ -32,6 +32,7 @@
job-spec? job-spec?
job-spec-name job-spec-name
job-spec-url job-spec-url
job-spec-load-path
job-spec-branch job-spec-branch
job-spec-commit job-spec-commit
job-spec-tag job-spec-tag
@ -58,10 +59,11 @@
metadata))))) metadata)))))
(define-record-type <job-spec> (define-record-type <job-spec>
(%make-job-spec name url branch commit file proc arguments) (%make-job-spec name url load-path branch commit file proc arguments)
job-spec? job-spec?
(name job-spec-name) ;string (name job-spec-name) ;string
(url job-spec-url) ;string (url job-spec-url) ;string
(load-path job-spec-load-path) ;string
(branch job-spec-branch) ;string (branch job-spec-branch) ;string
(commit job-spec-commit) ;string (commit job-spec-commit) ;string
(tag job-spec-tag) ;string (tag job-spec-tag) ;string
@ -69,6 +71,7 @@
(proc job-spec-proc) ;symbol (proc job-spec-proc) ;symbol
(arguments job-spec-arguments)) ;alist (arguments job-spec-arguments)) ;alist
(define* (make-job-spec #:key name url commit tag file proc arguments (define* (make-job-spec #:key name url load-path
commit tag file proc arguments
(branch "master")) (branch "master"))
(%make-job-spec name url branch tag file proc arguments)) (%make-job-spec name url load-path branch tag file proc arguments))

View File

@ -27,6 +27,7 @@
(list (make-job-spec (list (make-job-spec
#:name "guix" #:name "guix"
#:url "git://git.savannah.gnu.org/guix.git" #:url "git://git.savannah.gnu.org/guix.git"
#:load-path "."
#:branch "master" #:branch "master"
#:file (local-file "gnu-system.scm") #:file (local-file "gnu-system.scm")
#:proc 'hydra-jobs #:proc 'hydra-jobs
@ -34,6 +35,7 @@
(make-job-spec (make-job-spec
#:name "guix" #:name "guix"
#:url "git://git.savannah.gnu.org/guix.git" #:url "git://git.savannah.gnu.org/guix.git"
#:load-path "."
#:branch "core-updates" #:branch "core-updates"
#:file (local-file "gnu-system.scm") #:file (local-file "gnu-system.scm")
#:proc 'hydra-jobs #:proc 'hydra-jobs
@ -41,6 +43,7 @@
(make-job-spec (make-job-spec
#:name "guix" #:name "guix"
#:url "git://git.savannah.gnu.org/guix.git" #:url "git://git.savannah.gnu.org/guix.git"
#:load-path "."
#:tag "v0.9.0" #:tag "v0.9.0"
#:file (local-file "gnu-system.scm") #:file (local-file "gnu-system.scm")
#:proc 'hydra-jobs #:proc 'hydra-jobs