diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-11-12 00:10:10 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-11-12 01:06:45 +0100 |
commit | eddd4077a5292052d95443078ee4db9f34f2f0e2 (patch) | |
tree | d157119a2613b08fa3947e9c756c99f1086a557b /guix | |
parent | 08184ebf16fad0e84c3dc22b059cd0e211684954 (diff) |
store: Add 'log-file' procedure.
* guix/store.scm (log-file): New procedure.
* tests/store.scm ("log-file, derivation", "log-file, output file
name"): New tests.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/store.scm | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/guix/store.scm b/guix/store.scm index 0f1e2f9466..290118d74b 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -87,7 +87,8 @@ store-path? derivation-path? store-path-package-name - store-path-hash-part)) + store-path-hash-part + log-file)) (define %protocol-version #x10c) @@ -660,3 +661,23 @@ syntactically valid store path." "/([0-9a-df-np-sv-z]{32})-[^/]+$")))) (and=> (regexp-exec path-rx path) (cut match:substring <> 1)))) + +(define (log-file store file) + "Return the build log file for FILE, or #f if none could be found. FILE +must be an absolute store file name, or a derivation file name." + (define state-dir ; XXX: factorize + (or (getenv "NIX_STATE_DIR") %state-directory)) + + (cond ((derivation-path? file) + (let* ((base (basename file)) + (log (string-append (dirname state-dir) ; XXX: ditto + "/log/nix/drvs/" + (string-take base 2) "/" + (string-drop base 2) ".bz2"))) + (and (file-exists? log) log))) + (else + (match (valid-derivers store file) + ((derivers ...) + ;; Return the first that works. + (any (cut log-file store <>) derivers)) + (_ #f))))) |