about summary refs log tree commit diff
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2016-11-17T13·06-0500
committerShea Levy <shea@shealevy.com>2016-11-17T13·06-0500
commit8bf378e9998cfbeb4303fade33fe514a4c18bf81 (patch)
tree0f1caaf0cff3920809176814cd9bbdd36776a9a7
parent4be4f6de56f4de77f6a376f1a40ed75eb641bb89 (diff)
Update darwin build for optional sandbox paths
Fixes #1132
-rw-r--r--src/libstore/build.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index d488cda37ca2..ba51f85917f3 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -2554,15 +2554,18 @@ void DerivationGoal::runChild()
              */
             sandboxProfile += "(allow file-read* file-write* process-exec\n";
             for (auto & i : dirsInChroot) {
-                if (i.first != i.second)
+                if (i.first != i.second.source)
                     throw Error(format(
                         "can't map '%1%' to '%2%': mismatched impure paths not supported on Darwin")
-                        % i.first % i.second);
+                        % i.first % i.second.source);
 
                 string path = i.first;
                 struct stat st;
-                if (lstat(path.c_str(), &st))
+                if (lstat(path.c_str(), &st)) {
+                    if (i.second.optional && errno == ENOENT)
+                        continue;
                     throw SysError(format("getting attributes of path ‘%1%’") % path);
+                }
                 if (S_ISDIR(st.st_mode))
                     sandboxProfile += (format("\t(subpath \"%1%\")\n") % path).str();
                 else