aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libstore/globals.cc9
-rw-r--r--src/libstore/globals.hh4
2 files changed, 12 insertions, 1 deletions
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
index cec85edca..5f1ae5ab5 100644
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -117,6 +117,15 @@ void Settings::requireExperimentalFeature(const std::string & name)
throw Error("experimental Nix feature '%s' is disabled", name);
}
+bool Settings::isWSL1()
+{
+ struct utsname utsbuf;
+ uname(&utsbuf);
+ // WSL1 uses -Microsoft suffix
+ // WSL2 uses -microsoft-standard suffix
+ return hasSuffix(utsbuf.release, "-Microsoft");
+}
+
const string nixVersion = PACKAGE_VERSION;
template<> void BaseSetting<SandboxMode>::set(const std::string & str)
diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh
index 41e511c6c..782870547 100644
--- a/src/libstore/globals.hh
+++ b/src/libstore/globals.hh
@@ -34,6 +34,8 @@ class Settings : public Config {
StringSet getDefaultSystemFeatures();
+ bool isWSL1();
+
public:
Settings();
@@ -130,7 +132,7 @@ public:
Setting<bool> fsyncMetadata{this, true, "fsync-metadata",
"Whether SQLite should use fsync()."};
- Setting<bool> useSQLiteWAL{this, true, "use-sqlite-wal",
+ Setting<bool> useSQLiteWAL{this, !isWSL1(), "use-sqlite-wal",
"Whether SQLite should use WAL mode."};
Setting<bool> syncBeforeRegistering{this, false, "sync-before-registering",