about summary refs log tree commit diff
path: root/third_party
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-27T20·56+0100
committerVincent Ambo <tazjin@google.com>2020-05-27T20·56+0100
commit3652326ed281f5f753423acef51103fb8df62a6d (patch)
tree3e6969ccaa13e77eb42f887cd081b45d7fffed80 /third_party
parent86a35d963d7b6108dec44411c8ebd5aadbb148ac (diff)
refactor(3p/nix): Anchor local includes at src/ r/865
Previously all includes were anchored in one global mess of header
files. This moves the includes into filesystem "namespaces" (if you
will) for each sub-package of Nix.

Note: This commit does not introduce the relevant build system changes.
Diffstat (limited to 'third_party')
-rw-r--r--third_party/nix/src/build-remote/build-remote.cc18
-rw-r--r--third_party/nix/src/libexpr/attr-path.cc6
-rw-r--r--third_party/nix/src/libexpr/attr-path.hh2
-rw-r--r--third_party/nix/src/libexpr/attr-set.cc4
-rw-r--r--third_party/nix/src/libexpr/attr-set.hh6
-rw-r--r--third_party/nix/src/libexpr/common-eval-args.cc10
-rw-r--r--third_party/nix/src/libexpr/common-eval-args.hh2
-rw-r--r--third_party/nix/src/libexpr/eval-inline.hh2
-rw-r--r--third_party/nix/src/libexpr/eval.cc20
-rw-r--r--third_party/nix/src/libexpr/eval.hh12
-rw-r--r--third_party/nix/src/libexpr/function-trace.cc2
-rw-r--r--third_party/nix/src/libexpr/function-trace.hh2
-rw-r--r--third_party/nix/src/libexpr/get-drvs.cc8
-rw-r--r--third_party/nix/src/libexpr/get-drvs.hh2
-rw-r--r--third_party/nix/src/libexpr/json-to-value.cc2
-rw-r--r--third_party/nix/src/libexpr/json-to-value.hh2
-rw-r--r--third_party/nix/src/libexpr/lexer.l4
-rw-r--r--third_party/nix/src/libexpr/names.cc4
-rw-r--r--third_party/nix/src/libexpr/names.hh2
-rw-r--r--third_party/nix/src/libexpr/nixexpr.cc6
-rw-r--r--third_party/nix/src/libexpr/nixexpr.hh6
-rw-r--r--third_party/nix/src/libexpr/parser.y16
-rw-r--r--third_party/nix/src/libexpr/primops.cc28
-rw-r--r--third_party/nix/src/libexpr/primops.hh2
-rw-r--r--third_party/nix/src/libexpr/primops/context.cc6
-rw-r--r--third_party/nix/src/libexpr/primops/fetchGit.cc12
-rw-r--r--third_party/nix/src/libexpr/primops/fetchMercurial.cc10
-rw-r--r--third_party/nix/src/libexpr/primops/fromTOML.cc4
-rw-r--r--third_party/nix/src/libexpr/symbol-table.cc2
-rw-r--r--third_party/nix/src/libexpr/value-to-json.cc8
-rw-r--r--third_party/nix/src/libexpr/value-to-json.hh4
-rw-r--r--third_party/nix/src/libexpr/value-to-xml.cc8
-rw-r--r--third_party/nix/src/libexpr/value-to-xml.hh4
-rw-r--r--third_party/nix/src/libexpr/value.hh8
-rw-r--r--third_party/nix/src/libmain/common-args.cc4
-rw-r--r--third_party/nix/src/libmain/common-args.hh2
-rw-r--r--third_party/nix/src/libmain/shared.cc8
-rw-r--r--third_party/nix/src/libmain/shared.hh6
-rw-r--r--third_party/nix/src/libmain/stack.cc2
-rw-r--r--third_party/nix/src/libstore/binary-cache-store.cc28
-rw-r--r--third_party/nix/src/libstore/binary-cache-store.hh6
-rw-r--r--third_party/nix/src/libstore/build.cc32
-rw-r--r--third_party/nix/src/libstore/builtins.hh2
-rw-r--r--third_party/nix/src/libstore/builtins/buildenv.cc2
-rw-r--r--third_party/nix/src/libstore/builtins/fetchurl.cc10
-rw-r--r--third_party/nix/src/libstore/crypto.cc6
-rw-r--r--third_party/nix/src/libstore/crypto.hh2
-rw-r--r--third_party/nix/src/libstore/derivations.cc14
-rw-r--r--third_party/nix/src/libstore/derivations.hh6
-rw-r--r--third_party/nix/src/libstore/download.cc20
-rw-r--r--third_party/nix/src/libstore/download.hh6
-rw-r--r--third_party/nix/src/libstore/export-import.cc6
-rw-r--r--third_party/nix/src/libstore/fs-accessor.hh2
-rw-r--r--third_party/nix/src/libstore/gc.cc10
-rw-r--r--third_party/nix/src/libstore/globals.cc9
-rw-r--r--third_party/nix/src/libstore/globals.hh7
-rw-r--r--third_party/nix/src/libstore/http-binary-cache-store.cc8
-rw-r--r--third_party/nix/src/libstore/legacy-ssh-store.cc19
-rw-r--r--third_party/nix/src/libstore/local-binary-cache-store.cc6
-rw-r--r--third_party/nix/src/libstore/local-fs-store.cc12
-rw-r--r--third_party/nix/src/libstore/local-store.cc15
-rw-r--r--third_party/nix/src/libstore/local-store.hh10
-rw-r--r--third_party/nix/src/libstore/machines.cc6
-rw-r--r--third_party/nix/src/libstore/machines.hh2
-rw-r--r--third_party/nix/src/libstore/misc.cc12
-rw-r--r--third_party/nix/src/libstore/nar-accessor.cc6
-rw-r--r--third_party/nix/src/libstore/nar-accessor.hh2
-rw-r--r--third_party/nix/src/libstore/nar-info-disk-cache.cc8
-rw-r--r--third_party/nix/src/libstore/nar-info-disk-cache.hh4
-rw-r--r--third_party/nix/src/libstore/nar-info.cc4
-rw-r--r--third_party/nix/src/libstore/nar-info.hh6
-rw-r--r--third_party/nix/src/libstore/optimise-store.cc8
-rw-r--r--third_party/nix/src/libstore/parsed-derivations.cc2
-rw-r--r--third_party/nix/src/libstore/parsed-derivations.hh2
-rw-r--r--third_party/nix/src/libstore/pathlocks.cc6
-rw-r--r--third_party/nix/src/libstore/pathlocks.hh2
-rw-r--r--third_party/nix/src/libstore/profiles.cc6
-rw-r--r--third_party/nix/src/libstore/profiles.hh4
-rw-r--r--third_party/nix/src/libstore/references.cc8
-rw-r--r--third_party/nix/src/libstore/references.hh4
-rw-r--r--third_party/nix/src/libstore/remote-fs-accessor.cc6
-rw-r--r--third_party/nix/src/libstore/remote-fs-accessor.hh6
-rw-r--r--third_party/nix/src/libstore/remote-store.cc22
-rw-r--r--third_party/nix/src/libstore/remote-store.hh2
-rw-r--r--third_party/nix/src/libstore/s3-binary-cache-store.cc16
-rw-r--r--third_party/nix/src/libstore/s3-binary-cache-store.hh2
-rw-r--r--third_party/nix/src/libstore/s3.hh2
-rw-r--r--third_party/nix/src/libstore/sqlite.cc4
-rw-r--r--third_party/nix/src/libstore/sqlite.hh2
-rw-r--r--third_party/nix/src/libstore/ssh-store.cc14
-rw-r--r--third_party/nix/src/libstore/ssh.cc2
-rw-r--r--third_party/nix/src/libstore/ssh.hh4
-rw-r--r--third_party/nix/src/libstore/store-api.cc20
-rw-r--r--third_party/nix/src/libstore/store-api.hh14
-rw-r--r--third_party/nix/src/libutil/affinity.cc6
-rw-r--r--third_party/nix/src/libutil/archive.cc8
-rw-r--r--third_party/nix/src/libutil/archive.hh4
-rw-r--r--third_party/nix/src/libutil/args.cc4
-rw-r--r--third_party/nix/src/libutil/args.hh2
-rw-r--r--third_party/nix/src/libutil/compression.cc8
-rw-r--r--third_party/nix/src/libutil/compression.hh6
-rw-r--r--third_party/nix/src/libutil/config.cc6
-rw-r--r--third_party/nix/src/libutil/config.hh2
-rw-r--r--third_party/nix/src/libutil/hash.cc8
-rw-r--r--third_party/nix/src/libutil/hash.hh4
-rw-r--r--third_party/nix/src/libutil/json.cc2
-rw-r--r--third_party/nix/src/libutil/pool.hh4
-rw-r--r--third_party/nix/src/libutil/serialise.cc7
-rw-r--r--third_party/nix/src/libutil/serialise.hh4
-rw-r--r--third_party/nix/src/libutil/thread-pool.cc7
-rw-r--r--third_party/nix/src/libutil/thread-pool.hh4
-rw-r--r--third_party/nix/src/libutil/types.hh2
-rw-r--r--third_party/nix/src/libutil/util.cc15
-rw-r--r--third_party/nix/src/libutil/util.hh2
-rw-r--r--third_party/nix/src/libutil/xml-writer.cc2
-rw-r--r--third_party/nix/src/nix-build/nix-build.cc24
-rw-r--r--third_party/nix/src/nix-channel/nix-channel.cc10
-rw-r--r--third_party/nix/src/nix-collect-garbage/nix-collect-garbage.cc10
-rw-r--r--third_party/nix/src/nix-copy-closure/nix-copy-closure.cc6
-rw-r--r--third_party/nix/src/nix-daemon/nix-daemon.cc24
-rw-r--r--third_party/nix/src/nix-env/nix-env.cc32
-rw-r--r--third_party/nix/src/nix-env/user-env.cc18
-rw-r--r--third_party/nix/src/nix-env/user-env.hh2
-rw-r--r--third_party/nix/src/nix-instantiate/nix-instantiate.cc24
-rw-r--r--third_party/nix/src/nix-prefetch-url/nix-prefetch-url.cc20
-rw-r--r--third_party/nix/src/nix-store/dotgraph.cc6
-rw-r--r--third_party/nix/src/nix-store/dotgraph.hh2
-rw-r--r--third_party/nix/src/nix-store/graphml.cc8
-rw-r--r--third_party/nix/src/nix-store/graphml.hh2
-rw-r--r--third_party/nix/src/nix-store/nix-store.cc24
-rw-r--r--third_party/nix/src/nix/add-to-store.cc8
-rw-r--r--third_party/nix/src/nix/build.cc8
-rw-r--r--third_party/nix/src/nix/cat.cc8
-rw-r--r--third_party/nix/src/nix/command.cc6
-rw-r--r--third_party/nix/src/nix/command.hh4
-rw-r--r--third_party/nix/src/nix/copy.cc10
-rw-r--r--third_party/nix/src/nix/doctor.cc10
-rw-r--r--third_party/nix/src/nix/dump-path.cc4
-rw-r--r--third_party/nix/src/nix/edit.cc8
-rw-r--r--third_party/nix/src/nix/eval.cc16
-rw-r--r--third_party/nix/src/nix/hash.cc8
-rw-r--r--third_party/nix/src/nix/installables.cc18
-rw-r--r--third_party/nix/src/nix/legacy.cc2
-rw-r--r--third_party/nix/src/nix/log.cc8
-rw-r--r--third_party/nix/src/nix/ls.cc12
-rw-r--r--third_party/nix/src/nix/main.cc20
-rw-r--r--third_party/nix/src/nix/optimise-store.cc6
-rw-r--r--third_party/nix/src/nix/path-info.cc10
-rw-r--r--third_party/nix/src/nix/ping-store.cc6
-rw-r--r--third_party/nix/src/nix/repl.cc22
-rw-r--r--third_party/nix/src/nix/run.cc18
-rw-r--r--third_party/nix/src/nix/search.cc20
-rw-r--r--third_party/nix/src/nix/show-config.cc10
-rw-r--r--third_party/nix/src/nix/show-derivation.cc12
-rw-r--r--third_party/nix/src/nix/sigs.cc8
-rw-r--r--third_party/nix/src/nix/upgrade-nix.cc14
-rw-r--r--third_party/nix/src/nix/verify.cc10
-rw-r--r--third_party/nix/src/nix/why-depends.cc8
-rw-r--r--third_party/nix/tests/plugins/plugintest.cc2
159 files changed, 661 insertions, 656 deletions
diff --git a/third_party/nix/src/build-remote/build-remote.cc b/third_party/nix/src/build-remote/build-remote.cc
index 6bca30a5a136..2c7e6dbab8cf 100644
--- a/third_party/nix/src/build-remote/build-remote.cc
+++ b/third_party/nix/src/build-remote/build-remote.cc
@@ -11,15 +11,15 @@
 #include <absl/strings/str_cat.h>
 #include <glog/logging.h>
 
-#include "derivations.hh"
-#include "globals.hh"
-#include "legacy.hh"
-#include "local-store.hh"
-#include "machines.hh"
-#include "pathlocks.hh"
-#include "serialise.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libmain/shared.hh"
+#include "libstore/derivations.hh"
+#include "libstore/globals.hh"
+#include "libstore/local-store.hh"
+#include "libstore/machines.hh"
+#include "libstore/pathlocks.hh"
+#include "libstore/store-api.hh"
+#include "libutil/serialise.hh"
+#include "nix/legacy.hh"
 
 using namespace nix;
 using std::cin;
diff --git a/third_party/nix/src/libexpr/attr-path.cc b/third_party/nix/src/libexpr/attr-path.cc
index 5f14fca21493..e366f18575e7 100644
--- a/third_party/nix/src/libexpr/attr-path.cc
+++ b/third_party/nix/src/libexpr/attr-path.cc
@@ -1,9 +1,9 @@
-#include "attr-path.hh"
+#include "libexpr/attr-path.hh"
 
 #include <absl/strings/numbers.h>
 
-#include "eval-inline.hh"
-#include "util.hh"
+#include "libexpr/eval-inline.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/attr-path.hh b/third_party/nix/src/libexpr/attr-path.hh
index 889c2158d79e..a71ceb9a06cd 100644
--- a/third_party/nix/src/libexpr/attr-path.hh
+++ b/third_party/nix/src/libexpr/attr-path.hh
@@ -3,7 +3,7 @@
 #include <map>
 #include <string>
 
-#include "eval.hh"
+#include "libexpr/eval.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/attr-set.cc b/third_party/nix/src/libexpr/attr-set.cc
index 6310cc66b726..c5355a69c5cb 100644
--- a/third_party/nix/src/libexpr/attr-set.cc
+++ b/third_party/nix/src/libexpr/attr-set.cc
@@ -1,4 +1,4 @@
-#include "attr-set.hh"
+#include "libexpr/attr-set.hh"
 
 #include <new>
 
@@ -6,7 +6,7 @@
 #include <gc/gc_cpp.h>
 #include <glog/logging.h>
 
-#include "eval-inline.hh"
+#include "libexpr/eval-inline.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/attr-set.hh b/third_party/nix/src/libexpr/attr-set.hh
index 37e6d5e1ca8f..ff13e9a7fa07 100644
--- a/third_party/nix/src/libexpr/attr-set.hh
+++ b/third_party/nix/src/libexpr/attr-set.hh
@@ -4,9 +4,9 @@
 #include <absl/container/btree_map.h>
 #include <gc/gc_allocator.h>
 
-#include "nixexpr.hh"
-#include "symbol-table.hh"
-#include "types.hh"
+#include "libexpr/nixexpr.hh"
+#include "libexpr/symbol-table.hh"
+#include "libutil/types.hh"
 
 namespace nix {  // TODO(tazjin): ::expr
 
diff --git a/third_party/nix/src/libexpr/common-eval-args.cc b/third_party/nix/src/libexpr/common-eval-args.cc
index 19271f2cc582..fe8a6a02af08 100644
--- a/third_party/nix/src/libexpr/common-eval-args.cc
+++ b/third_party/nix/src/libexpr/common-eval-args.cc
@@ -1,9 +1,9 @@
-#include "common-eval-args.hh"
+#include "libexpr/common-eval-args.hh"
 
-#include "download.hh"
-#include "eval.hh"
-#include "shared.hh"
-#include "util.hh"
+#include "libexpr/eval.hh"
+#include "libmain/shared.hh"
+#include "libstore/download.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/common-eval-args.hh b/third_party/nix/src/libexpr/common-eval-args.hh
index dad30daf6b13..be7126c039df 100644
--- a/third_party/nix/src/libexpr/common-eval-args.hh
+++ b/third_party/nix/src/libexpr/common-eval-args.hh
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "args.hh"
+#include "libutil/args.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/eval-inline.hh b/third_party/nix/src/libexpr/eval-inline.hh
index ca0cf2a3607a..5162ab3971a3 100644
--- a/third_party/nix/src/libexpr/eval-inline.hh
+++ b/third_party/nix/src/libexpr/eval-inline.hh
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "eval.hh"
+#include "libexpr/eval.hh"
 
 #define LocalNoInline(f)              \
   static f __attribute__((noinline)); \
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc
index ca2b65203f19..91dff6b40dc9 100644
--- a/third_party/nix/src/libexpr/eval.cc
+++ b/third_party/nix/src/libexpr/eval.cc
@@ -1,4 +1,4 @@
-#include "eval.hh"
+#include "libexpr/eval.hh"
 
 #include <algorithm>
 #include <chrono>
@@ -15,15 +15,15 @@
 #include <sys/time.h>
 #include <unistd.h>
 
-#include "derivations.hh"
-#include "download.hh"
-#include "eval-inline.hh"
-#include "function-trace.hh"
-#include "globals.hh"
-#include "hash.hh"
-#include "json.hh"
-#include "store-api.hh"
-#include "util.hh"
+#include "libexpr/eval-inline.hh"
+#include "libexpr/function-trace.hh"
+#include "libstore/derivations.hh"
+#include "libstore/download.hh"
+#include "libstore/globals.hh"
+#include "libstore/store-api.hh"
+#include "libutil/hash.hh"
+#include "libutil/json.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/eval.hh b/third_party/nix/src/libexpr/eval.hh
index f13e8553d14b..9e4e500b4745 100644
--- a/third_party/nix/src/libexpr/eval.hh
+++ b/third_party/nix/src/libexpr/eval.hh
@@ -4,12 +4,12 @@
 #include <optional>
 #include <unordered_map>
 
-#include "attr-set.hh"
-#include "config.hh"
-#include "hash.hh"
-#include "nixexpr.hh"
-#include "symbol-table.hh"
-#include "value.hh"
+#include "libexpr/attr-set.hh"
+#include "libexpr/nixexpr.hh"
+#include "libexpr/symbol-table.hh"
+#include "libexpr/value.hh"
+#include "libutil/config.hh"
+#include "libutil/hash.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/function-trace.cc b/third_party/nix/src/libexpr/function-trace.cc
index 8b0d60fab8be..b1b856965c2a 100644
--- a/third_party/nix/src/libexpr/function-trace.cc
+++ b/third_party/nix/src/libexpr/function-trace.cc
@@ -1,4 +1,4 @@
-#include "function-trace.hh"
+#include "libexpr/function-trace.hh"
 
 #include <glog/logging.h>
 
diff --git a/third_party/nix/src/libexpr/function-trace.hh b/third_party/nix/src/libexpr/function-trace.hh
index 93d70862eda1..6b810159b8fc 100644
--- a/third_party/nix/src/libexpr/function-trace.hh
+++ b/third_party/nix/src/libexpr/function-trace.hh
@@ -2,7 +2,7 @@
 
 #include <chrono>
 
-#include "eval.hh"
+#include "libexpr/eval.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/get-drvs.cc b/third_party/nix/src/libexpr/get-drvs.cc
index 968108e78c51..875c8ca2a0eb 100644
--- a/third_party/nix/src/libexpr/get-drvs.cc
+++ b/third_party/nix/src/libexpr/get-drvs.cc
@@ -1,4 +1,4 @@
-#include "get-drvs.hh"
+#include "libexpr/get-drvs.hh"
 
 #include <cstring>
 #include <regex>
@@ -7,9 +7,9 @@
 #include <absl/strings/numbers.h>
 #include <glog/logging.h>
 
-#include "derivations.hh"
-#include "eval-inline.hh"
-#include "util.hh"
+#include "libexpr/eval-inline.hh"
+#include "libstore/derivations.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/get-drvs.hh b/third_party/nix/src/libexpr/get-drvs.hh
index a0840ee9b280..bb20c32c0b44 100644
--- a/third_party/nix/src/libexpr/get-drvs.hh
+++ b/third_party/nix/src/libexpr/get-drvs.hh
@@ -3,7 +3,7 @@
 #include <map>
 #include <string>
 
-#include "eval.hh"
+#include "libexpr/eval.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/json-to-value.cc b/third_party/nix/src/libexpr/json-to-value.cc
index d46e6f268e9f..4411b411f229 100644
--- a/third_party/nix/src/libexpr/json-to-value.cc
+++ b/third_party/nix/src/libexpr/json-to-value.cc
@@ -1,4 +1,4 @@
-#include "json-to-value.hh"
+#include "libexpr/json-to-value.hh"
 
 #include <cstring>
 
diff --git a/third_party/nix/src/libexpr/json-to-value.hh b/third_party/nix/src/libexpr/json-to-value.hh
index f416dfbb3860..041a4c596591 100644
--- a/third_party/nix/src/libexpr/json-to-value.hh
+++ b/third_party/nix/src/libexpr/json-to-value.hh
@@ -2,7 +2,7 @@
 
 #include <string>
 
-#include "eval.hh"
+#include "libexpr/eval.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/lexer.l b/third_party/nix/src/libexpr/lexer.l
index 9cdb2bd97ecf..be5fe4a78f7d 100644
--- a/third_party/nix/src/libexpr/lexer.l
+++ b/third_party/nix/src/libexpr/lexer.l
@@ -14,8 +14,8 @@
 %{
 #include <boost/lexical_cast.hpp>
 
-#include "nixexpr.hh"
-#include "parser-tab.hh"
+#include "libexpr/nixexpr.hh"
+#include "generated/parser-tab.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/libexpr/names.cc b/third_party/nix/src/libexpr/names.cc
index 769f9e99db29..1e9c2f2f4aac 100644
--- a/third_party/nix/src/libexpr/names.cc
+++ b/third_party/nix/src/libexpr/names.cc
@@ -1,10 +1,10 @@
-#include "names.hh"
+#include "libexpr/names.hh"
 
 #include <memory>
 
 #include <absl/strings/numbers.h>
 
-#include "util.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/names.hh b/third_party/nix/src/libexpr/names.hh
index 521740152ca2..061388d517cd 100644
--- a/third_party/nix/src/libexpr/names.hh
+++ b/third_party/nix/src/libexpr/names.hh
@@ -3,7 +3,7 @@
 #include <memory>
 #include <regex>
 
-#include "types.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/nixexpr.cc b/third_party/nix/src/libexpr/nixexpr.cc
index ef4a75ed8d5b..28d8eee7a7f8 100644
--- a/third_party/nix/src/libexpr/nixexpr.cc
+++ b/third_party/nix/src/libexpr/nixexpr.cc
@@ -1,9 +1,9 @@
-#include "nixexpr.hh"
+#include "libexpr/nixexpr.hh"
 
 #include <cstdlib>
 
-#include "derivations.hh"
-#include "util.hh"
+#include "libstore/derivations.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/nixexpr.hh b/third_party/nix/src/libexpr/nixexpr.hh
index 8817fbc9ddb8..0bf5245181ec 100644
--- a/third_party/nix/src/libexpr/nixexpr.hh
+++ b/third_party/nix/src/libexpr/nixexpr.hh
@@ -2,9 +2,9 @@
 
 #include <map>
 
-#include "symbol-table.hh"
-#include "types.hh"  // TODO(tazjin): audit this include
-#include "value.hh"
+#include "libexpr/symbol-table.hh"
+#include "libexpr/value.hh"
+#include "libutil/types.hh"  // TODO(tazjin): audit this include
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/parser.y b/third_party/nix/src/libexpr/parser.y
index 9ba053ee7b12..fe8759f3c6b7 100644
--- a/third_party/nix/src/libexpr/parser.y
+++ b/third_party/nix/src/libexpr/parser.y
@@ -16,9 +16,9 @@
 #ifndef BISON_HEADER
 #define BISON_HEADER
 
-#include "util.hh"
-#include "nixexpr.hh"
-#include "eval.hh"
+#include "libutil/util.hh"
+#include "libexpr/nixexpr.hh"
+#include "libexpr/eval.hh"
 #include <glog/logging.h>
 
 namespace nix {
@@ -50,8 +50,8 @@ namespace nix {
 
 %{
 
-#include "parser-tab.hh"
-#include "lexer-tab.hh"
+#include "generated/parser-tab.hh"
+#include "generated/lexer-tab.hh"
 
 YY_DECL;
 
@@ -539,9 +539,9 @@ formal
 #include <fcntl.h>
 #include <unistd.h>
 
-#include "eval.hh"
-#include "download.hh"
-#include "store-api.hh"
+#include "libexpr/eval.hh"
+#include "libstore/download.hh"
+#include "libstore/store-api.hh"
 
 
 namespace nix {
diff --git a/third_party/nix/src/libexpr/primops.cc b/third_party/nix/src/libexpr/primops.cc
index 8ade52bd9122..67a8a03ab02d 100644
--- a/third_party/nix/src/libexpr/primops.cc
+++ b/third_party/nix/src/libexpr/primops.cc
@@ -1,4 +1,4 @@
-#include "primops.hh"
+#include "libexpr/primops.hh"
 
 #include <algorithm>
 #include <cstring>
@@ -11,19 +11,19 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include "archive.hh"
-#include "derivations.hh"
-#include "download.hh"
-#include "eval-inline.hh"
-#include "eval.hh"
-#include "globals.hh"
-#include "json-to-value.hh"
-#include "json.hh"
-#include "names.hh"
-#include "store-api.hh"
-#include "util.hh"
-#include "value-to-json.hh"
-#include "value-to-xml.hh"
+#include "libexpr/eval-inline.hh"
+#include "libexpr/eval.hh"
+#include "libexpr/json-to-value.hh"
+#include "libexpr/names.hh"
+#include "libexpr/value-to-json.hh"
+#include "libexpr/value-to-xml.hh"
+#include "libstore/derivations.hh"
+#include "libstore/download.hh"
+#include "libstore/globals.hh"
+#include "libstore/store-api.hh"
+#include "libutil/archive.hh"
+#include "libutil/json.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/primops.hh b/third_party/nix/src/libexpr/primops.hh
index 6abd0508a09b..ad646e4d0b3c 100644
--- a/third_party/nix/src/libexpr/primops.hh
+++ b/third_party/nix/src/libexpr/primops.hh
@@ -1,7 +1,7 @@
 #include <tuple>
 #include <vector>
 
-#include "eval.hh"
+#include "libexpr/eval.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/primops/context.cc b/third_party/nix/src/libexpr/primops/context.cc
index 481a2910bf84..3a39e03eabc7 100644
--- a/third_party/nix/src/libexpr/primops/context.cc
+++ b/third_party/nix/src/libexpr/primops/context.cc
@@ -1,6 +1,6 @@
-#include "derivations.hh"
-#include "eval-inline.hh"
-#include "primops.hh"
+#include "libexpr/eval-inline.hh"
+#include "libexpr/primops.hh"
+#include "libstore/derivations.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/primops/fetchGit.cc b/third_party/nix/src/libexpr/primops/fetchGit.cc
index 2cfdefe7abfd..7262a291559f 100644
--- a/third_party/nix/src/libexpr/primops/fetchGit.cc
+++ b/third_party/nix/src/libexpr/primops/fetchGit.cc
@@ -7,12 +7,12 @@
 #include <glog/logging.h>
 #include <sys/time.h>
 
-#include "download.hh"
-#include "eval-inline.hh"
-#include "hash.hh"
-#include "pathlocks.hh"
-#include "primops.hh"
-#include "store-api.hh"
+#include "libexpr/eval-inline.hh"
+#include "libexpr/primops.hh"
+#include "libstore/download.hh"
+#include "libstore/pathlocks.hh"
+#include "libstore/store-api.hh"
+#include "libutil/hash.hh"
 
 using namespace std::string_literals;
 
diff --git a/third_party/nix/src/libexpr/primops/fetchMercurial.cc b/third_party/nix/src/libexpr/primops/fetchMercurial.cc
index 71722faedf11..3ece094e6a8d 100644
--- a/third_party/nix/src/libexpr/primops/fetchMercurial.cc
+++ b/third_party/nix/src/libexpr/primops/fetchMercurial.cc
@@ -7,11 +7,11 @@
 #include <glog/logging.h>
 #include <sys/time.h>
 
-#include "download.hh"
-#include "eval-inline.hh"
-#include "pathlocks.hh"
-#include "primops.hh"
-#include "store-api.hh"
+#include "libexpr/eval-inline.hh"
+#include "libexpr/primops.hh"
+#include "libstore/download.hh"
+#include "libstore/pathlocks.hh"
+#include "libstore/store-api.hh"
 
 using namespace std::string_literals;
 
diff --git a/third_party/nix/src/libexpr/primops/fromTOML.cc b/third_party/nix/src/libexpr/primops/fromTOML.cc
index cc7b3cfcc33e..66e2e1b4094f 100644
--- a/third_party/nix/src/libexpr/primops/fromTOML.cc
+++ b/third_party/nix/src/libexpr/primops/fromTOML.cc
@@ -1,6 +1,6 @@
 #include "cpptoml/cpptoml.h"
-#include "eval-inline.hh"
-#include "primops.hh"
+#include "libexpr/eval-inline.hh"
+#include "libexpr/primops.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/symbol-table.cc b/third_party/nix/src/libexpr/symbol-table.cc
index 6abaedc5173c..2b27ca54c289 100644
--- a/third_party/nix/src/libexpr/symbol-table.cc
+++ b/third_party/nix/src/libexpr/symbol-table.cc
@@ -1,4 +1,4 @@
-#include "symbol-table.hh"
+#include "libexpr/symbol-table.hh"
 
 #include <absl/container/node_hash_set.h>
 #include <absl/strings/string_view.h>
diff --git a/third_party/nix/src/libexpr/value-to-json.cc b/third_party/nix/src/libexpr/value-to-json.cc
index 0b641a41b5ac..a51a1cee3043 100644
--- a/third_party/nix/src/libexpr/value-to-json.cc
+++ b/third_party/nix/src/libexpr/value-to-json.cc
@@ -1,11 +1,11 @@
-#include "value-to-json.hh"
+#include "libexpr/value-to-json.hh"
 
 #include <cstdlib>
 #include <iomanip>
 
-#include "eval-inline.hh"
-#include "json.hh"
-#include "util.hh"
+#include "libexpr/eval-inline.hh"
+#include "libutil/json.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/value-to-json.hh b/third_party/nix/src/libexpr/value-to-json.hh
index 6ec36c829d37..294d77604560 100644
--- a/third_party/nix/src/libexpr/value-to-json.hh
+++ b/third_party/nix/src/libexpr/value-to-json.hh
@@ -3,8 +3,8 @@
 #include <map>
 #include <string>
 
-#include "eval.hh"
-#include "nixexpr.hh"
+#include "libexpr/eval.hh"
+#include "libexpr/nixexpr.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/value-to-xml.cc b/third_party/nix/src/libexpr/value-to-xml.cc
index 149bf764f0f9..2a46ac84be61 100644
--- a/third_party/nix/src/libexpr/value-to-xml.cc
+++ b/third_party/nix/src/libexpr/value-to-xml.cc
@@ -1,10 +1,10 @@
-#include "value-to-xml.hh"
+#include "libexpr/value-to-xml.hh"
 
 #include <cstdlib>
 
-#include "eval-inline.hh"
-#include "util.hh"
-#include "xml-writer.hh"
+#include "libexpr/eval-inline.hh"
+#include "libutil/util.hh"
+#include "libutil/xml-writer.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/value-to-xml.hh b/third_party/nix/src/libexpr/value-to-xml.hh
index e7749dd7ae30..18c5279236ff 100644
--- a/third_party/nix/src/libexpr/value-to-xml.hh
+++ b/third_party/nix/src/libexpr/value-to-xml.hh
@@ -3,8 +3,8 @@
 #include <map>
 #include <string>
 
-#include "eval.hh"
-#include "nixexpr.hh"
+#include "libexpr/eval.hh"
+#include "libexpr/nixexpr.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libexpr/value.hh b/third_party/nix/src/libexpr/value.hh
index 1f20a440d933..01b9fd3a216d 100644
--- a/third_party/nix/src/libexpr/value.hh
+++ b/third_party/nix/src/libexpr/value.hh
@@ -1,11 +1,9 @@
 #pragma once
 
-#include "symbol-table.hh"
-#include "types.hh"
-
-#if HAVE_BOEHMGC
 #include <gc/gc_allocator.h>
-#endif
+
+#include "libexpr/symbol-table.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libmain/common-args.cc b/third_party/nix/src/libmain/common-args.cc
index f85eadbf70d9..0000605d454a 100644
--- a/third_party/nix/src/libmain/common-args.cc
+++ b/third_party/nix/src/libmain/common-args.cc
@@ -1,8 +1,8 @@
-#include "common-args.hh"
+#include "libmain/common-args.hh"
 
 #include <glog/logging.h>
 
-#include "globals.hh"
+#include "libstore/globals.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libmain/common-args.hh b/third_party/nix/src/libmain/common-args.hh
index 88b51047dfbe..f1c7c8481323 100644
--- a/third_party/nix/src/libmain/common-args.hh
+++ b/third_party/nix/src/libmain/common-args.hh
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "args.hh"
+#include "libutil/args.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libmain/shared.cc b/third_party/nix/src/libmain/shared.cc
index 549134872e91..3cbf59c88770 100644
--- a/third_party/nix/src/libmain/shared.cc
+++ b/third_party/nix/src/libmain/shared.cc
@@ -1,4 +1,4 @@
-#include "shared.hh"
+#include "libmain/shared.hh"
 
 #include <algorithm>
 #include <cctype>
@@ -15,9 +15,9 @@
 #include <sys/time.h>
 #include <unistd.h>
 
-#include "globals.hh"
-#include "store-api.hh"
-#include "util.hh"
+#include "libstore/globals.hh"
+#include "libstore/store-api.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libmain/shared.hh b/third_party/nix/src/libmain/shared.hh
index 60d7918931d7..b749b572c560 100644
--- a/third_party/nix/src/libmain/shared.hh
+++ b/third_party/nix/src/libmain/shared.hh
@@ -5,9 +5,9 @@
 #include <absl/strings/numbers.h>
 #include <signal.h>
 
-#include "args.hh"
-#include "common-args.hh"
-#include "util.hh"
+#include "libmain/common-args.hh"
+#include "libutil/args.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libmain/stack.cc b/third_party/nix/src/libmain/stack.cc
index f100b39156e4..c7744f69c82c 100644
--- a/third_party/nix/src/libmain/stack.cc
+++ b/third_party/nix/src/libmain/stack.cc
@@ -5,7 +5,7 @@
 
 #include <unistd.h>
 
-#include "types.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/binary-cache-store.cc b/third_party/nix/src/libstore/binary-cache-store.cc
index f631c9dee231..b862ea005870 100644
--- a/third_party/nix/src/libstore/binary-cache-store.cc
+++ b/third_party/nix/src/libstore/binary-cache-store.cc
@@ -1,4 +1,4 @@
-#include "binary-cache-store.hh"
+#include "libstore/binary-cache-store.hh"
 
 #include <chrono>
 #include <future>
@@ -7,19 +7,19 @@
 #include <absl/strings/ascii.h>
 #include <absl/strings/numbers.h>
 #include <absl/strings/str_split.h>
-
-#include "archive.hh"
-#include "compression.hh"
-#include "derivations.hh"
-#include "fs-accessor.hh"
-#include "globals.hh"
-#include "glog/logging.h"
-#include "json.hh"
-#include "nar-accessor.hh"
-#include "nar-info-disk-cache.hh"
-#include "nar-info.hh"
-#include "remote-fs-accessor.hh"
-#include "sync.hh"
+#include <glog/logging.h>
+
+#include "libstore/derivations.hh"
+#include "libstore/fs-accessor.hh"
+#include "libstore/globals.hh"
+#include "libstore/nar-accessor.hh"
+#include "libstore/nar-info-disk-cache.hh"
+#include "libstore/nar-info.hh"
+#include "libstore/remote-fs-accessor.hh"
+#include "libutil/archive.hh"
+#include "libutil/compression.hh"
+#include "libutil/json.hh"
+#include "libutil/sync.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/binary-cache-store.hh b/third_party/nix/src/libstore/binary-cache-store.hh
index b8e1ccabf264..0b788152f0bc 100644
--- a/third_party/nix/src/libstore/binary-cache-store.hh
+++ b/third_party/nix/src/libstore/binary-cache-store.hh
@@ -2,9 +2,9 @@
 
 #include <atomic>
 
-#include "crypto.hh"
-#include "pool.hh"
-#include "store-api.hh"
+#include "libstore/crypto.hh"
+#include "libstore/store-api.hh"
+#include "libutil/pool.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/build.cc b/third_party/nix/src/libstore/build.cc
index a60f5ef173e6..0b4bce182031 100644
--- a/third_party/nix/src/libstore/build.cc
+++ b/third_party/nix/src/libstore/build.cc
@@ -17,6 +17,7 @@
 #include <absl/strings/numbers.h>
 #include <absl/strings/str_split.h>
 #include <fcntl.h>
+#include <glog/logging.h>
 #include <grp.h>
 #include <netdb.h>
 #include <pwd.h>
@@ -31,22 +32,21 @@
 #include <termios.h>
 #include <unistd.h>
 
-#include "affinity.hh"
-#include "archive.hh"
-#include "builtins.hh"
-#include "compression.hh"
-#include "download.hh"
-#include "finally.hh"
-#include "globals.hh"
-#include "glog/logging.h"
-#include "json.hh"
-#include "local-store.hh"
-#include "machines.hh"
-#include "nar-info.hh"
-#include "parsed-derivations.hh"
-#include "pathlocks.hh"
-#include "references.hh"
-#include "util.hh"
+#include "libstore/builtins.hh"
+#include "libstore/download.hh"
+#include "libstore/globals.hh"
+#include "libstore/local-store.hh"
+#include "libstore/machines.hh"
+#include "libstore/nar-info.hh"
+#include "libstore/parsed-derivations.hh"
+#include "libstore/pathlocks.hh"
+#include "libstore/references.hh"
+#include "libutil/affinity.hh"
+#include "libutil/archive.hh"
+#include "libutil/compression.hh"
+#include "libutil/finally.hh"
+#include "libutil/json.hh"
+#include "libutil/util.hh"
 
 /* Includes required for chroot support. */
 #if __linux__
diff --git a/third_party/nix/src/libstore/builtins.hh b/third_party/nix/src/libstore/builtins.hh
index 07601be0f50c..bc53e78ebc33 100644
--- a/third_party/nix/src/libstore/builtins.hh
+++ b/third_party/nix/src/libstore/builtins.hh
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "derivations.hh"
+#include "libstore/derivations.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/builtins/buildenv.cc b/third_party/nix/src/libstore/builtins/buildenv.cc
index db093663bfef..95f915227bb1 100644
--- a/third_party/nix/src/libstore/builtins/buildenv.cc
+++ b/third_party/nix/src/libstore/builtins/buildenv.cc
@@ -7,7 +7,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include "builtins.hh"
+#include "libstore/builtins.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/builtins/fetchurl.cc b/third_party/nix/src/libstore/builtins/fetchurl.cc
index 90814f6d7f0b..867a120e8d4a 100644
--- a/third_party/nix/src/libstore/builtins/fetchurl.cc
+++ b/third_party/nix/src/libstore/builtins/fetchurl.cc
@@ -1,11 +1,11 @@
 #include <absl/strings/match.h>
 #include <glog/logging.h>
 
-#include "archive.hh"
-#include "builtins.hh"
-#include "compression.hh"
-#include "download.hh"
-#include "store-api.hh"
+#include "libstore/builtins.hh"
+#include "libstore/download.hh"
+#include "libstore/store-api.hh"
+#include "libutil/archive.hh"
+#include "libutil/compression.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/crypto.cc b/third_party/nix/src/libstore/crypto.cc
index eb5bb6670738..62b3c05ff95f 100644
--- a/third_party/nix/src/libstore/crypto.cc
+++ b/third_party/nix/src/libstore/crypto.cc
@@ -1,7 +1,7 @@
-#include "crypto.hh"
+#include "libstore/crypto.hh"
 
-#include "globals.hh"
-#include "util.hh"
+#include "libstore/globals.hh"
+#include "libutil/util.hh"
 
 #if HAVE_SODIUM
 #include <sodium.h>
diff --git a/third_party/nix/src/libstore/crypto.hh b/third_party/nix/src/libstore/crypto.hh
index ef578db6d055..e282f4f8ef69 100644
--- a/third_party/nix/src/libstore/crypto.hh
+++ b/third_party/nix/src/libstore/crypto.hh
@@ -2,7 +2,7 @@
 
 #include <map>
 
-#include "types.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/derivations.cc b/third_party/nix/src/libstore/derivations.cc
index b2590f5e28e6..64d1c6a15144 100644
--- a/third_party/nix/src/libstore/derivations.cc
+++ b/third_party/nix/src/libstore/derivations.cc
@@ -1,15 +1,15 @@
-#include "derivations.hh"
+#include "libstore/derivations.hh"
 
 #include <absl/strings/match.h>
 #include <absl/strings/str_split.h>
 #include <absl/strings/string_view.h>
 
-#include "fs-accessor.hh"
-#include "globals.hh"
-#include "istringstream_nocopy.hh"
-#include "store-api.hh"
-#include "util.hh"
-#include "worker-protocol.hh"
+#include "libstore/fs-accessor.hh"
+#include "libstore/globals.hh"
+#include "libstore/store-api.hh"
+#include "libstore/worker-protocol.hh"
+#include "libutil/istringstream_nocopy.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/derivations.hh b/third_party/nix/src/libstore/derivations.hh
index 170f09804dee..7574aa90c2c4 100644
--- a/third_party/nix/src/libstore/derivations.hh
+++ b/third_party/nix/src/libstore/derivations.hh
@@ -2,9 +2,9 @@
 
 #include <map>
 
-#include "hash.hh"
-#include "store-api.hh"
-#include "types.hh"
+#include "libstore/store-api.hh"
+#include "libutil/hash.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/download.cc b/third_party/nix/src/libstore/download.cc
index 92a63087289e..f30642d69daf 100644
--- a/third_party/nix/src/libstore/download.cc
+++ b/third_party/nix/src/libstore/download.cc
@@ -1,19 +1,19 @@
-#include "download.hh"
+#include "libstore/download.hh"
 
 #include <absl/strings/ascii.h>
 #include <absl/strings/match.h>
 #include <absl/strings/numbers.h>
 #include <absl/strings/str_split.h>
 
-#include "archive.hh"
-#include "compression.hh"
-#include "finally.hh"
-#include "globals.hh"
-#include "hash.hh"
-#include "pathlocks.hh"
-#include "s3.hh"
-#include "store-api.hh"
-#include "util.hh"
+#include "libstore/globals.hh"
+#include "libstore/pathlocks.hh"
+#include "libstore/s3.hh"
+#include "libstore/store-api.hh"
+#include "libutil/archive.hh"
+#include "libutil/compression.hh"
+#include "libutil/finally.hh"
+#include "libutil/hash.hh"
+#include "libutil/util.hh"
 
 #ifdef ENABLE_S3
 #include <aws/core/client/ClientConfiguration.h>
diff --git a/third_party/nix/src/libstore/download.hh b/third_party/nix/src/libstore/download.hh
index a988ec682669..cbfab5f40d22 100644
--- a/third_party/nix/src/libstore/download.hh
+++ b/third_party/nix/src/libstore/download.hh
@@ -3,9 +3,9 @@
 #include <future>
 #include <string>
 
-#include "globals.hh"
-#include "hash.hh"
-#include "types.hh"
+#include "libstore/globals.hh"
+#include "libutil/hash.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/export-import.cc b/third_party/nix/src/libstore/export-import.cc
index 077b0d539001..8e9314433990 100644
--- a/third_party/nix/src/libstore/export-import.cc
+++ b/third_party/nix/src/libstore/export-import.cc
@@ -1,8 +1,8 @@
 #include <algorithm>
 
-#include "archive.hh"
-#include "store-api.hh"
-#include "worker-protocol.hh"
+#include "libstore/store-api.hh"
+#include "libstore/worker-protocol.hh"
+#include "libutil/archive.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/fs-accessor.hh b/third_party/nix/src/libstore/fs-accessor.hh
index ad0d7f0ed9fd..1bc1373dcb2f 100644
--- a/third_party/nix/src/libstore/fs-accessor.hh
+++ b/third_party/nix/src/libstore/fs-accessor.hh
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "types.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/gc.cc b/third_party/nix/src/libstore/gc.cc
index 5c1ea3d58b69..9a6d97eb73c9 100644
--- a/third_party/nix/src/libstore/gc.cc
+++ b/third_party/nix/src/libstore/gc.cc
@@ -9,16 +9,16 @@
 #include <absl/strings/match.h>
 #include <absl/strings/str_split.h>
 #include <fcntl.h>
+#include <glog/logging.h>
 #include <sys/stat.h>
 #include <sys/statvfs.h>
 #include <sys/types.h>
 #include <unistd.h>
 
-#include "derivations.hh"
-#include "finally.hh"
-#include "globals.hh"
-#include "glog/logging.h"
-#include "local-store.hh"
+#include "libstore/derivations.hh"
+#include "libstore/globals.hh"
+#include "libstore/local-store.hh"
+#include "libutil/finally.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/globals.cc b/third_party/nix/src/libstore/globals.cc
index f218534cc9f8..dccf8d9815a7 100644
--- a/third_party/nix/src/libstore/globals.cc
+++ b/third_party/nix/src/libstore/globals.cc
@@ -1,4 +1,4 @@
-#include "globals.hh"
+#include "libstore/globals.hh"
 
 #include <algorithm>
 #include <map>
@@ -9,9 +9,10 @@
 #include <absl/strings/str_split.h>
 #include <dlfcn.h>
 
-#include "archive.hh"
-#include "args.hh"
-#include "util.hh"
+#include "libutil/archive.hh"
+#include "libutil/args.hh"
+#include "libutil/util.hh"
+#include "nix_config.h"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/globals.hh b/third_party/nix/src/libstore/globals.hh
index feff54879070..567ec6c42b6c 100644
--- a/third_party/nix/src/libstore/globals.hh
+++ b/third_party/nix/src/libstore/globals.hh
@@ -5,9 +5,10 @@
 
 #include <sys/types.h>
 
-#include "config.hh"
-#include "types.hh"
-#include "util.hh"
+#include "libutil/config.hh"
+#include "libutil/types.hh"
+#include "libutil/util.hh"
+#include "nix_config.h"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/http-binary-cache-store.cc b/third_party/nix/src/libstore/http-binary-cache-store.cc
index c75d5f2860a7..8ab07033b191 100644
--- a/third_party/nix/src/libstore/http-binary-cache-store.cc
+++ b/third_party/nix/src/libstore/http-binary-cache-store.cc
@@ -2,10 +2,10 @@
 
 #include <glog/logging.h>
 
-#include "binary-cache-store.hh"
-#include "download.hh"
-#include "globals.hh"
-#include "nar-info-disk-cache.hh"
+#include "libstore/binary-cache-store.hh"
+#include "libstore/download.hh"
+#include "libstore/globals.hh"
+#include "libstore/nar-info-disk-cache.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/legacy-ssh-store.cc b/third_party/nix/src/libstore/legacy-ssh-store.cc
index 9e6870f0da6b..332f6676b26e 100644
--- a/third_party/nix/src/libstore/legacy-ssh-store.cc
+++ b/third_party/nix/src/libstore/legacy-ssh-store.cc
@@ -1,12 +1,13 @@
-#include "archive.hh"
-#include "derivations.hh"
-#include "glog/logging.h"
-#include "pool.hh"
-#include "remote-store.hh"
-#include "serve-protocol.hh"
-#include "ssh.hh"
-#include "store-api.hh"
-#include "worker-protocol.hh"
+#include <glog/logging.h>
+
+#include "libstore/derivations.hh"
+#include "libstore/remote-store.hh"
+#include "libstore/serve-protocol.hh"
+#include "libstore/ssh.hh"
+#include "libstore/store-api.hh"
+#include "libstore/worker-protocol.hh"
+#include "libutil/archive.hh"
+#include "libutil/pool.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/local-binary-cache-store.cc b/third_party/nix/src/libstore/local-binary-cache-store.cc
index 88dd19a32069..4555de504783 100644
--- a/third_party/nix/src/libstore/local-binary-cache-store.cc
+++ b/third_party/nix/src/libstore/local-binary-cache-store.cc
@@ -2,9 +2,9 @@
 
 #include <absl/strings/match.h>
 
-#include "binary-cache-store.hh"
-#include "globals.hh"
-#include "nar-info-disk-cache.hh"
+#include "libstore/binary-cache-store.hh"
+#include "libstore/globals.hh"
+#include "libstore/nar-info-disk-cache.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/local-fs-store.cc b/third_party/nix/src/libstore/local-fs-store.cc
index f11c84b182a6..2dd09093d5f8 100644
--- a/third_party/nix/src/libstore/local-fs-store.cc
+++ b/third_party/nix/src/libstore/local-fs-store.cc
@@ -1,9 +1,9 @@
-#include "archive.hh"
-#include "compression.hh"
-#include "derivations.hh"
-#include "fs-accessor.hh"
-#include "globals.hh"
-#include "store-api.hh"
+#include "libstore/derivations.hh"
+#include "libstore/fs-accessor.hh"
+#include "libstore/globals.hh"
+#include "libstore/store-api.hh"
+#include "libutil/archive.hh"
+#include "libutil/compression.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/local-store.cc b/third_party/nix/src/libstore/local-store.cc
index ebc912969423..f9d03c520a7c 100644
--- a/third_party/nix/src/libstore/local-store.cc
+++ b/third_party/nix/src/libstore/local-store.cc
@@ -1,4 +1,4 @@
-#include "local-store.hh"
+#include "libstore/local-store.hh"
 
 #include <algorithm>
 #include <cerrno>
@@ -25,12 +25,13 @@
 #include <unistd.h>
 #include <utime.h>
 
-#include "archive.hh"
-#include "derivations.hh"
-#include "globals.hh"
-#include "nar-info.hh"
-#include "pathlocks.hh"
-#include "worker-protocol.hh"
+#include "generated/schema.sql.hh"
+#include "libstore/derivations.hh"
+#include "libstore/globals.hh"
+#include "libstore/nar-info.hh"
+#include "libstore/pathlocks.hh"
+#include "libstore/worker-protocol.hh"
+#include "libutil/archive.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/local-store.hh b/third_party/nix/src/libstore/local-store.hh
index 178cadf92bf6..7ad9de3a8a3e 100644
--- a/third_party/nix/src/libstore/local-store.hh
+++ b/third_party/nix/src/libstore/local-store.hh
@@ -7,11 +7,11 @@
 
 #include <absl/strings/str_split.h>
 
-#include "pathlocks.hh"
-#include "sqlite.hh"
-#include "store-api.hh"
-#include "sync.hh"
-#include "util.hh"
+#include "libstore/pathlocks.hh"
+#include "libstore/sqlite.hh"
+#include "libstore/store-api.hh"
+#include "libutil/sync.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/machines.cc b/third_party/nix/src/libstore/machines.cc
index 9ad20a25f8f0..e5d22c534c36 100644
--- a/third_party/nix/src/libstore/machines.cc
+++ b/third_party/nix/src/libstore/machines.cc
@@ -1,4 +1,4 @@
-#include "machines.hh"
+#include "libstore/machines.hh"
 
 #include <algorithm>
 
@@ -8,8 +8,8 @@
 #include <absl/strings/string_view.h>
 #include <glog/logging.h>
 
-#include "globals.hh"
-#include "util.hh"
+#include "libstore/globals.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/machines.hh b/third_party/nix/src/libstore/machines.hh
index 23712e676056..0e7269723707 100644
--- a/third_party/nix/src/libstore/machines.hh
+++ b/third_party/nix/src/libstore/machines.hh
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "types.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/misc.cc b/third_party/nix/src/libstore/misc.cc
index f95c4bec8b0c..8a05d55accd0 100644
--- a/third_party/nix/src/libstore/misc.cc
+++ b/third_party/nix/src/libstore/misc.cc
@@ -1,11 +1,11 @@
 #include <glog/logging.h>
 
-#include "derivations.hh"
-#include "globals.hh"
-#include "local-store.hh"
-#include "parsed-derivations.hh"
-#include "store-api.hh"
-#include "thread-pool.hh"
+#include "libstore/derivations.hh"
+#include "libstore/globals.hh"
+#include "libstore/local-store.hh"
+#include "libstore/parsed-derivations.hh"
+#include "libstore/store-api.hh"
+#include "libutil/thread-pool.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/nar-accessor.cc b/third_party/nix/src/libstore/nar-accessor.cc
index 84bfb531ecd6..49fa1bd1d61c 100644
--- a/third_party/nix/src/libstore/nar-accessor.cc
+++ b/third_party/nix/src/libstore/nar-accessor.cc
@@ -1,4 +1,4 @@
-#include "nar-accessor.hh"
+#include "libstore/nar-accessor.hh"
 
 #include <algorithm>
 #include <map>
@@ -6,8 +6,8 @@
 #include <stack>
 #include <utility>
 
-#include "archive.hh"
-#include "json.hh"
+#include "libutil/archive.hh"
+#include "libutil/json.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/nar-accessor.hh b/third_party/nix/src/libstore/nar-accessor.hh
index 8b18d4a36e06..0906a4606eb4 100644
--- a/third_party/nix/src/libstore/nar-accessor.hh
+++ b/third_party/nix/src/libstore/nar-accessor.hh
@@ -2,7 +2,7 @@
 
 #include <functional>
 
-#include "fs-accessor.hh"
+#include "libstore/fs-accessor.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/nar-info-disk-cache.cc b/third_party/nix/src/libstore/nar-info-disk-cache.cc
index 0a7a0dc22c51..c98882bff319 100644
--- a/third_party/nix/src/libstore/nar-info-disk-cache.cc
+++ b/third_party/nix/src/libstore/nar-info-disk-cache.cc
@@ -1,13 +1,13 @@
-#include "nar-info-disk-cache.hh"
+#include "libstore/nar-info-disk-cache.hh"
 
 #include <absl/strings/str_cat.h>
 #include <absl/strings/str_split.h>
 #include <glog/logging.h>
 #include <sqlite3.h>
 
-#include "globals.hh"
-#include "sqlite.hh"
-#include "sync.hh"
+#include "libstore/globals.hh"
+#include "libstore/sqlite.hh"
+#include "libutil/sync.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/nar-info-disk-cache.hh b/third_party/nix/src/libstore/nar-info-disk-cache.hh
index 65bb773c92f7..b4107721aad1 100644
--- a/third_party/nix/src/libstore/nar-info-disk-cache.hh
+++ b/third_party/nix/src/libstore/nar-info-disk-cache.hh
@@ -1,7 +1,7 @@
 #pragma once
 
-#include "nar-info.hh"
-#include "ref.hh"
+#include "libstore/nar-info.hh"
+#include "libutil/ref.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/nar-info.cc b/third_party/nix/src/libstore/nar-info.cc
index 1dc0b54cf1e6..aa764f4a16a0 100644
--- a/third_party/nix/src/libstore/nar-info.cc
+++ b/third_party/nix/src/libstore/nar-info.cc
@@ -1,9 +1,9 @@
-#include "nar-info.hh"
+#include "libstore/nar-info.hh"
 
 #include <absl/strings/numbers.h>
 #include <absl/strings/str_split.h>
 
-#include "globals.hh"
+#include "libstore/globals.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/nar-info.hh b/third_party/nix/src/libstore/nar-info.hh
index ce362e703f99..48eccf830270 100644
--- a/third_party/nix/src/libstore/nar-info.hh
+++ b/third_party/nix/src/libstore/nar-info.hh
@@ -1,8 +1,8 @@
 #pragma once
 
-#include "hash.hh"
-#include "store-api.hh"
-#include "types.hh"
+#include "libstore/store-api.hh"
+#include "libutil/hash.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/optimise-store.cc b/third_party/nix/src/libstore/optimise-store.cc
index 7217d54ca9af..eb24633c181c 100644
--- a/third_party/nix/src/libstore/optimise-store.cc
+++ b/third_party/nix/src/libstore/optimise-store.cc
@@ -5,14 +5,14 @@
 #include <regex>
 #include <utility>
 
+#include <glog/logging.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
 
-#include "globals.hh"
-#include "glog/logging.h"
-#include "local-store.hh"
-#include "util.hh"
+#include "libstore/globals.hh"
+#include "libstore/local-store.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/parsed-derivations.cc b/third_party/nix/src/libstore/parsed-derivations.cc
index 571f49ad59e2..9ee93b6a6d6e 100644
--- a/third_party/nix/src/libstore/parsed-derivations.cc
+++ b/third_party/nix/src/libstore/parsed-derivations.cc
@@ -1,4 +1,4 @@
-#include "parsed-derivations.hh"
+#include "libstore/parsed-derivations.hh"
 
 #include <absl/strings/str_split.h>
 
diff --git a/third_party/nix/src/libstore/parsed-derivations.hh b/third_party/nix/src/libstore/parsed-derivations.hh
index 7b2da3b566ac..7cd3d36f67bf 100644
--- a/third_party/nix/src/libstore/parsed-derivations.hh
+++ b/third_party/nix/src/libstore/parsed-derivations.hh
@@ -1,6 +1,6 @@
 #include <nlohmann/json.hpp>
 
-#include "derivations.hh"
+#include "libstore/derivations.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/pathlocks.cc b/third_party/nix/src/libstore/pathlocks.cc
index 642e64a62bac..4b153856d283 100644
--- a/third_party/nix/src/libstore/pathlocks.cc
+++ b/third_party/nix/src/libstore/pathlocks.cc
@@ -1,4 +1,4 @@
-#include "pathlocks.hh"
+#include "libstore/pathlocks.hh"
 
 #include <cerrno>
 #include <cstdlib>
@@ -9,8 +9,8 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include "sync.hh"
-#include "util.hh"
+#include "libutil/sync.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/pathlocks.hh b/third_party/nix/src/libstore/pathlocks.hh
index 201e3f01b4df..d515963e76e9 100644
--- a/third_party/nix/src/libstore/pathlocks.hh
+++ b/third_party/nix/src/libstore/pathlocks.hh
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "util.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/profiles.cc b/third_party/nix/src/libstore/profiles.cc
index 53e64879954b..0d44c60cc4e9 100644
--- a/third_party/nix/src/libstore/profiles.cc
+++ b/third_party/nix/src/libstore/profiles.cc
@@ -1,4 +1,4 @@
-#include "profiles.hh"
+#include "libstore/profiles.hh"
 
 #include <cerrno>
 #include <cstdio>
@@ -11,8 +11,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include "store-api.hh"
-#include "util.hh"
+#include "libstore/store-api.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/profiles.hh b/third_party/nix/src/libstore/profiles.hh
index 9f31083b32ee..ff6399040928 100644
--- a/third_party/nix/src/libstore/profiles.hh
+++ b/third_party/nix/src/libstore/profiles.hh
@@ -2,8 +2,8 @@
 
 #include <time.h>
 
-#include "pathlocks.hh"
-#include "types.hh"
+#include "libstore/pathlocks.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/references.cc b/third_party/nix/src/libstore/references.cc
index 6b9b7137c4e5..ea9ce44275a0 100644
--- a/third_party/nix/src/libstore/references.cc
+++ b/third_party/nix/src/libstore/references.cc
@@ -1,13 +1,13 @@
-#include "references.hh"
+#include "libstore/references.hh"
 
 #include <cstdlib>
 #include <map>
 
 #include <glog/logging.h>
 
-#include "archive.hh"
-#include "hash.hh"
-#include "util.hh"
+#include "libutil/archive.hh"
+#include "libutil/hash.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/references.hh b/third_party/nix/src/libstore/references.hh
index 2229150e3359..94ac5200bdff 100644
--- a/third_party/nix/src/libstore/references.hh
+++ b/third_party/nix/src/libstore/references.hh
@@ -1,7 +1,7 @@
 #pragma once
 
-#include "hash.hh"
-#include "types.hh"
+#include "libutil/hash.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/remote-fs-accessor.cc b/third_party/nix/src/libstore/remote-fs-accessor.cc
index ca478c213fde..2917f01f7939 100644
--- a/third_party/nix/src/libstore/remote-fs-accessor.cc
+++ b/third_party/nix/src/libstore/remote-fs-accessor.cc
@@ -1,11 +1,11 @@
-#include "remote-fs-accessor.hh"
+#include "libstore/remote-fs-accessor.hh"
 
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include "json.hh"
-#include "nar-accessor.hh"
+#include "libstore/nar-accessor.hh"
+#include "libutil/json.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/remote-fs-accessor.hh b/third_party/nix/src/libstore/remote-fs-accessor.hh
index 32c729f50dcf..c4f6e89c97b5 100644
--- a/third_party/nix/src/libstore/remote-fs-accessor.hh
+++ b/third_party/nix/src/libstore/remote-fs-accessor.hh
@@ -1,8 +1,8 @@
 #pragma once
 
-#include "fs-accessor.hh"
-#include "ref.hh"
-#include "store-api.hh"
+#include "libstore/fs-accessor.hh"
+#include "libstore/store-api.hh"
+#include "libutil/ref.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/remote-store.cc b/third_party/nix/src/libstore/remote-store.cc
index c5d1dac6cb6c..5c5038dc4154 100644
--- a/third_party/nix/src/libstore/remote-store.cc
+++ b/third_party/nix/src/libstore/remote-store.cc
@@ -1,4 +1,4 @@
-#include "remote-store.hh"
+#include "libstore/remote-store.hh"
 
 #include <cerrno>
 #include <cstring>
@@ -12,16 +12,16 @@
 #include <sys/un.h>
 #include <unistd.h>
 
-#include "affinity.hh"
-#include "archive.hh"
-#include "derivations.hh"
-#include "finally.hh"
-#include "globals.hh"
-#include "pool.hh"
-#include "prefork-compat.hh"
-#include "serialise.hh"
-#include "util.hh"
-#include "worker-protocol.hh"
+#include "libstore/derivations.hh"
+#include "libstore/globals.hh"
+#include "libstore/worker-protocol.hh"
+#include "libutil/affinity.hh"
+#include "libutil/archive.hh"
+#include "libutil/finally.hh"
+#include "libutil/pool.hh"
+#include "libutil/prefork-compat.hh"
+#include "libutil/serialise.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/remote-store.hh b/third_party/nix/src/libstore/remote-store.hh
index e61e72892c34..03fbbf000c5f 100644
--- a/third_party/nix/src/libstore/remote-store.hh
+++ b/third_party/nix/src/libstore/remote-store.hh
@@ -3,7 +3,7 @@
 #include <limits>
 #include <string>
 
-#include "store-api.hh"
+#include "libstore/store-api.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/s3-binary-cache-store.cc b/third_party/nix/src/libstore/s3-binary-cache-store.cc
index d713c5ce0151..0c13039b52d4 100644
--- a/third_party/nix/src/libstore/s3-binary-cache-store.cc
+++ b/third_party/nix/src/libstore/s3-binary-cache-store.cc
@@ -1,6 +1,6 @@
 #if ENABLE_S3
 
-#include "s3-binary-cache-store.hh"
+#include "libstore/s3-binary-cache-store.hh"
 
 #include <absl/strings/ascii.h>
 #include <absl/strings/match.h>
@@ -20,13 +20,13 @@
 #include <aws/s3/model/PutObjectRequest.h>
 #include <aws/transfer/TransferManager.h>
 
-#include "compression.hh"
-#include "download.hh"
-#include "globals.hh"
-#include "istringstream_nocopy.hh"
-#include "nar-info-disk-cache.hh"
-#include "nar-info.hh"
-#include "s3.hh"
+#include "libstore/download.hh"
+#include "libstore/globals.hh"
+#include "libstore/nar-info-disk-cache.hh"
+#include "libstore/nar-info.hh"
+#include "libstore/s3.hh"
+#include "libutil/compression.hh"
+#include "libutil/istringstream_nocopy.hh"
 
 using namespace Aws::Transfer;
 
diff --git a/third_party/nix/src/libstore/s3-binary-cache-store.hh b/third_party/nix/src/libstore/s3-binary-cache-store.hh
index 24cb67721a92..3d0d0b3c4496 100644
--- a/third_party/nix/src/libstore/s3-binary-cache-store.hh
+++ b/third_party/nix/src/libstore/s3-binary-cache-store.hh
@@ -2,7 +2,7 @@
 
 #include <atomic>
 
-#include "binary-cache-store.hh"
+#include "libstore/binary-cache-store.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/s3.hh b/third_party/nix/src/libstore/s3.hh
index 09935fabed47..4f1852dc3d72 100644
--- a/third_party/nix/src/libstore/s3.hh
+++ b/third_party/nix/src/libstore/s3.hh
@@ -2,7 +2,7 @@
 
 #if ENABLE_S3
 
-#include "ref.hh"
+#include "libutil/ref.hh"
 
 namespace Aws {
 namespace Client {
diff --git a/third_party/nix/src/libstore/sqlite.cc b/third_party/nix/src/libstore/sqlite.cc
index dbdaa29d4fd9..b6ecfce924a1 100644
--- a/third_party/nix/src/libstore/sqlite.cc
+++ b/third_party/nix/src/libstore/sqlite.cc
@@ -1,11 +1,11 @@
-#include "sqlite.hh"
+#include "libstore/sqlite.hh"
 
 #include <atomic>
 
 #include <glog/logging.h>
 #include <sqlite3.h>
 
-#include "util.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/sqlite.hh b/third_party/nix/src/libstore/sqlite.hh
index 298bb574ea2d..c0bc70bfc16d 100644
--- a/third_party/nix/src/libstore/sqlite.hh
+++ b/third_party/nix/src/libstore/sqlite.hh
@@ -3,7 +3,7 @@
 #include <functional>
 #include <string>
 
-#include "types.hh"
+#include "libutil/types.hh"
 
 class sqlite3;
 class sqlite3_stmt;
diff --git a/third_party/nix/src/libstore/ssh-store.cc b/third_party/nix/src/libstore/ssh-store.cc
index 9c49babcf2b2..eae8ee888bb9 100644
--- a/third_party/nix/src/libstore/ssh-store.cc
+++ b/third_party/nix/src/libstore/ssh-store.cc
@@ -1,10 +1,10 @@
-#include "archive.hh"
-#include "pool.hh"
-#include "remote-fs-accessor.hh"
-#include "remote-store.hh"
-#include "ssh.hh"
-#include "store-api.hh"
-#include "worker-protocol.hh"
+#include "libstore/remote-fs-accessor.hh"
+#include "libstore/remote-store.hh"
+#include "libstore/ssh.hh"
+#include "libstore/store-api.hh"
+#include "libstore/worker-protocol.hh"
+#include "libutil/archive.hh"
+#include "libutil/pool.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/ssh.cc b/third_party/nix/src/libstore/ssh.cc
index 1b09eb42c6b9..e84944c4c9cd 100644
--- a/third_party/nix/src/libstore/ssh.cc
+++ b/third_party/nix/src/libstore/ssh.cc
@@ -1,4 +1,4 @@
-#include "ssh.hh"
+#include "libstore/ssh.hh"
 
 #include <utility>
 
diff --git a/third_party/nix/src/libstore/ssh.hh b/third_party/nix/src/libstore/ssh.hh
index 23952ccb1293..9844f89d3599 100644
--- a/third_party/nix/src/libstore/ssh.hh
+++ b/third_party/nix/src/libstore/ssh.hh
@@ -1,7 +1,7 @@
 #pragma once
 
-#include "sync.hh"
-#include "util.hh"
+#include "libutil/sync.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/store-api.cc b/third_party/nix/src/libstore/store-api.cc
index afdbc14e29a3..081cdea9873d 100644
--- a/third_party/nix/src/libstore/store-api.cc
+++ b/third_party/nix/src/libstore/store-api.cc
@@ -1,4 +1,4 @@
-#include "store-api.hh"
+#include "libstore/store-api.hh"
 
 #include <future>
 #include <utility>
@@ -8,13 +8,13 @@
 #include <absl/strings/str_split.h>
 #include <glog/logging.h>
 
-#include "crypto.hh"
-#include "derivations.hh"
-#include "globals.hh"
-#include "json.hh"
-#include "nar-info-disk-cache.hh"
-#include "thread-pool.hh"
-#include "util.hh"
+#include "libstore/crypto.hh"
+#include "libstore/derivations.hh"
+#include "libstore/globals.hh"
+#include "libstore/nar-info-disk-cache.hh"
+#include "libutil/json.hh"
+#include "libutil/thread-pool.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
@@ -844,8 +844,8 @@ void Store::addToStore(const ValidPathInfo& info, const ref<std::string>& nar,
 
 }  // namespace nix
 
-#include "local-store.hh"
-#include "remote-store.hh"
+#include "libstore/local-store.hh"
+#include "libstore/remote-store.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libstore/store-api.hh b/third_party/nix/src/libstore/store-api.hh
index cf2520c6ca98..c6f8d75b67e2 100644
--- a/third_party/nix/src/libstore/store-api.hh
+++ b/third_party/nix/src/libstore/store-api.hh
@@ -8,13 +8,13 @@
 #include <unordered_map>
 #include <unordered_set>
 
-#include "config.hh"
-#include "crypto.hh"
-#include "globals.hh"
-#include "hash.hh"
-#include "lru-cache.hh"
-#include "serialise.hh"
-#include "sync.hh"
+#include "libstore/crypto.hh"
+#include "libstore/globals.hh"
+#include "libutil/config.hh"
+#include "libutil/hash.hh"
+#include "libutil/lru-cache.hh"
+#include "libutil/serialise.hh"
+#include "libutil/sync.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/affinity.cc b/third_party/nix/src/libutil/affinity.cc
index 7db8906eb0b4..03fbe1243992 100644
--- a/third_party/nix/src/libutil/affinity.cc
+++ b/third_party/nix/src/libutil/affinity.cc
@@ -1,9 +1,9 @@
-#include "affinity.hh"
+#include "libutil/affinity.hh"
 
 #include <glog/logging.h>
 
-#include "types.hh"
-#include "util.hh"
+#include "libutil/types.hh"
+#include "libutil/util.hh"
 
 #if __linux__
 #include <sched.h>
diff --git a/third_party/nix/src/libutil/archive.cc b/third_party/nix/src/libutil/archive.cc
index f78727c5fb46..40898093212a 100644
--- a/third_party/nix/src/libutil/archive.cc
+++ b/third_party/nix/src/libutil/archive.cc
@@ -1,4 +1,4 @@
-#include "archive.hh"
+#include "libutil/archive.hh"
 
 #include <algorithm>
 #include <cerrno>
@@ -7,14 +7,14 @@
 
 #include <dirent.h>
 #include <fcntl.h>
+#include <glog/logging.h>
 #include <strings.h>  // for strcasecmp
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
 
-#include "config.hh"
-#include "glog/logging.h"
-#include "util.hh"
+#include "libutil/config.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/archive.hh b/third_party/nix/src/libutil/archive.hh
index 0afa8893efdd..07f58b5f9433 100644
--- a/third_party/nix/src/libutil/archive.hh
+++ b/third_party/nix/src/libutil/archive.hh
@@ -1,7 +1,7 @@
 #pragma once
 
-#include "serialise.hh"
-#include "types.hh"
+#include "libutil/serialise.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/args.cc b/third_party/nix/src/libutil/args.cc
index 4e7bcb3ae72b..c56383ef88cc 100644
--- a/third_party/nix/src/libutil/args.cc
+++ b/third_party/nix/src/libutil/args.cc
@@ -1,6 +1,6 @@
-#include "args.hh"
+#include "libutil/args.hh"
 
-#include "hash.hh"
+#include "libutil/hash.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/args.hh b/third_party/nix/src/libutil/args.hh
index 2c352a04368c..37904b19aaa8 100644
--- a/third_party/nix/src/libutil/args.hh
+++ b/third_party/nix/src/libutil/args.hh
@@ -6,7 +6,7 @@
 
 #include <absl/strings/numbers.h>
 
-#include "util.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/compression.cc b/third_party/nix/src/libutil/compression.cc
index d7084ab7f15d..a50076fcd550 100644
--- a/third_party/nix/src/libutil/compression.cc
+++ b/third_party/nix/src/libutil/compression.cc
@@ -1,4 +1,4 @@
-#include "compression.hh"
+#include "libutil/compression.hh"
 
 #include <cstdio>
 #include <cstring>
@@ -7,11 +7,11 @@
 #include <brotli/decode.h>
 #include <brotli/encode.h>
 #include <bzlib.h>
+#include <glog/logging.h>
 #include <lzma.h>
 
-#include "finally.hh"
-#include "glog/logging.h"
-#include "util.hh"
+#include "libutil/finally.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/compression.hh b/third_party/nix/src/libutil/compression.hh
index 80b651e107d4..8ec340ab7447 100644
--- a/third_party/nix/src/libutil/compression.hh
+++ b/third_party/nix/src/libutil/compression.hh
@@ -2,9 +2,9 @@
 
 #include <string>
 
-#include "ref.hh"
-#include "serialise.hh"
-#include "types.hh"
+#include "libutil/ref.hh"
+#include "libutil/serialise.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/config.cc b/third_party/nix/src/libutil/config.cc
index 9e3f6f85c52d..ebb6b4df1d70 100644
--- a/third_party/nix/src/libutil/config.cc
+++ b/third_party/nix/src/libutil/config.cc
@@ -1,4 +1,4 @@
-#include "config.hh"
+#include "libutil/config.hh"
 
 #include <string>
 #include <utility>
@@ -9,8 +9,8 @@
 #include <absl/strings/string_view.h>
 #include <glog/logging.h>
 
-#include "args.hh"
-#include "json.hh"
+#include "libutil/args.hh"
+#include "libutil/json.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/config.hh b/third_party/nix/src/libutil/config.hh
index f8055d4d3690..0441e3b9e848 100644
--- a/third_party/nix/src/libutil/config.hh
+++ b/third_party/nix/src/libutil/config.hh
@@ -1,7 +1,7 @@
 #include <map>
 #include <set>
 
-#include "types.hh"
+#include "libutil/types.hh"
 
 #pragma once
 
diff --git a/third_party/nix/src/libutil/hash.cc b/third_party/nix/src/libutil/hash.cc
index 07a9730551da..5c2ddc4bda8e 100644
--- a/third_party/nix/src/libutil/hash.cc
+++ b/third_party/nix/src/libutil/hash.cc
@@ -1,4 +1,4 @@
-#include "hash.hh"
+#include "libutil/hash.hh"
 
 #include <cstring>
 #include <iostream>
@@ -9,9 +9,9 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include "archive.hh"
-#include "istringstream_nocopy.hh"
-#include "util.hh"
+#include "libutil/archive.hh"
+#include "libutil/istringstream_nocopy.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/hash.hh b/third_party/nix/src/libutil/hash.hh
index f9c63c155ead..34cb41c48784 100644
--- a/third_party/nix/src/libutil/hash.hh
+++ b/third_party/nix/src/libutil/hash.hh
@@ -1,7 +1,7 @@
 #pragma once
 
-#include "serialise.hh"
-#include "types.hh"
+#include "libutil/serialise.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/json.cc b/third_party/nix/src/libutil/json.cc
index 218fc264ba50..da636e7be9c3 100644
--- a/third_party/nix/src/libutil/json.cc
+++ b/third_party/nix/src/libutil/json.cc
@@ -1,4 +1,4 @@
-#include "json.hh"
+#include "libutil/json.hh"
 
 #include <cstring>
 #include <iomanip>
diff --git a/third_party/nix/src/libutil/pool.hh b/third_party/nix/src/libutil/pool.hh
index 6d70795d35ac..fe6d5c28004e 100644
--- a/third_party/nix/src/libutil/pool.hh
+++ b/third_party/nix/src/libutil/pool.hh
@@ -6,8 +6,8 @@
 #include <list>
 #include <memory>
 
-#include "ref.hh"
-#include "sync.hh"
+#include "libutil/ref.hh"
+#include "libutil/sync.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/serialise.cc b/third_party/nix/src/libutil/serialise.cc
index 52f0b5542601..d02a0205af0d 100644
--- a/third_party/nix/src/libutil/serialise.cc
+++ b/third_party/nix/src/libutil/serialise.cc
@@ -1,4 +1,4 @@
-#include "serialise.hh"
+#include "libutil/serialise.hh"
 
 #include <boost/coroutine2/coroutine.hpp>
 #include <cerrno>
@@ -6,8 +6,9 @@
 #include <memory>
 #include <utility>
 
-#include "glog/logging.h"
-#include "util.hh"
+#include <glog/logging.h>
+
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/serialise.hh b/third_party/nix/src/libutil/serialise.hh
index dc877487ee7e..fbedf0510aa1 100644
--- a/third_party/nix/src/libutil/serialise.hh
+++ b/third_party/nix/src/libutil/serialise.hh
@@ -2,8 +2,8 @@
 
 #include <memory>
 
-#include "types.hh"
-#include "util.hh"
+#include "libutil/types.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/thread-pool.cc b/third_party/nix/src/libutil/thread-pool.cc
index 879de446c294..7c6b0a1b469b 100644
--- a/third_party/nix/src/libutil/thread-pool.cc
+++ b/third_party/nix/src/libutil/thread-pool.cc
@@ -1,7 +1,8 @@
-#include "thread-pool.hh"
+#include "libutil/thread-pool.hh"
 
-#include "affinity.hh"
-#include "glog/logging.h"
+#include <glog/logging.h>
+
+#include "libutil/affinity.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/thread-pool.hh b/third_party/nix/src/libutil/thread-pool.hh
index 72837ca1eecc..23527b907a21 100644
--- a/third_party/nix/src/libutil/thread-pool.hh
+++ b/third_party/nix/src/libutil/thread-pool.hh
@@ -6,8 +6,8 @@
 #include <queue>
 #include <thread>
 
-#include "sync.hh"
-#include "util.hh"
+#include "libutil/sync.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/types.hh b/third_party/nix/src/libutil/types.hh
index ad44719afe3a..e2ea86fdcf5f 100644
--- a/third_party/nix/src/libutil/types.hh
+++ b/third_party/nix/src/libutil/types.hh
@@ -7,7 +7,7 @@
 #include <set>
 #include <string>
 
-#include "ref.hh"
+#include "libutil/ref.hh"
 
 /* Before 4.7, gcc's std::exception uses empty throw() specifiers for
  * its (virtual) destructor and what() in c++11 mode, in violation of spec
diff --git a/third_party/nix/src/libutil/util.cc b/third_party/nix/src/libutil/util.cc
index 3f541134b88f..bb6a17e03047 100644
--- a/third_party/nix/src/libutil/util.cc
+++ b/third_party/nix/src/libutil/util.cc
@@ -1,4 +1,4 @@
-#include "util.hh"
+#include "libutil/util.hh"
 
 #include <cctype>
 #include <cerrno>
@@ -15,6 +15,7 @@
 #include <absl/strings/str_split.h>
 #include <absl/strings/string_view.h>
 #include <fcntl.h>
+#include <glog/logging.h>
 #include <grp.h>
 #include <pwd.h>
 #include <sys/ioctl.h>
@@ -23,12 +24,12 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
-#include "affinity.hh"
-#include "finally.hh"
-#include "glog/logging.h"
-#include "lazy.hh"
-#include "serialise.hh"
-#include "sync.hh"
+#include "libutil/affinity.hh"
+#include "libutil/finally.hh"
+#include "libutil/lazy.hh"
+#include "libutil/serialise.hh"
+#include "libutil/sync.hh"
+#include "nix_config.h"
 
 namespace nix {
 
diff --git a/third_party/nix/src/libutil/util.hh b/third_party/nix/src/libutil/util.hh
index 27e6b47fb26b..b308c428fd2c 100644
--- a/third_party/nix/src/libutil/util.hh
+++ b/third_party/nix/src/libutil/util.hh
@@ -15,7 +15,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include "types.hh"
+#include "libutil/types.hh"
 
 #ifndef HAVE_STRUCT_DIRENT_D_TYPE
 #define DT_UNKNOWN 0
diff --git a/third_party/nix/src/libutil/xml-writer.cc b/third_party/nix/src/libutil/xml-writer.cc
index d34e9a2f0d59..8274ed769eb4 100644
--- a/third_party/nix/src/libutil/xml-writer.cc
+++ b/third_party/nix/src/libutil/xml-writer.cc
@@ -1,4 +1,4 @@
-#include "xml-writer.hh"
+#include "libutil/xml-writer.hh"
 
 #include <cassert>
 
diff --git a/third_party/nix/src/nix-build/nix-build.cc b/third_party/nix/src/nix-build/nix-build.cc
index 938452f71667..b00062de0ea0 100644
--- a/third_party/nix/src/nix-build/nix-build.cc
+++ b/third_party/nix/src/nix-build/nix-build.cc
@@ -9,18 +9,18 @@
 #include <absl/strings/str_split.h>
 #include <glog/logging.h>
 
-#include "affinity.hh"
-#include "attr-path.hh"
-#include "common-eval-args.hh"
-#include "derivations.hh"
-#include "eval-inline.hh"
-#include "eval.hh"
-#include "get-drvs.hh"
-#include "globals.hh"
-#include "legacy.hh"
-#include "shared.hh"
-#include "store-api.hh"
-#include "util.hh"
+#include "libexpr/attr-path.hh"
+#include "libexpr/common-eval-args.hh"
+#include "libexpr/eval-inline.hh"
+#include "libexpr/eval.hh"
+#include "libexpr/get-drvs.hh"
+#include "libmain/shared.hh"
+#include "libstore/derivations.hh"
+#include "libstore/globals.hh"
+#include "libstore/store-api.hh"
+#include "libutil/affinity.hh"
+#include "libutil/util.hh"
+#include "nix/legacy.hh"
 
 using namespace nix;
 using namespace std::string_literals;
diff --git a/third_party/nix/src/nix-channel/nix-channel.cc b/third_party/nix/src/nix-channel/nix-channel.cc
index 01fc788b9011..0fb53780d3b1 100644
--- a/third_party/nix/src/nix-channel/nix-channel.cc
+++ b/third_party/nix/src/nix-channel/nix-channel.cc
@@ -5,11 +5,11 @@
 #include <fcntl.h>
 #include <pwd.h>
 
-#include "download.hh"
-#include "globals.hh"
-#include "legacy.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libmain/shared.hh"
+#include "libstore/download.hh"
+#include "libstore/globals.hh"
+#include "libstore/store-api.hh"
+#include "nix/legacy.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix-collect-garbage/nix-collect-garbage.cc b/third_party/nix/src/nix-collect-garbage/nix-collect-garbage.cc
index 548e492664de..f6897595cbab 100644
--- a/third_party/nix/src/nix-collect-garbage/nix-collect-garbage.cc
+++ b/third_party/nix/src/nix-collect-garbage/nix-collect-garbage.cc
@@ -3,11 +3,11 @@
 
 #include <glog/logging.h>
 
-#include "globals.hh"
-#include "legacy.hh"
-#include "profiles.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libmain/shared.hh"
+#include "libstore/globals.hh"
+#include "libstore/profiles.hh"
+#include "libstore/store-api.hh"
+#include "nix/legacy.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix-copy-closure/nix-copy-closure.cc b/third_party/nix/src/nix-copy-closure/nix-copy-closure.cc
index 67765a8cf72c..d4ea6a85eca7 100644
--- a/third_party/nix/src/nix-copy-closure/nix-copy-closure.cc
+++ b/third_party/nix/src/nix-copy-closure/nix-copy-closure.cc
@@ -1,8 +1,8 @@
 #include <glog/logging.h>
 
-#include "legacy.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libmain/shared.hh"
+#include "libstore/store-api.hh"
+#include "nix/legacy.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix-daemon/nix-daemon.cc b/third_party/nix/src/nix-daemon/nix-daemon.cc
index 4373c33e8b4d..b2161f8584db 100644
--- a/third_party/nix/src/nix-daemon/nix-daemon.cc
+++ b/third_party/nix/src/nix-daemon/nix-daemon.cc
@@ -15,18 +15,18 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
-#include "affinity.hh"
-#include "archive.hh"
-#include "derivations.hh"
-#include "finally.hh"
-#include "globals.hh"
-#include "legacy.hh"
-#include "local-store.hh"
-#include "monitor-fd.hh"
-#include "serialise.hh"
-#include "shared.hh"
-#include "util.hh"
-#include "worker-protocol.hh"
+#include "libmain/shared.hh"
+#include "libstore/derivations.hh"
+#include "libstore/globals.hh"
+#include "libstore/local-store.hh"
+#include "libstore/worker-protocol.hh"
+#include "libutil/affinity.hh"
+#include "libutil/archive.hh"
+#include "libutil/finally.hh"
+#include "libutil/monitor-fd.hh"
+#include "libutil/serialise.hh"
+#include "libutil/util.hh"
+#include "nix/legacy.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix-env/nix-env.cc b/third_party/nix/src/nix-env/nix-env.cc
index d25a4897467c..10e2e9492e6c 100644
--- a/third_party/nix/src/nix-env/nix-env.cc
+++ b/third_party/nix/src/nix-env/nix-env.cc
@@ -11,22 +11,22 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include "attr-path.hh"
-#include "common-eval-args.hh"
-#include "derivations.hh"
-#include "eval.hh"
-#include "get-drvs.hh"
-#include "globals.hh"
-#include "json.hh"
-#include "legacy.hh"
-#include "names.hh"
-#include "profiles.hh"
-#include "shared.hh"
-#include "store-api.hh"
-#include "user-env.hh"
-#include "util.hh"
-#include "value-to-json.hh"
-#include "xml-writer.hh"
+#include "libexpr/attr-path.hh"
+#include "libexpr/common-eval-args.hh"
+#include "libexpr/eval.hh"
+#include "libexpr/get-drvs.hh"
+#include "libexpr/names.hh"
+#include "libexpr/value-to-json.hh"
+#include "libmain/shared.hh"
+#include "libstore/derivations.hh"
+#include "libstore/globals.hh"
+#include "libstore/profiles.hh"
+#include "libstore/store-api.hh"
+#include "libutil/json.hh"
+#include "libutil/util.hh"
+#include "libutil/xml-writer.hh"
+#include "nix-env/user-env.hh"
+#include "nix/legacy.hh"
 
 using namespace nix;
 using std::cout;
diff --git a/third_party/nix/src/nix-env/user-env.cc b/third_party/nix/src/nix-env/user-env.cc
index c8eee4aac09b..8130eafbdf35 100644
--- a/third_party/nix/src/nix-env/user-env.cc
+++ b/third_party/nix/src/nix-env/user-env.cc
@@ -1,15 +1,15 @@
-#include "user-env.hh"
+#include "nix-env/user-env.hh"
 
 #include <glog/logging.h>
 
-#include "derivations.hh"
-#include "eval-inline.hh"
-#include "eval.hh"
-#include "globals.hh"
-#include "profiles.hh"
-#include "shared.hh"
-#include "store-api.hh"
-#include "util.hh"
+#include "libexpr/eval-inline.hh"
+#include "libexpr/eval.hh"
+#include "libmain/shared.hh"
+#include "libstore/derivations.hh"
+#include "libstore/globals.hh"
+#include "libstore/profiles.hh"
+#include "libstore/store-api.hh"
+#include "libutil/util.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/nix-env/user-env.hh b/third_party/nix/src/nix-env/user-env.hh
index a117d5c2ad67..95919a6c8799 100644
--- a/third_party/nix/src/nix-env/user-env.hh
+++ b/third_party/nix/src/nix-env/user-env.hh
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "get-drvs.hh"
+#include "libexpr/get-drvs.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/nix-instantiate/nix-instantiate.cc b/third_party/nix/src/nix-instantiate/nix-instantiate.cc
index 8e1c7afe1c91..6c77a96ebc07 100644
--- a/third_party/nix/src/nix-instantiate/nix-instantiate.cc
+++ b/third_party/nix/src/nix-instantiate/nix-instantiate.cc
@@ -1,18 +1,18 @@
 #include <iostream>
 #include <map>
 
-#include "attr-path.hh"
-#include "common-eval-args.hh"
-#include "eval-inline.hh"
-#include "eval.hh"
-#include "get-drvs.hh"
-#include "globals.hh"
-#include "legacy.hh"
-#include "shared.hh"
-#include "store-api.hh"
-#include "util.hh"
-#include "value-to-json.hh"
-#include "value-to-xml.hh"
+#include "libexpr/attr-path.hh"
+#include "libexpr/common-eval-args.hh"
+#include "libexpr/eval-inline.hh"
+#include "libexpr/eval.hh"
+#include "libexpr/get-drvs.hh"
+#include "libexpr/value-to-json.hh"
+#include "libexpr/value-to-xml.hh"
+#include "libmain/shared.hh"
+#include "libstore/globals.hh"
+#include "libstore/store-api.hh"
+#include "libutil/util.hh"
+#include "nix/legacy.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix-prefetch-url/nix-prefetch-url.cc b/third_party/nix/src/nix-prefetch-url/nix-prefetch-url.cc
index c5b649fac7d7..a83ac62635be 100644
--- a/third_party/nix/src/nix-prefetch-url/nix-prefetch-url.cc
+++ b/third_party/nix/src/nix-prefetch-url/nix-prefetch-url.cc
@@ -6,16 +6,16 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include "attr-path.hh"
-#include "common-eval-args.hh"
-#include "download.hh"
-#include "eval-inline.hh"
-#include "eval.hh"
-#include "finally.hh"
-#include "hash.hh"
-#include "legacy.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libexpr/attr-path.hh"
+#include "libexpr/common-eval-args.hh"
+#include "libexpr/eval-inline.hh"
+#include "libexpr/eval.hh"
+#include "libmain/shared.hh"
+#include "libstore/download.hh"
+#include "libstore/store-api.hh"
+#include "libutil/finally.hh"
+#include "libutil/hash.hh"
+#include "nix/legacy.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix-store/dotgraph.cc b/third_party/nix/src/nix-store/dotgraph.cc
index ef335bb5318d..2500b8f4b07d 100644
--- a/third_party/nix/src/nix-store/dotgraph.cc
+++ b/third_party/nix/src/nix-store/dotgraph.cc
@@ -1,9 +1,9 @@
-#include "dotgraph.hh"
+#include "nix-store/dotgraph.hh"
 
 #include <iostream>
 
-#include "store-api.hh"
-#include "util.hh"
+#include "libstore/store-api.hh"
+#include "libutil/util.hh"
 
 using std::cout;
 
diff --git a/third_party/nix/src/nix-store/dotgraph.hh b/third_party/nix/src/nix-store/dotgraph.hh
index 20fc357b1bd4..40c268685494 100644
--- a/third_party/nix/src/nix-store/dotgraph.hh
+++ b/third_party/nix/src/nix-store/dotgraph.hh
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "types.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/nix-store/graphml.cc b/third_party/nix/src/nix-store/graphml.cc
index 86b1c6b94231..ada4aaf6d048 100644
--- a/third_party/nix/src/nix-store/graphml.cc
+++ b/third_party/nix/src/nix-store/graphml.cc
@@ -1,10 +1,10 @@
-#include "graphml.hh"
+#include "nix-store/graphml.hh"
 
 #include <iostream>
 
-#include "derivations.hh"
-#include "store-api.hh"
-#include "util.hh"
+#include "libstore/derivations.hh"
+#include "libstore/store-api.hh"
+#include "libutil/util.hh"
 
 using std::cout;
 
diff --git a/third_party/nix/src/nix-store/graphml.hh b/third_party/nix/src/nix-store/graphml.hh
index 199421acb264..be07904d0fc6 100644
--- a/third_party/nix/src/nix-store/graphml.hh
+++ b/third_party/nix/src/nix-store/graphml.hh
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "types.hh"
+#include "libutil/types.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/nix-store/nix-store.cc b/third_party/nix/src/nix-store/nix-store.cc
index 713439308ae8..a642780b72e8 100644
--- a/third_party/nix/src/nix-store/nix-store.cc
+++ b/third_party/nix/src/nix-store/nix-store.cc
@@ -7,18 +7,18 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include "archive.hh"
-#include "derivations.hh"
-#include "dotgraph.hh"
-#include "globals.hh"
-#include "graphml.hh"
-#include "legacy.hh"
-#include "local-store.hh"
-#include "monitor-fd.hh"
-#include "serve-protocol.hh"
-#include "shared.hh"
-#include "util.hh"
-#include "worker-protocol.hh"
+#include "libmain/shared.hh"
+#include "libstore/derivations.hh"
+#include "libstore/globals.hh"
+#include "libstore/local-store.hh"
+#include "libstore/serve-protocol.hh"
+#include "libstore/worker-protocol.hh"
+#include "libutil/archive.hh"
+#include "libutil/monitor-fd.hh"
+#include "libutil/util.hh"
+#include "nix-store/dotgraph.hh"
+#include "nix-store/graphml.hh"
+#include "nix/legacy.hh"
 
 #if HAVE_SODIUM
 #include <sodium.h>
diff --git a/third_party/nix/src/nix/add-to-store.cc b/third_party/nix/src/nix/add-to-store.cc
index b7fda9c9d390..f99fa30be07f 100644
--- a/third_party/nix/src/nix/add-to-store.cc
+++ b/third_party/nix/src/nix/add-to-store.cc
@@ -1,7 +1,7 @@
-#include "archive.hh"
-#include "command.hh"
-#include "common-args.hh"
-#include "store-api.hh"
+#include "libmain/common-args.hh"
+#include "libstore/store-api.hh"
+#include "libutil/archive.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/build.cc b/third_party/nix/src/nix/build.cc
index 9ab2d27e0fc9..d5bdb7a379a7 100644
--- a/third_party/nix/src/nix/build.cc
+++ b/third_party/nix/src/nix/build.cc
@@ -1,7 +1,7 @@
-#include "command.hh"
-#include "common-args.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libmain/common-args.hh"
+#include "libmain/shared.hh"
+#include "libstore/store-api.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/cat.cc b/third_party/nix/src/nix/cat.cc
index 2d662a453f54..49471100cfd0 100644
--- a/third_party/nix/src/nix/cat.cc
+++ b/third_party/nix/src/nix/cat.cc
@@ -1,7 +1,7 @@
-#include "command.hh"
-#include "fs-accessor.hh"
-#include "nar-accessor.hh"
-#include "store-api.hh"
+#include "libstore/fs-accessor.hh"
+#include "libstore/nar-accessor.hh"
+#include "libstore/store-api.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/command.cc b/third_party/nix/src/nix/command.cc
index 34fcde80033e..f7f183ab0ab7 100644
--- a/third_party/nix/src/nix/command.cc
+++ b/third_party/nix/src/nix/command.cc
@@ -1,9 +1,9 @@
-#include "command.hh"
+#include "nix/command.hh"
 
 #include <utility>
 
-#include "derivations.hh"
-#include "store-api.hh"
+#include "libstore/derivations.hh"
+#include "libstore/store-api.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/nix/command.hh b/third_party/nix/src/nix/command.hh
index c297bfbd38dd..813fdb557d82 100644
--- a/third_party/nix/src/nix/command.hh
+++ b/third_party/nix/src/nix/command.hh
@@ -1,7 +1,7 @@
 #pragma once
 
-#include "args.hh"
-#include "common-eval-args.hh"
+#include "libexpr/common-eval-args.hh"
+#include "libutil/args.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/nix/copy.cc b/third_party/nix/src/nix/copy.cc
index 633fe399b48c..a527d40cfafd 100644
--- a/third_party/nix/src/nix/copy.cc
+++ b/third_party/nix/src/nix/copy.cc
@@ -1,10 +1,10 @@
 #include <atomic>
 
-#include "command.hh"
-#include "shared.hh"
-#include "store-api.hh"
-#include "sync.hh"
-#include "thread-pool.hh"
+#include "libmain/shared.hh"
+#include "libstore/store-api.hh"
+#include "libutil/sync.hh"
+#include "libutil/thread-pool.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/doctor.cc b/third_party/nix/src/nix/doctor.cc
index c7d133fdacf3..3a5cd987a9d6 100644
--- a/third_party/nix/src/nix/doctor.cc
+++ b/third_party/nix/src/nix/doctor.cc
@@ -2,11 +2,11 @@
 #include <absl/strings/str_cat.h>
 #include <absl/strings/str_split.h>
 
-#include "command.hh"
-#include "serve-protocol.hh"
-#include "shared.hh"
-#include "store-api.hh"
-#include "worker-protocol.hh"
+#include "libmain/shared.hh"
+#include "libstore/serve-protocol.hh"
+#include "libstore/store-api.hh"
+#include "libstore/worker-protocol.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/dump-path.cc b/third_party/nix/src/nix/dump-path.cc
index 5e93a3a44b83..d7e8bc69fd91 100644
--- a/third_party/nix/src/nix/dump-path.cc
+++ b/third_party/nix/src/nix/dump-path.cc
@@ -1,5 +1,5 @@
-#include "command.hh"
-#include "store-api.hh"
+#include "libstore/store-api.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/edit.cc b/third_party/nix/src/nix/edit.cc
index 4d5cb382bc48..55b193fb6b7e 100644
--- a/third_party/nix/src/nix/edit.cc
+++ b/third_party/nix/src/nix/edit.cc
@@ -2,10 +2,10 @@
 #include <glog/logging.h>
 #include <unistd.h>
 
-#include "attr-path.hh"
-#include "command.hh"
-#include "eval.hh"
-#include "shared.hh"
+#include "libexpr/attr-path.hh"
+#include "libexpr/eval.hh"
+#include "libmain/shared.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/eval.cc b/third_party/nix/src/nix/eval.cc
index 661d587d7385..5f26aa14c096 100644
--- a/third_party/nix/src/nix/eval.cc
+++ b/third_party/nix/src/nix/eval.cc
@@ -1,11 +1,11 @@
-#include "eval.hh"
-
-#include "command.hh"
-#include "common-args.hh"
-#include "json.hh"
-#include "shared.hh"
-#include "store-api.hh"
-#include "value-to-json.hh"
+#include "libexpr/eval.hh"
+
+#include "libexpr/value-to-json.hh"
+#include "libmain/common-args.hh"
+#include "libmain/shared.hh"
+#include "libstore/store-api.hh"
+#include "libutil/json.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/hash.cc b/third_party/nix/src/nix/hash.cc
index c500dc4f3ca6..935faec9d598 100644
--- a/third_party/nix/src/nix/hash.cc
+++ b/third_party/nix/src/nix/hash.cc
@@ -1,8 +1,8 @@
-#include "hash.hh"
+#include "libutil/hash.hh"
 
-#include "command.hh"
-#include "legacy.hh"
-#include "shared.hh"
+#include "libmain/shared.hh"
+#include "nix/command.hh"
+#include "nix/legacy.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/installables.cc b/third_party/nix/src/nix/installables.cc
index 38a3f0c8ecf6..80c5ddb68b9c 100644
--- a/third_party/nix/src/nix/installables.cc
+++ b/third_party/nix/src/nix/installables.cc
@@ -1,15 +1,15 @@
 #include <regex>
 #include <utility>
 
-#include "attr-path.hh"
-#include "command.hh"
-#include "common-eval-args.hh"
-#include "derivations.hh"
-#include "eval-inline.hh"
-#include "eval.hh"
-#include "get-drvs.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libexpr/attr-path.hh"
+#include "libexpr/common-eval-args.hh"
+#include "libexpr/eval-inline.hh"
+#include "libexpr/eval.hh"
+#include "libexpr/get-drvs.hh"
+#include "libmain/shared.hh"
+#include "libstore/derivations.hh"
+#include "libstore/store-api.hh"
+#include "nix/command.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/nix/legacy.cc b/third_party/nix/src/nix/legacy.cc
index b851392b4276..a0f9fc65b311 100644
--- a/third_party/nix/src/nix/legacy.cc
+++ b/third_party/nix/src/nix/legacy.cc
@@ -1,4 +1,4 @@
-#include "legacy.hh"
+#include "nix/legacy.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/nix/log.cc b/third_party/nix/src/nix/log.cc
index 63d3554cc2fb..b205851ecefc 100644
--- a/third_party/nix/src/nix/log.cc
+++ b/third_party/nix/src/nix/log.cc
@@ -1,9 +1,9 @@
 #include <glog/logging.h>
 
-#include "command.hh"
-#include "common-args.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libmain/common-args.hh"
+#include "libmain/shared.hh"
+#include "libstore/store-api.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/ls.cc b/third_party/nix/src/nix/ls.cc
index 5b052f8fcc7c..aa461675ad25 100644
--- a/third_party/nix/src/nix/ls.cc
+++ b/third_party/nix/src/nix/ls.cc
@@ -1,9 +1,9 @@
-#include "command.hh"
-#include "common-args.hh"
-#include "fs-accessor.hh"
-#include "json.hh"
-#include "nar-accessor.hh"
-#include "store-api.hh"
+#include "libmain/common-args.hh"
+#include "libstore/fs-accessor.hh"
+#include "libstore/nar-accessor.hh"
+#include "libstore/store-api.hh"
+#include "libutil/json.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/main.cc b/third_party/nix/src/nix/main.cc
index 59782388087a..a7b6e71bbe93 100644
--- a/third_party/nix/src/nix/main.cc
+++ b/third_party/nix/src/nix/main.cc
@@ -1,21 +1,21 @@
 #include <algorithm>
 
+#include <glog/logging.h>
 #include <ifaddrs.h>
 #include <netdb.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <sys/types.h>
 
-#include "command.hh"
-#include "common-args.hh"
-#include "download.hh"
-#include "eval.hh"
-#include "finally.hh"
-#include "globals.hh"
-#include "glog/logging.h"
-#include "legacy.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libexpr/eval.hh"
+#include "libmain/common-args.hh"
+#include "libmain/shared.hh"
+#include "libstore/download.hh"
+#include "libstore/globals.hh"
+#include "libstore/store-api.hh"
+#include "libutil/finally.hh"
+#include "nix/command.hh"
+#include "nix/legacy.hh"
 
 extern std::string chrootHelperName;
 
diff --git a/third_party/nix/src/nix/optimise-store.cc b/third_party/nix/src/nix/optimise-store.cc
index 5fdcfb742465..594cc0e637a7 100644
--- a/third_party/nix/src/nix/optimise-store.cc
+++ b/third_party/nix/src/nix/optimise-store.cc
@@ -1,8 +1,8 @@
 #include <atomic>
 
-#include "command.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libmain/shared.hh"
+#include "libstore/store-api.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/path-info.cc b/third_party/nix/src/nix/path-info.cc
index e94dcc962831..aa43ad5262e9 100644
--- a/third_party/nix/src/nix/path-info.cc
+++ b/third_party/nix/src/nix/path-info.cc
@@ -1,11 +1,11 @@
 #include <algorithm>
 #include <array>
 
-#include "command.hh"
-#include "common-args.hh"
-#include "json.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libmain/common-args.hh"
+#include "libmain/shared.hh"
+#include "libstore/store-api.hh"
+#include "libutil/json.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/ping-store.cc b/third_party/nix/src/nix/ping-store.cc
index 9e9ee15c8966..0857733c4258 100644
--- a/third_party/nix/src/nix/ping-store.cc
+++ b/third_party/nix/src/nix/ping-store.cc
@@ -1,6 +1,6 @@
-#include "command.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libmain/shared.hh"
+#include "libstore/store-api.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/repl.cc b/third_party/nix/src/nix/repl.cc
index f6261cfeccc7..65a22382b248 100644
--- a/third_party/nix/src/nix/repl.cc
+++ b/third_party/nix/src/nix/repl.cc
@@ -24,17 +24,17 @@ extern "C" {
 }
 #endif
 
-#include "affinity.hh"
-#include "command.hh"
-#include "common-eval-args.hh"
-#include "derivations.hh"
-#include "eval-inline.hh"
-#include "eval.hh"
-#include "finally.hh"
-#include "get-drvs.hh"
-#include "globals.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libexpr/common-eval-args.hh"
+#include "libexpr/eval-inline.hh"
+#include "libexpr/eval.hh"
+#include "libexpr/get-drvs.hh"
+#include "libmain/shared.hh"
+#include "libstore/derivations.hh"
+#include "libstore/globals.hh"
+#include "libstore/store-api.hh"
+#include "libutil/affinity.hh"
+#include "libutil/finally.hh"
+#include "nix/command.hh"
 
 namespace nix {
 
diff --git a/third_party/nix/src/nix/run.cc b/third_party/nix/src/nix/run.cc
index 47103e8db3cd..b1ca56d7516c 100644
--- a/third_party/nix/src/nix/run.cc
+++ b/third_party/nix/src/nix/run.cc
@@ -3,15 +3,15 @@
 #include <absl/strings/str_split.h>
 #include <sys/mount.h>
 
-#include "affinity.hh"
-#include "command.hh"
-#include "common-args.hh"
-#include "derivations.hh"
-#include "finally.hh"
-#include "fs-accessor.hh"
-#include "local-store.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libmain/common-args.hh"
+#include "libmain/shared.hh"
+#include "libstore/derivations.hh"
+#include "libstore/fs-accessor.hh"
+#include "libstore/local-store.hh"
+#include "libstore/store-api.hh"
+#include "libutil/affinity.hh"
+#include "libutil/finally.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/search.cc b/third_party/nix/src/nix/search.cc
index 9f03fc6f3202..350863cf811c 100644
--- a/third_party/nix/src/nix/search.cc
+++ b/third_party/nix/src/nix/search.cc
@@ -3,16 +3,16 @@
 
 #include <glog/logging.h>
 
-#include "command.hh"
-#include "common-args.hh"
-#include "eval-inline.hh"
-#include "eval.hh"
-#include "get-drvs.hh"
-#include "globals.hh"
-#include "json-to-value.hh"
-#include "json.hh"
-#include "names.hh"
-#include "shared.hh"
+#include "libexpr/eval-inline.hh"
+#include "libexpr/eval.hh"
+#include "libexpr/get-drvs.hh"
+#include "libexpr/json-to-value.hh"
+#include "libexpr/names.hh"
+#include "libmain/common-args.hh"
+#include "libmain/shared.hh"
+#include "libstore/globals.hh"
+#include "libutil/json.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/show-config.cc b/third_party/nix/src/nix/show-config.cc
index 51f02ed61bbe..8e27fd168f64 100644
--- a/third_party/nix/src/nix/show-config.cc
+++ b/third_party/nix/src/nix/show-config.cc
@@ -1,8 +1,8 @@
-#include "command.hh"
-#include "common-args.hh"
-#include "json.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libmain/common-args.hh"
+#include "libmain/shared.hh"
+#include "libstore/store-api.hh"
+#include "libutil/json.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/show-derivation.cc b/third_party/nix/src/nix/show-derivation.cc
index b821a9ee1205..2a6252f931c6 100644
--- a/third_party/nix/src/nix/show-derivation.cc
+++ b/third_party/nix/src/nix/show-derivation.cc
@@ -1,11 +1,11 @@
 // FIXME: integrate this with nix path-info?
 
-#include "archive.hh"
-#include "command.hh"
-#include "common-args.hh"
-#include "derivations.hh"
-#include "json.hh"
-#include "store-api.hh"
+#include "libmain/common-args.hh"
+#include "libstore/derivations.hh"
+#include "libstore/store-api.hh"
+#include "libutil/archive.hh"
+#include "libutil/json.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/sigs.cc b/third_party/nix/src/nix/sigs.cc
index 420296a8023f..8df1beef2b5c 100644
--- a/third_party/nix/src/nix/sigs.cc
+++ b/third_party/nix/src/nix/sigs.cc
@@ -2,10 +2,10 @@
 
 #include <glog/logging.h>
 
-#include "command.hh"
-#include "shared.hh"
-#include "store-api.hh"
-#include "thread-pool.hh"
+#include "libmain/shared.hh"
+#include "libstore/store-api.hh"
+#include "libutil/thread-pool.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/upgrade-nix.cc b/third_party/nix/src/nix/upgrade-nix.cc
index 174cc1f1fc6d..1d85af03c16a 100644
--- a/third_party/nix/src/nix/upgrade-nix.cc
+++ b/third_party/nix/src/nix/upgrade-nix.cc
@@ -3,13 +3,13 @@
 #include <absl/strings/str_split.h>
 #include <glog/logging.h>
 
-#include "attr-path.hh"
-#include "command.hh"
-#include "common-args.hh"
-#include "download.hh"
-#include "eval.hh"
-#include "names.hh"
-#include "store-api.hh"
+#include "libexpr/attr-path.hh"
+#include "libexpr/eval.hh"
+#include "libexpr/names.hh"
+#include "libmain/common-args.hh"
+#include "libstore/download.hh"
+#include "libstore/store-api.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/verify.cc b/third_party/nix/src/nix/verify.cc
index a773b3a2c8de..f5f222915eb9 100644
--- a/third_party/nix/src/nix/verify.cc
+++ b/third_party/nix/src/nix/verify.cc
@@ -2,11 +2,11 @@
 
 #include <glog/logging.h>
 
-#include "command.hh"
-#include "shared.hh"
-#include "store-api.hh"
-#include "sync.hh"
-#include "thread-pool.hh"
+#include "libmain/shared.hh"
+#include "libstore/store-api.hh"
+#include "libutil/sync.hh"
+#include "libutil/thread-pool.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/src/nix/why-depends.cc b/third_party/nix/src/nix/why-depends.cc
index 9c5eaf737c03..4fb91c9d9192 100644
--- a/third_party/nix/src/nix/why-depends.cc
+++ b/third_party/nix/src/nix/why-depends.cc
@@ -2,10 +2,10 @@
 
 #include <glog/logging.h>
 
-#include "command.hh"
-#include "fs-accessor.hh"
-#include "shared.hh"
-#include "store-api.hh"
+#include "libmain/shared.hh"
+#include "libstore/fs-accessor.hh"
+#include "libstore/store-api.hh"
+#include "nix/command.hh"
 
 using namespace nix;
 
diff --git a/third_party/nix/tests/plugins/plugintest.cc b/third_party/nix/tests/plugins/plugintest.cc
index 5edd28bd099c..353166cffe3b 100644
--- a/third_party/nix/tests/plugins/plugintest.cc
+++ b/third_party/nix/tests/plugins/plugintest.cc
@@ -1,4 +1,4 @@
-#include "config.hh"
+#include "libutil/config.hh"
 #include "primops.hh"
 
 using namespace nix;