about summary refs log tree commit diff
path: root/third_party/nix/src
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/src')
-rw-r--r--third_party/nix/src/CMakeLists.txt80
-rw-r--r--third_party/nix/src/libexpr/CMakeLists.txt75
-rw-r--r--third_party/nix/src/libmain/CMakeLists.txt25
-rw-r--r--third_party/nix/src/libstore/CMakeLists.txt102
-rw-r--r--third_party/nix/src/libstore/local-store.cc9
-rw-r--r--third_party/nix/src/libutil/CMakeLists.txt53
6 files changed, 338 insertions, 6 deletions
diff --git a/third_party/nix/src/CMakeLists.txt b/third_party/nix/src/CMakeLists.txt
new file mode 100644
index 0000000000..37ff3b54af
--- /dev/null
+++ b/third_party/nix/src/CMakeLists.txt
@@ -0,0 +1,80 @@
+# -*- mode: cmake; -*-
+
+# The 'nix' binary is composed of various sources below this
+# directory. In the previous build system, they were all built from
+# this location and this setup mimics that (with the exception of the
+# various Nix libraries).
+
+add_subdirectory(libutil)
+add_subdirectory(libstore)
+add_subdirectory(libmain)
+add_subdirectory(libexpr)
+
+add_executable(nix)
+set_property(TARGET nix PROPERTY CXX_STANDARD 17)
+include_directories(${PROJECT_BINARY_DIR})
+target_include_directories(nix PUBLIC "${nix_SOURCE_DIR}/src")
+
+target_sources(nix
+  PRIVATE
+    nix/command.hh
+    nix/legacy.hh
+    nix-env/user-env.hh
+    nix-store/dotgraph.hh
+    nix-store/graphml.hh
+
+    nix/add-to-store.cc
+    nix/build.cc
+    nix/cat.cc
+    nix/command.cc
+    nix/copy.cc
+    nix/doctor.cc
+    nix/dump-path.cc
+    nix/edit.cc
+    nix/eval.cc
+    nix/hash.cc
+    nix/installables.cc
+    nix/legacy.cc
+    nix/log.cc
+    nix/ls.cc
+    nix/main.cc
+    nix/optimise-store.cc
+    nix/path-info.cc
+    nix/ping-store.cc
+    nix/repl.cc
+    nix/run.cc
+    nix/search.cc
+    nix/show-config.cc
+    nix/show-derivation.cc
+    nix/sigs.cc
+    nix/upgrade-nix.cc
+    nix/verify.cc
+    nix/why-depends.cc
+
+    build-remote/build-remote.cc
+    nix-build/nix-build.cc
+    nix-channel/nix-channel.cc
+    nix-collect-garbage/nix-collect-garbage.cc
+    nix-copy-closure/nix-copy-closure.cc
+    nix-daemon/nix-daemon.cc
+    nix-env/nix-env.cc
+    nix-env/user-env.cc
+    nix-instantiate/nix-instantiate.cc
+    nix-prefetch-url/nix-prefetch-url.cc
+    nix-store/dotgraph.cc
+    nix-store/graphml.cc
+    nix-store/nix-store.cc
+)
+
+target_link_libraries(nix
+  nixexpr
+  nixmain
+  nixstore
+  nixutil
+
+  absl::strings
+  editline
+  glog
+)
+
+INSTALL(TARGETS nix DESTINATION bin)
diff --git a/third_party/nix/src/libexpr/CMakeLists.txt b/third_party/nix/src/libexpr/CMakeLists.txt
new file mode 100644
index 0000000000..3456052ea9
--- /dev/null
+++ b/third_party/nix/src/libexpr/CMakeLists.txt
@@ -0,0 +1,75 @@
+# -*- mode: cmake; -*-
+add_library(nixexpr SHARED)
+set_property(TARGET nixexpr PROPERTY CXX_STANDARD 17)
+include_directories(${PROJECT_BINARY_DIR}) # for 'generated/'
+target_include_directories(nixexpr PUBLIC "${nix_SOURCE_DIR}/src")
+
+# Generate lexer & parser for inclusion:
+find_package(BISON)
+find_package(FLEX)
+
+BISON_TARGET(NixParser parser.y
+  ${PROJECT_BINARY_DIR}/generated/parser-tab.cc
+  DEFINES_FILE ${PROJECT_BINARY_DIR}/generated/parser-tab.hh)
+
+FLEX_TARGET(NixLexer lexer.l
+  ${PROJECT_BINARY_DIR}/generated/lexer-tab.cc
+  DEFINES_FILE ${PROJECT_BINARY_DIR}/generated/lexer-tab.hh)
+
+ADD_FLEX_BISON_DEPENDENCY(NixLexer NixParser)
+
+target_sources(nixexpr
+  PUBLIC
+    attr-path.hh
+    attr-set.hh
+    common-eval-args.hh
+    eval.hh
+    eval-inline.hh
+    function-trace.hh
+    get-drvs.hh
+    json-to-value.hh
+    names.hh
+    nixexpr.hh
+    primops.hh
+    symbol-table.hh
+    value.hh
+    value-to-json.hh
+    value-to-xml.hh
+
+  PRIVATE
+    ${PROJECT_BINARY_DIR}/generated/parser-tab.hh
+    ${PROJECT_BINARY_DIR}/generated/parser-tab.cc
+    ${PROJECT_BINARY_DIR}/generated/lexer-tab.hh
+    ${PROJECT_BINARY_DIR}/generated/lexer-tab.cc
+    primops/context.cc
+    primops/fetchGit.cc
+    primops/fetchMercurial.cc
+    primops/fromTOML.cc
+    attr-path.cc
+    attr-set.cc
+    common-eval-args.cc
+    eval.cc
+    function-trace.cc
+    get-drvs.cc
+    json-to-value.cc
+    names.cc
+    nixexpr.cc
+    primops.cc
+    symbol-table.cc
+    value-to-json.cc
+    value-to-xml.cc
+)
+
+target_link_libraries(nixexpr
+  nixmain
+  nixstore
+  nixutil
+
+  absl::btree
+  absl::node_hash_set
+  absl::strings
+  gc
+  gccpp
+)
+
+INSTALL(TARGETS nixexpr DESTINATION lib)
diff --git a/third_party/nix/src/libmain/CMakeLists.txt b/third_party/nix/src/libmain/CMakeLists.txt
new file mode 100644
index 0000000000..825e8ee5d6
--- /dev/null
+++ b/third_party/nix/src/libmain/CMakeLists.txt
@@ -0,0 +1,25 @@
+# -*- mode: cmake; -*-
+add_library(nixmain SHARED)
+set_property(TARGET nixmain PROPERTY CXX_STANDARD 17)
+include_directories(${PROJECT_BINARY_DIR}) # for config.h
+target_include_directories(nixmain PUBLIC "${nix_SOURCE_DIR}/src")
+
+target_sources(nixmain
+  PUBLIC
+    common-args.hh
+    shared.hh
+  PRIVATE
+    common-args.cc
+    shared.cc
+    stack.cc
+)
+
+target_link_libraries(nixmain
+  nixstore
+  nixutil
+
+  absl::strings
+  glog
+)
+
+INSTALL(TARGETS nixmain DESTINATION lib)
diff --git a/third_party/nix/src/libstore/CMakeLists.txt b/third_party/nix/src/libstore/CMakeLists.txt
new file mode 100644
index 0000000000..21adb0fb02
--- /dev/null
+++ b/third_party/nix/src/libstore/CMakeLists.txt
@@ -0,0 +1,102 @@
+# -*- mode: cmake; -*-
+add_library(nixstore SHARED)
+set_property(TARGET nixstore PROPERTY CXX_STANDARD 17)
+include_directories(${PROJECT_BINARY_DIR}) # for config.h
+target_include_directories(nixstore PUBLIC "${nix_SOURCE_DIR}/src")
+
+# The database schema is stored in schema.sql, but needs to be
+# available during the build as static data.
+#
+# These commands create an includeable source-file out of it.
+file(READ "schema.sql" NIX_SCHEMA)
+
+string(CONFIGURE
+  "#pragma once
+   namespace nix {
+   constexpr char kNixSqlSchema[] = R\"(${NIX_SCHEMA})\"\;
+   }"
+  NIX_SCHEMA_GEN)
+
+file(WRITE ${PROJECT_BINARY_DIR}/generated/schema.sql.hh ${NIX_SCHEMA_GEN})
+
+target_sources(nixstore
+  PUBLIC
+    binary-cache-store.hh
+    builtins.hh
+    crypto.hh
+    derivations.hh
+    download.hh
+    fs-accessor.hh
+    globals.hh
+    local-store.hh
+    machines.hh
+    nar-accessor.hh
+    nar-info-disk-cache.hh
+    nar-info.hh
+    parsed-derivations.hh
+    pathlocks.hh
+    profiles.hh
+    references.hh
+    remote-fs-accessor.hh
+    remote-store.hh
+    s3-binary-cache-store.hh
+    s3.hh
+    serve-protocol.hh
+    sqlite.hh
+    ssh.hh
+    store-api.hh
+    worker-protocol.hh
+
+  PRIVATE
+    ${PROJECT_BINARY_DIR}/generated/schema.sql.hh
+    binary-cache-store.cc
+    build.cc
+    crypto.cc
+    derivations.cc
+    download.cc
+    export-import.cc
+    gc.cc
+    globals.cc
+    http-binary-cache-store.cc
+    legacy-ssh-store.cc
+    local-binary-cache-store.cc
+    local-fs-store.cc
+    local-store.cc
+    machines.cc
+    misc.cc
+    nar-accessor.cc
+    nar-info.cc
+    nar-info-disk-cache.cc
+    optimise-store.cc
+    parsed-derivations.cc
+    pathlocks.cc
+    profiles.cc
+    references.cc
+    remote-fs-accessor.cc
+    remote-store.cc
+    s3-binary-cache-store.cc
+    sqlite.cc
+    ssh.cc
+    ssh-store.cc
+    store-api.cc
+    builtins/buildenv.cc
+    builtins/fetchurl.cc
+)
+
+target_link_libraries(nixstore
+  nixutil
+
+  BZip2::BZip2
+  Boost::context
+  CURL::libcurl
+  LibLZMA::LibLZMA
+  SQLite::SQLite3
+  absl::strings
+  brotlidec
+  brotlienc
+  glog
+  seccomp
+  sodium
+)
+
+INSTALL(TARGETS nixstore DESTINATION lib)
diff --git a/third_party/nix/src/libstore/local-store.cc b/third_party/nix/src/libstore/local-store.cc
index f9d03c520a..2f35dd69c4 100644
--- a/third_party/nix/src/libstore/local-store.cc
+++ b/third_party/nix/src/libstore/local-store.cc
@@ -374,10 +374,7 @@ void LocalStore::openDB(State& state, bool create) {
 
   /* Initialise the database schema, if necessary. */
   if (create) {
-    const char* schema =
-#include "schema.sql.gen.hh"
-        ;
-    db.exec(schema);
+    db.exec(kNixSqlSchema);
   }
 }
 
@@ -435,13 +432,13 @@ static void canonicaliseTimestampAndPermissions(const Path& path,
       if (errno != ENOSYS ||
           (!S_ISLNK(st.st_mode) && utimes(path.c_str(), times) == -1)) {
 #else
-    if (!S_ISLNK(st.st_mode) && utimes(path.c_str(), times) == -1)
+    if (!S_ISLNK(st.st_mode) && utimes(path.c_str(), times) == -1) {
 #endif
         throw SysError(format("changing modification time of '%1%'") % path);
       }
     }
   }  // namespace nix
-}
+}  // namespace nix
 
 void canonicaliseTimestampAndPermissions(const Path& path) {
   struct stat st;
diff --git a/third_party/nix/src/libutil/CMakeLists.txt b/third_party/nix/src/libutil/CMakeLists.txt
new file mode 100644
index 0000000000..2aa513a395
--- /dev/null
+++ b/third_party/nix/src/libutil/CMakeLists.txt
@@ -0,0 +1,53 @@
+# -*- mode: cmake; -*-
+add_library(nixutil SHARED)
+set_property(TARGET nixutil PROPERTY CXX_STANDARD 17)
+include_directories(${PROJECT_BINARY_DIR}) # for config.h
+target_compile_features(nixutil PUBLIC cxx_std_17)
+
+target_sources(nixutil
+  PUBLIC
+    affinity.hh
+    archive.hh
+    args.hh
+    compression.hh
+    config.hh
+    finally.hh
+    hash.hh
+    istringstream_nocopy.hh
+    json.hh
+    lazy.hh
+    lru-cache.hh
+    monitor-fd.hh
+    pool.hh
+    prefork-compat.hh
+    ref.hh
+    serialise.hh
+    sync.hh
+    thread-pool.hh
+    types.hh
+    util.hh
+    xml-writer.hh
+
+  PRIVATE
+    affinity.cc
+    archive.cc
+    args.cc
+    compression.cc
+    config.cc
+    hash.cc
+    json.cc
+    serialise.cc
+    thread-pool.cc
+    util.cc
+    xml-writer.cc
+)
+
+target_link_libraries(nixutil
+  absl::strings
+  glog
+)
+
+# Install header files to include/libutil and mark them for automatic
+# inclusion in targets that link to this one.
+target_include_directories(nixutil PUBLIC "${nix_SOURCE_DIR}/src")
+INSTALL(TARGETS nixutil DESTINATION lib)