aboutsummaryrefslogtreecommitdiff
path: root/guix/store.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-11-12 23:36:29 +0100
committerLudovic Courtès <ludo@gnu.org>2013-11-13 00:29:05 +0100
commit9336e5b5e7b05e636b147aba2c97357620711c2a (patch)
treee54a9d862b8b5693c464175f47358e069c73d81d /guix/store.scm
parente387ab7c10b18427b97cd22526f1b135856a083e (diff)
downloadgnu-guix-9336e5b5e7b05e636b147aba2c97357620711c2a.tar
gnu-guix-9336e5b5e7b05e636b147aba2c97357620711c2a.tar.gz
store: Make 'direct-store-path?' public.
* guix/store.scm (direct-store-path?): New procedure. * guix/derivations.scm (derivation)[direct-store-path?]: Remove. * tests/store.scm ("direct-store-path?"): New test.
Diffstat (limited to 'guix/store.scm')
-rw-r--r--guix/store.scm9
1 files changed, 9 insertions, 0 deletions
diff --git a/guix/store.scm b/guix/store.scm
index 290118d74b..2821cacdcc 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -85,6 +85,7 @@
%store-prefix
store-path?
+ direct-store-path?
derivation-path?
store-path-package-name
store-path-hash-part
@@ -640,6 +641,14 @@ collected, and the number of bytes freed."
;; `isStorePath' in Nix does something similar.
(string-prefix? (%store-prefix) path))
+(define (direct-store-path? path)
+ "Return #t if PATH is a store path, and not a sub-directory of a store path.
+This predicate is sometimes needed because files *under* a store path are not
+valid inputs."
+ (and (store-path? path)
+ (let ((len (+ 1 (string-length (%store-prefix)))))
+ (not (string-index (substring path len) #\/)))))
+
(define (derivation-path? path)
"Return #t if PATH is a derivation path."
(and (store-path? path) (string-suffix? ".drv" path)))