aboutsummaryrefslogtreecommitdiff
path: root/guix/store.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-06-01 23:29:55 +0200
committerLudovic Courtès <ludo@gnu.org>2012-06-03 23:32:06 +0200
commit26bbbb95200b4fcd16bf92ee2593fccd9fe8f32d (patch)
treeec10a193c2dfc05aef55d855f9c3fbef2d42c968 /guix/store.scm
parent38b3122afb5093f3094eceb4648f6ff65bd684b2 (diff)
downloadgnu-guix-26bbbb95200b4fcd16bf92ee2593fccd9fe8f32d.tar
gnu-guix-26bbbb95200b4fcd16bf92ee2593fccd9fe8f32d.tar.gz
First stab at the `derivation' primitive.
* guix/store.scm (%store-prefix): New parameter. (store-path?, derivation-path?): New procedures. * guix/derivations.scm (write-derivation): Pass SOURCES through `object->string'. (compressed-hash, store-path, output-path, derivation): New procedures. * tests/derivations.scm (%store): New global variable. ("derivation with no inputs"): New test.
Diffstat (limited to 'guix/store.scm')
-rw-r--r--guix/store.scm30
1 files changed, 29 insertions, 1 deletions
diff --git a/guix/store.scm b/guix/store.scm
index 539aa61455..1ea4d16894 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -24,6 +24,7 @@
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
#:use-module (srfi srfi-35)
+ #:use-module (srfi srfi-39)
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
#:export (nix-server?
@@ -36,11 +37,17 @@
nix-protocol-error-message
nix-protocol-error-status
+ hash-algo
+
open-connection
set-build-options
add-text-to-store
add-to-store
- build-derivations))
+ build-derivations
+
+ %store-prefix
+ store-path?
+ derivation-path?))
(define %protocol-version #x109)
@@ -352,3 +359,24 @@
(define-operation (build-derivations (string-list derivations))
"Build DERIVATIONS; return #t on success."
boolean)
+
+
+;;;
+;;; Store paths.
+;;;
+
+(define %store-prefix
+ ;; Absolute path to the Nix store.
+ (make-parameter "/nix/store"))
+
+(define store-path?
+ (let ((store-path-rx
+ (delay (make-regexp
+ (string-append "^.*" (%store-prefix) "/[^-]{32}-(.+)$")))))
+ (lambda (path)
+ "Return #t if PATH is a store path."
+ (not (not (regexp-exec (force store-path-rx) path))))))
+
+(define (derivation-path? path)
+ "Return #t if PATH is a derivation path."
+ (and (store-path? path) (string-suffix? ".drv" path)))