mirror of
https://github.com/NixOS/nix
synced 2025-07-07 01:51:47 +02:00
Merge remote-tracking branch 'origin/master' into flakes
This commit is contained in:
commit
cc218b15ba
26 changed files with 1295 additions and 59 deletions
|
@ -112,7 +112,10 @@ GitInfo exportGit(ref<Store> store, std::string uri,
|
|||
runProgram("git", true, { "init", "--bare", repoDir });
|
||||
}
|
||||
|
||||
Path localRefFile = repoDir + "/refs/heads/" + *ref;
|
||||
Path localRefFile =
|
||||
ref->compare(0, 5, "refs/") == 0
|
||||
? cacheDir + "/" + *ref
|
||||
: cacheDir + "/refs/heads/" + *ref;
|
||||
|
||||
bool doFetch;
|
||||
time_t now = time(0);
|
||||
|
|
|
@ -266,6 +266,12 @@ public:
|
|||
/* Set if at least one derivation had a timeout. */
|
||||
bool timedOut;
|
||||
|
||||
/* Set if at least one derivation fails with a hash mismatch. */
|
||||
bool hashMismatch;
|
||||
|
||||
/* Set if at least one derivation is not deterministic in check mode. */
|
||||
bool checkMismatch;
|
||||
|
||||
LocalStore & store;
|
||||
|
||||
std::unique_ptr<HookInstance> hook;
|
||||
|
@ -3213,6 +3219,7 @@ void DerivationGoal::registerOutputs()
|
|||
|
||||
/* Throw an error after registering the path as
|
||||
valid. */
|
||||
worker.hashMismatch = true;
|
||||
delayedException = std::make_exception_ptr(
|
||||
BuildError("hash mismatch in fixed-output derivation '%s':\n wanted: %s\n got: %s",
|
||||
dest, h.to_string(SRI), h2.to_string(SRI)));
|
||||
|
@ -3255,6 +3262,7 @@ void DerivationGoal::registerOutputs()
|
|||
if (!worker.store.isValidPath(path)) continue;
|
||||
auto info = *worker.store.queryPathInfo(path);
|
||||
if (hash.first != info.narHash) {
|
||||
worker.checkMismatch = true;
|
||||
if (settings.runDiffHook || settings.keepFailed) {
|
||||
Path dst = worker.store.toRealPath(path + checkSuffix);
|
||||
deletePath(dst);
|
||||
|
@ -3266,10 +3274,10 @@ void DerivationGoal::registerOutputs()
|
|||
buildUser ? buildUser->getGID() : getgid(),
|
||||
path, dst, drvPath, tmpDir);
|
||||
|
||||
throw Error(format("derivation '%1%' may not be deterministic: output '%2%' differs from '%3%'")
|
||||
throw NotDeterministic(format("derivation '%1%' may not be deterministic: output '%2%' differs from '%3%'")
|
||||
% drvPath % path % dst);
|
||||
} else
|
||||
throw Error(format("derivation '%1%' may not be deterministic: output '%2%' differs")
|
||||
throw NotDeterministic(format("derivation '%1%' may not be deterministic: output '%2%' differs")
|
||||
% drvPath % path);
|
||||
}
|
||||
|
||||
|
@ -4101,6 +4109,8 @@ Worker::Worker(LocalStore & store)
|
|||
lastWokenUp = steady_time_point::min();
|
||||
permanentFailure = false;
|
||||
timedOut = false;
|
||||
hashMismatch = false;
|
||||
checkMismatch = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -4461,7 +4471,29 @@ void Worker::waitForInput()
|
|||
|
||||
unsigned int Worker::exitStatus()
|
||||
{
|
||||
return timedOut ? 101 : (permanentFailure ? 100 : 1);
|
||||
/*
|
||||
* 1100100
|
||||
* ^^^^
|
||||
* |||`- timeout
|
||||
* ||`-- output hash mismatch
|
||||
* |`--- build failure
|
||||
* `---- not deterministic
|
||||
*/
|
||||
unsigned int mask = 0;
|
||||
bool buildFailure = permanentFailure || timedOut || hashMismatch;
|
||||
if (buildFailure)
|
||||
mask |= 0x04; // 100
|
||||
if (timedOut)
|
||||
mask |= 0x01; // 101
|
||||
if (hashMismatch)
|
||||
mask |= 0x02; // 102
|
||||
if (checkMismatch) {
|
||||
mask |= 0x08; // 104
|
||||
}
|
||||
|
||||
if (mask)
|
||||
mask |= 0x60;
|
||||
return mask ? mask : 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -244,6 +244,8 @@ struct CurlDownloader : public Downloader
|
|||
#if LIBCURL_VERSION_NUM >= 0x072f00
|
||||
if (downloadSettings.enableHttp2)
|
||||
curl_easy_setopt(req, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);
|
||||
else
|
||||
curl_easy_setopt(req, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
||||
#endif
|
||||
curl_easy_setopt(req, CURLOPT_WRITEFUNCTION, DownloadItem::writeCallbackWrapper);
|
||||
curl_easy_setopt(req, CURLOPT_WRITEDATA, this);
|
||||
|
@ -864,10 +866,11 @@ CachedDownloadResult Downloader::downloadCached(
|
|||
}
|
||||
|
||||
if (expectedStorePath != "" && storePath != expectedStorePath) {
|
||||
unsigned int statusCode = 102;
|
||||
Hash gotHash = request.unpack
|
||||
? hashPath(request.expectedHash.type, store->toRealPath(storePath)).first
|
||||
: hashFile(request.expectedHash.type, store->toRealPath(storePath));
|
||||
throw nix::Error("hash mismatch in file downloaded from '%s':\n wanted: %s\n got: %s",
|
||||
throw nix::Error(statusCode, "hash mismatch in file downloaded from '%s':\n wanted: %s\n got: %s",
|
||||
url, request.expectedHash.to_string(), gotHash.to_string());
|
||||
}
|
||||
|
||||
|
|
|
@ -86,18 +86,25 @@ string storePathToHash(const Path & path)
|
|||
void checkStoreName(const string & name)
|
||||
{
|
||||
string validChars = "+-._?=";
|
||||
|
||||
auto baseError = format("The path name '%2%' is invalid: %3%. "
|
||||
"Path names are alphanumeric and can include the symbols %1% "
|
||||
"and must not begin with a period. "
|
||||
"Note: If '%2%' is a source file and you cannot rename it on "
|
||||
"disk, builtins.path { name = ... } can be used to give it an "
|
||||
"alternative name.") % validChars % name;
|
||||
|
||||
/* Disallow names starting with a dot for possible security
|
||||
reasons (e.g., "." and ".."). */
|
||||
if (string(name, 0, 1) == ".")
|
||||
throw Error(format("illegal name: '%1%'") % name);
|
||||
throw Error(baseError % "it is illegal to start the name with a period");
|
||||
for (auto & i : name)
|
||||
if (!((i >= 'A' && i <= 'Z') ||
|
||||
(i >= 'a' && i <= 'z') ||
|
||||
(i >= '0' && i <= '9') ||
|
||||
validChars.find(i) != string::npos))
|
||||
{
|
||||
throw Error(format("invalid character '%1%' in name '%2%'")
|
||||
% i % name);
|
||||
throw Error(baseError % (format("the '%1%' character is invalid") % i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,4 +6,4 @@ libutil_DIR := $(d)
|
|||
|
||||
libutil_SOURCES := $(wildcard $(d)/*.cc)
|
||||
|
||||
libutil_LDFLAGS = $(LIBLZMA_LIBS) -lbz2 -pthread $(OPENSSL_LIBS) $(LIBBROTLI_LIBS) -lboost_context
|
||||
libutil_LDFLAGS = $(LIBLZMA_LIBS) -lbz2 -pthread $(OPENSSL_LIBS) $(LIBBROTLI_LIBS) $(BOOST_LDFLAGS) -lboost_context
|
||||
|
|
|
@ -17,7 +17,7 @@ nix_SOURCES := \
|
|||
|
||||
nix_LIBS = libexpr libmain libstore libutil
|
||||
|
||||
nix_LDFLAGS = -pthread $(SODIUM_LIBS) $(EDITLINE_LIBS)
|
||||
nix_LDFLAGS = -pthread $(SODIUM_LIBS) $(EDITLINE_LIBS) $(BOOST_LDFLAGS) -lboost_context -lboost_thread -lboost_system
|
||||
|
||||
$(foreach name, \
|
||||
nix-build nix-channel nix-collect-garbage nix-copy-closure nix-daemon nix-env nix-hash nix-instantiate nix-prefetch-url nix-shell nix-store, \
|
||||
|
|
|
@ -39,8 +39,8 @@ static bool haveInternet()
|
|||
return true;
|
||||
}
|
||||
} else if (i->ifa_addr->sa_family == AF_INET6) {
|
||||
if (!IN6_IS_ADDR_LOOPBACK(((sockaddr_in6 *) i->ifa_addr)->sin6_addr.s6_addr) &&
|
||||
!IN6_IS_ADDR_LINKLOCAL(((sockaddr_in6 *) i->ifa_addr)->sin6_addr.s6_addr))
|
||||
if (!IN6_IS_ADDR_LOOPBACK(&((sockaddr_in6 *) i->ifa_addr)->sin6_addr) &&
|
||||
!IN6_IS_ADDR_LINKLOCAL(&((sockaddr_in6 *) i->ifa_addr)->sin6_addr))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,14 @@
|
|||
#include <readline/history.h>
|
||||
#include <readline/readline.h>
|
||||
#else
|
||||
// editline < 1.15.2 don't wrap their API for C++ usage
|
||||
// (added in https://github.com/troglobit/editline/commit/91398ceb3427b730995357e9d120539fb9bb7461).
|
||||
// This results in linker errors due to to name-mangling of editline C symbols.
|
||||
// For compatibility with these versions, we wrap the API here
|
||||
// (wrapping multiple times on newer versions is no problem).
|
||||
extern "C" {
|
||||
#include <editline.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "shared.hh"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue