diff options
Diffstat (limited to 'src/libstore/storeexpr.cc')
-rw-r--r-- | src/libstore/storeexpr.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/libstore/storeexpr.cc b/src/libstore/storeexpr.cc index d7c87bfa151c..a9240130e755 100644 --- a/src/libstore/storeexpr.cc +++ b/src/libstore/storeexpr.cc @@ -12,11 +12,10 @@ Hash hashTerm(ATerm t) } -Path writeTerm(ATerm t, const string & suffix) +Path writeDerivation(const Derivation & drv, const string & name) { - char * s = ATwriteToString(t); - if (!s) throw Error("cannot print aterm"); - return addTextToStore(suffix + ".store", string(s)); + return addTextToStore(name + drvExtension, + atPrint(unparseDerivation(drv))); } @@ -133,3 +132,11 @@ ATerm unparseDerivation(const Derivation & drv) ATreverse(args), ATreverse(env)); } + + +bool isDerivation(const string & fileName) +{ + return + fileName.size() >= drvExtension.size() && + string(fileName, fileName.size() - drvExtension.size()) == drvExtension; +} |