about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/nix-instantiate/nix-instantiate.cc17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/nix-instantiate/nix-instantiate.cc b/src/nix-instantiate/nix-instantiate.cc
index 6a93acf39602..e9f1284eb182 100644
--- a/src/nix-instantiate/nix-instantiate.cc
+++ b/src/nix-instantiate/nix-instantiate.cc
@@ -97,23 +97,19 @@ void run(Strings args)
     bool strict = false;
     Strings attrPaths;
     Bindings autoArgs;
+    bool wantsReadWrite = false;
 
     for (Strings::iterator i = args.begin(); i != args.end(); ) {
         string arg = *i++;
 
         if (arg == "-")
             readStdin = true;
-        else if (arg == "--eval-only") {
-            settings.readOnlyMode = true;
+        else if (arg == "--eval-only")
             evalOnly = true;
-        }
-        else if (arg == "--read-write-mode") {
-            settings.readOnlyMode = false;
-        }
-        else if (arg == "--parse-only") {
-            settings.readOnlyMode = true;
+        else if (arg == "--read-write-mode")
+            wantsReadWrite = true;
+        else if (arg == "--parse-only")
             parseOnly = evalOnly = true;
-        }
         else if (arg == "--find-file")
             findFile = true;
         else if (arg == "--attr" || arg == "-A") {
@@ -146,6 +142,9 @@ void run(Strings args)
             files.push_back(arg);
     }
 
+    if (evalOnly && !wantsReadWrite)
+        settings.readOnlyMode = true;
+
     if (attrPaths.empty()) attrPaths.push_back("");
 
     if (findFile) {