aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore129
-rw-r--r--misc/pre-commit.nix9
-rw-r--r--package.nix6
-rw-r--r--src/build-remote/build-remote.cc19
-rw-r--r--src/libcmd/meson.build1
-rw-r--r--src/libexpr/meson.build1
-rw-r--r--src/libfetchers/meson.build1
-rw-r--r--src/libmain/meson.build1
-rw-r--r--src/libstore/local-store.cc7
-rw-r--r--src/libstore/meson.build1
-rw-r--r--src/libutil/args.cc2
-rw-r--r--src/libutil/args.hh7
-rw-r--r--src/libutil/args/root.hh4
-rw-r--r--src/libutil/meson.build1
-rw-r--r--src/nix/meson.build1
-rw-r--r--src/pch/precompiled-headers.hh (renamed from precompiled-headers.h)0
-rw-r--r--tests/unit/meson.build6
17 files changed, 56 insertions, 140 deletions
diff --git a/.gitignore b/.gitignore
index 4d921d97f..816a8e4b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,128 +1,5 @@
-Makefile.config
-perl/Makefile.config
-
-# /
-/aclocal.m4
-/autom4te.cache
-/precompiled-headers.h.gch
-/config.*
-/configure
-/stamp-h1
-/svn-revision
-/libtool
-/config
-
-# /doc/manual/
-/doc/manual/*.1
-/doc/manual/*.5
-/doc/manual/*.8
-/doc/manual/generated/*
-/doc/manual/nix.json
-/doc/manual/conf-file.json
-/doc/manual/language.json
-/doc/manual/xp-features.json
-/doc/manual/src/command-ref/experimental-features-shortlist.md
-/doc/manual/src/contributing/experimental-feature-descriptions.md
-/doc/manual/src/release-notes/rl-next-generated.md
-
-# /scripts/
-/scripts/nix-profile.sh
-/scripts/nix-profile-daemon.sh
-/scripts/nix-profile.fish
-/scripts/nix-profile-daemon.fish
-
-# /src/libexpr/
-/src/libexpr/lexer-tab.cc
-/src/libexpr/lexer-tab.hh
-/src/libexpr/parser-tab.cc
-/src/libexpr/parser-tab.hh
-/src/libexpr/parser-tab.output
-/src/libexpr/nix.tbl
-/src/libexpr/tests
-/tests/unit/libexpr/libnixexpr-tests
-
-# /src/libstore/
-*.gen.*
-/src/libstore/tests
-/tests/unit/libstore/libnixstore-tests
-
-# /src/libutil/
-/src/libutil/tests
-/tests/unit/libutil/libnixutil-tests
-
-/src/nix/nix
-
-/src/nix/doc
-
-# /src/nix-env/
-/src/nix-env/nix-env
-
-# /src/nix-instantiate/
-/src/nix-instantiate/nix-instantiate
-
-# /src/nix-store/
-/src/nix-store/nix-store
-
-/src/nix-prefetch-url/nix-prefetch-url
-
-/src/nix-collect-garbage/nix-collect-garbage
-
-# /src/nix-channel/
-/src/nix-channel/nix-channel
-
-# /src/nix-build/
-/src/nix-build/nix-build
-
-/src/nix-copy-closure/nix-copy-closure
-
-/src/error-demo/error-demo
-
-/src/build-remote/build-remote
-
-# /tests/functional/
-/tests/functional/test-tmp
-/tests/functional/common/vars-and-functions.sh
-/tests/functional/result*
-/tests/functional/restricted-innocent
-/tests/functional/shell
-/tests/functional/shell.drv
-/tests/functional/config.nix
-/tests/functional/ca/config.nix
-/tests/functional/dyn-drv/config.nix
-/tests/functional/repl-result-out
-/tests/functional/debugger-test-out
-/tests/functional/test-libstoreconsumer/test-libstoreconsumer
-
-# /tests/functional/lang/
-/tests/functional/lang/*.out
-/tests/functional/lang/*.out.xml
-/tests/functional/lang/*.err
-/tests/functional/lang/*.ast
-
-/perl/lib/Nix/Config.pm
-/perl/lib/Nix/Store.cc
-
-/misc/systemd/nix-daemon.service
-/misc/systemd/nix-daemon.socket
-/misc/systemd/nix-daemon.conf
-/misc/upstart/nix-daemon.conf
-
-/src/resolve-system-dependencies/resolve-system-dependencies
-
outputs/
-*.a
-*.o
-*.o.tmp
-*.so
-*.dylib
-*.dll
-*.exe
-*.dep
-*~
-*.pc
-*.plist
-
# GNU Global
GPATH
GRTAGS
@@ -132,17 +9,11 @@ GTAGS
# ccls
/.ccls-cache
-# auto-generated compilation database
-compile_commands.json
-
-nix-rust/target
-
result
result-*
.vscode/
.direnv/
-.envrc.local
# clangd and possibly more
.cache/
diff --git a/misc/pre-commit.nix b/misc/pre-commit.nix
index ed2b152a3..4f54141b3 100644
--- a/misc/pre-commit.nix
+++ b/misc/pre-commit.nix
@@ -87,11 +87,12 @@ pre-commit-run {
"file"
"header"
];
- # generated files; these will never actually be seen by this
- # check, and are left here as documentation
excludes = [
- "(parser|lexer)-tab\\.hh$"
- "\\.gen\\.hh$"
+ ''^src/pch/.*$''
+ # generated files; these will never actually be seen by this
+ # check, and are left here as documentation
+ ''(parser|lexer)-tab\.hh$''
+ ''\.gen\.hh$''
];
entry = lib.getExe pkgs.check-headers;
};
diff --git a/package.nix b/package.nix
index 6251b28ba..43b709023 100644
--- a/package.nix
+++ b/package.nix
@@ -169,7 +169,6 @@ stdenv.mkDerivation (finalAttrs: {
./boehmgc-coroutine-sp-fallback.diff
./doc
./misc
- ./precompiled-headers.h
./src
./COPYING
]
@@ -449,7 +448,10 @@ stdenv.mkDerivation (finalAttrs: {
shellHook = ''
# don't re-run the hook in (other) nested nix-shells
function lixShellHook() {
- if [[ $name != lix-shell-env ]]; then
+ # n.b. how the heck does this become -env-env? well, `nix develop` does it:
+ # https://git.lix.systems/lix-project/lix/src/commit/7575db522e9008685c4009423398f6900a16bcce/src/nix/develop.cc#L240-L241
+ # this is, of course, absurd.
+ if [[ $name != lix-shell-env && $name != lix-shell-env-env ]]; then
return;
fi
diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc
index f7a159829..fb90403a0 100644
--- a/src/build-remote/build-remote.cc
+++ b/src/build-remote/build-remote.cc
@@ -3,6 +3,7 @@
#include <algorithm>
#include <set>
#include <memory>
+#include <string_view>
#include <tuple>
#include <iomanip>
#if __APPLE__
@@ -20,9 +21,9 @@
#include "local-store.hh"
#include "legacy.hh"
#include "experimental-features.hh"
+#include "hash.hh"
using namespace nix;
-using std::cin;
static void handleAlarm(int sig) {
}
@@ -35,9 +36,19 @@ std::string escapeUri(std::string uri)
static std::string currentLoad;
+static std::string makeLockFilename(const std::string & storeUri) {
+ // We include 48 bytes of escaped URI to give an idea of what the lock
+ // is on, then 16 bytes of hash to disambiguate.
+ // This avoids issues with the escaped URI being very long and causing
+ // path too long errors, while also avoiding any possibility of collision
+ // caused by simple truncation.
+ auto hash = hashString(HashType::htSHA256, storeUri).to_string(Base::Base32, false);
+ return escapeUri(storeUri).substr(0, 48) + "-" + hash.substr(0, 16);
+}
+
static AutoCloseFD openSlotLock(const Machine & m, uint64_t slot)
{
- return openLockFile(fmt("%s/%s-%d", currentLoad, escapeUri(m.storeUri), slot), true);
+ return openLockFile(fmt("%s/%s-%d", currentLoad, makeLockFilename(m.storeUri), slot), true);
}
static bool allSupportedLocally(Store & store, const std::set<std::string>& requiredFeatures) {
@@ -263,7 +274,9 @@ connected:
auto inputs = readStrings<PathSet>(source);
auto wantedOutputs = readStrings<StringSet>(source);
- AutoCloseFD uploadLock = openLockFile(currentLoad + "/" + escapeUri(storeUri) + ".upload-lock", true);
+ auto lockFileName = currentLoad + "/" + makeLockFilename(storeUri) + ".upload-lock";
+
+ AutoCloseFD uploadLock = openLockFile(lockFileName, true);
{
Activity act(*logger, lvlTalkative, actUnknown, fmt("waiting for the upload lock to '%s'", storeUri));
diff --git a/src/libcmd/meson.build b/src/libcmd/meson.build
index 4da1b496b..4dc0714c8 100644
--- a/src/libcmd/meson.build
+++ b/src/libcmd/meson.build
@@ -54,6 +54,7 @@ libcmd = library(
nlohmann_json,
lix_doc
],
+ cpp_pch : ['../pch/precompiled-headers.hh'],
install : true,
# FIXME(Qyriad): is this right?
install_rpath : libdir,
diff --git a/src/libexpr/meson.build b/src/libexpr/meson.build
index fda6fde2c..9a18c7ab3 100644
--- a/src/libexpr/meson.build
+++ b/src/libexpr/meson.build
@@ -145,6 +145,7 @@ libexpr = library(
include_directories : [
'../libmain',
],
+ cpp_pch : ['../pch/precompiled-headers.hh'],
install : true,
# FIXME(Qyriad): is this right?
install_rpath : libdir,
diff --git a/src/libfetchers/meson.build b/src/libfetchers/meson.build
index dbb85b84c..365bcd4a7 100644
--- a/src/libfetchers/meson.build
+++ b/src/libfetchers/meson.build
@@ -30,6 +30,7 @@ libfetchers = library(
liblixutil,
nlohmann_json,
],
+ cpp_pch : ['../pch/precompiled-headers.hh'],
install : true,
# FIXME(Qyriad): is this right?
install_rpath : libdir,
diff --git a/src/libmain/meson.build b/src/libmain/meson.build
index b17247a9d..075aa83b2 100644
--- a/src/libmain/meson.build
+++ b/src/libmain/meson.build
@@ -20,6 +20,7 @@ libmain = library(
liblixutil,
liblixstore,
],
+ cpp_pch : ['../pch/precompiled-headers.hh'],
install : true,
# FIXME(Qyriad): is this right?
install_rpath : libdir,
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 7bcbe3298..d92fafa1b 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -550,7 +550,12 @@ void LocalStore::openDB(State & state, bool create)
if (mode == "wal" ) {
/* persist the WAL files when the DB connection is closed.
* This allows for read-only connections without any write permissions
- * on the state directory to succeed on a closed database. */
+ * on the state directory to succeed on a closed database. Setting the
+ * journal_size_limit to 2^40 bytes results in the WAL files getting
+ * truncated to 0 on exit and limits the on disk size of the WAL files
+ * to 2^40 bytes following a checkpoint */
+ if (sqlite3_exec(db, "pragma main.journal_size_limit = 1099511627776;", 0, 0, 0) != SQLITE_OK)
+ SQLiteError::throw_(db, "setting journal_size_limit");
int enable = 1;
if (sqlite3_file_control(db, NULL, SQLITE_FCNTL_PERSIST_WAL, &enable) != SQLITE_OK)
SQLiteError::throw_(db, "setting persistent WAL mode");
diff --git a/src/libstore/meson.build b/src/libstore/meson.build
index f776e9621..65ecacc20 100644
--- a/src/libstore/meson.build
+++ b/src/libstore/meson.build
@@ -220,6 +220,7 @@ libstore = library(
nlohmann_json,
],
cpp_args : cpp_args,
+ cpp_pch : ['../pch/precompiled-headers.hh'],
install : true,
# FIXME(Qyriad): is this right?
install_rpath : libdir,
diff --git a/src/libutil/args.cc b/src/libutil/args.cc
index 655b3e82f..1342e7c6a 100644
--- a/src/libutil/args.cc
+++ b/src/libutil/args.cc
@@ -64,7 +64,7 @@ RootArgs & Args::getRoot()
while (p->parent)
p = p->parent;
- auto * res = dynamic_cast<RootArgs *>(p);
+ auto res = p->asRootArgs();
assert(res);
return *res;
}
diff --git a/src/libutil/args.hh b/src/libutil/args.hh
index 35a5238c0..71f8f88fa 100644
--- a/src/libutil/args.hh
+++ b/src/libutil/args.hh
@@ -244,6 +244,13 @@ protected:
*/
virtual void initialFlagsProcessed() {}
+ /**
+ * Returns this Args as a RootArgs if it is one, or \ref std::nullopt otherwise.
+ */
+ virtual std::optional<std::reference_wrapper<RootArgs>> asRootArgs() {
+ return std::nullopt;
+ }
+
public:
void addFlag(Flag && flag);
diff --git a/src/libutil/args/root.hh b/src/libutil/args/root.hh
index f8124eaff..499ee6df4 100644
--- a/src/libutil/args/root.hh
+++ b/src/libutil/args/root.hh
@@ -65,6 +65,10 @@ protected:
*/
std::set<ExperimentalFeature> flagExperimentalFeatures;
+ virtual std::optional<std::reference_wrapper<RootArgs>> asRootArgs() override {
+ return *this;
+ }
+
private:
std::optional<std::string> needsCompletion(std::string_view s);
diff --git a/src/libutil/meson.build b/src/libutil/meson.build
index 96450fbe2..cfdd0e52c 100644
--- a/src/libutil/meson.build
+++ b/src/libutil/meson.build
@@ -129,6 +129,7 @@ libutil = library(
openssl,
nlohmann_json,
],
+ cpp_pch : ['../pch/precompiled-headers.hh'],
implicit_include_directories : true,
install : true,
)
diff --git a/src/nix/meson.build b/src/nix/meson.build
index e41399b5d..45303641f 100644
--- a/src/nix/meson.build
+++ b/src/nix/meson.build
@@ -89,6 +89,7 @@ nix = executable(
boehm,
nlohmann_json,
],
+ cpp_pch : ['../pch/precompiled-headers.hh'],
install : true,
# FIXME(Qyriad): is this right?
install_rpath : libdir,
diff --git a/precompiled-headers.h b/src/pch/precompiled-headers.hh
index f52f1cab8..f52f1cab8 100644
--- a/precompiled-headers.h
+++ b/src/pch/precompiled-headers.hh
diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index 35a11a5d3..d8d4a00d1 100644
--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -68,6 +68,7 @@ libutil_tester = executable(
liblixutil_test_support,
nlohmann_json,
],
+ cpp_pch : ['../../src/pch/precompiled-headers.hh'],
)
test(
@@ -102,6 +103,7 @@ libstore_test_support = library(
include_directories : include_directories(
'libstore-support',
),
+ cpp_pch : ['../../src/pch/precompiled-headers.hh'],
)
liblixstore_test_support = declare_dependency(
include_directories : include_directories('libstore-support'),
@@ -135,6 +137,7 @@ libstore_tester = executable(
gtest,
nlohmann_json,
],
+ cpp_pch : ['../../src/pch/precompiled-headers.hh'],
)
test(
@@ -166,6 +169,7 @@ libexpr_test_support = library(
include_directories : include_directories(
'libexpr-support',
),
+ cpp_pch : ['../../src/pch/precompiled-headers.hh'],
)
liblixexpr_test_support = declare_dependency(
include_directories : include_directories('libexpr-support'),
@@ -199,6 +203,7 @@ libexpr_tester = executable(
gtest,
nlohmann_json,
],
+ cpp_pch : ['../../src/pch/precompiled-headers.hh'],
)
test(
@@ -225,6 +230,7 @@ libcmd_tester = executable(
gtest,
boost,
],
+ cpp_pch : ['../../src/pch/precompiled-headers.hh'],
)
test(