mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
Merge branch 'master' of github.com:NixOS/nix into better-ca-parse-errors
This commit is contained in:
commit
323d51a7a0
8 changed files with 145 additions and 31 deletions
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
|
@ -12,3 +12,13 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: cachix/install-nix-action@v10
|
- uses: cachix/install-nix-action@v10
|
||||||
- run: nix-build release.nix --arg nix '{ outPath = ./.; revCount = 123; shortRev = "abcdefgh"; }' --arg systems '[ builtins.currentSystem ]' -A installerScript -A perlBindings
|
- run: nix-build release.nix --arg nix '{ outPath = ./.; revCount = 123; shortRev = "abcdefgh"; }' --arg systems '[ builtins.currentSystem ]' -A installerScript -A perlBindings
|
||||||
|
macos_perf_test:
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- name: Disable syspolicy assessments
|
||||||
|
run: |
|
||||||
|
spctl --status
|
||||||
|
sudo spctl --master-disable
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: cachix/install-nix-action@v10
|
||||||
|
- run: nix-build release.nix --arg nix '{ outPath = ./.; revCount = 123; shortRev = "abcdefgh"; }' --arg systems '[ builtins.currentSystem ]' -A installerScript -A perlBindings
|
||||||
|
|
|
@ -170,15 +170,5 @@ $channelsBucket->add_key(
|
||||||
chdir("/home/eelco/Dev/nix-pristine") or die;
|
chdir("/home/eelco/Dev/nix-pristine") or die;
|
||||||
system("git remote update origin") == 0 or die;
|
system("git remote update origin") == 0 or die;
|
||||||
system("git tag --force --sign $version $nixRev -m 'Tagging release $version'") == 0 or die;
|
system("git tag --force --sign $version $nixRev -m 'Tagging release $version'") == 0 or die;
|
||||||
|
system("git push --tags") == 0 or die;
|
||||||
# Update the website.
|
system("git push --force-with-lease origin $nixRev:refs/heads/latest-release") == 0 or die;
|
||||||
my $siteDir = "/home/eelco/Dev/nixos-homepage-pristine";
|
|
||||||
|
|
||||||
system("cd $siteDir && git pull") == 0 or die;
|
|
||||||
|
|
||||||
write_file("$siteDir/nix-release.tt",
|
|
||||||
"[%-\n" .
|
|
||||||
"latestNixVersion = \"$version\"\n" .
|
|
||||||
"-%]\n");
|
|
||||||
|
|
||||||
system("cd $siteDir && git commit -a -m 'Nix $version released'") == 0 or die;
|
|
||||||
|
|
|
@ -2041,7 +2041,10 @@ void DerivationGoal::startBuilder()
|
||||||
if (!std::regex_match(fileName, regex))
|
if (!std::regex_match(fileName, regex))
|
||||||
throw Error("invalid file name '%s' in 'exportReferencesGraph'", fileName);
|
throw Error("invalid file name '%s' in 'exportReferencesGraph'", fileName);
|
||||||
|
|
||||||
auto storePath = worker.store.parseStorePath(*i++);
|
auto storePathS = *i++;
|
||||||
|
if (!worker.store.isInStore(storePathS))
|
||||||
|
throw BuildError("'exportReferencesGraph' contains a non-store path '%1%'", storePathS);
|
||||||
|
auto storePath = worker.store.parseStorePath(worker.store.toStorePath(storePathS));
|
||||||
|
|
||||||
/* Write closure info to <fileName>. */
|
/* Write closure info to <fileName>. */
|
||||||
writeFile(tmpDir + "/" + fileName,
|
writeFile(tmpDir + "/" + fileName,
|
||||||
|
|
|
@ -81,7 +81,7 @@ struct TunnelLogger : public Logger
|
||||||
showErrorInfo(oss, ei, false);
|
showErrorInfo(oss, ei, false);
|
||||||
|
|
||||||
StringSink buf;
|
StringSink buf;
|
||||||
buf << STDERR_NEXT << oss.str() << "\n";
|
buf << STDERR_NEXT << oss.str();
|
||||||
enqueueMsg(*buf.s);
|
enqueueMsg(*buf.s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -365,6 +365,9 @@ public:
|
||||||
|
|
||||||
Setting<bool> warnDirty{this, true, "warn-dirty",
|
Setting<bool> warnDirty{this, true, "warn-dirty",
|
||||||
"Whether to warn about dirty Git/Mercurial trees."};
|
"Whether to warn about dirty Git/Mercurial trees."};
|
||||||
|
|
||||||
|
Setting<size_t> narBufferSize{this, 32 * 1024 * 1024, "nar-buffer-size",
|
||||||
|
"Maximum size of NARs before spilling them to disk."};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -976,7 +976,7 @@ void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
|
||||||
|
|
||||||
PathLocks outputLock;
|
PathLocks outputLock;
|
||||||
|
|
||||||
Path realPath = realStoreDir + "/" + std::string(info.path.to_string());
|
auto realPath = Store::toRealPath(info.path);
|
||||||
|
|
||||||
/* Lock the output path. But don't lock if we're being called
|
/* Lock the output path. But don't lock if we're being called
|
||||||
from a build hook (whose parent process already acquired a
|
from a build hook (whose parent process already acquired a
|
||||||
|
@ -1047,8 +1047,7 @@ StorePath LocalStore::addToStoreFromDump(const string & dump, const string & nam
|
||||||
/* The first check above is an optimisation to prevent
|
/* The first check above is an optimisation to prevent
|
||||||
unnecessary lock acquisition. */
|
unnecessary lock acquisition. */
|
||||||
|
|
||||||
Path realPath = realStoreDir + "/";
|
auto realPath = Store::toRealPath(dstPath);
|
||||||
realPath += dstPath.to_string();
|
|
||||||
|
|
||||||
PathLocks outputLock({realPath});
|
PathLocks outputLock({realPath});
|
||||||
|
|
||||||
|
@ -1098,16 +1097,125 @@ StorePath LocalStore::addToStore(const string & name, const Path & _srcPath,
|
||||||
{
|
{
|
||||||
Path srcPath(absPath(_srcPath));
|
Path srcPath(absPath(_srcPath));
|
||||||
|
|
||||||
/* Read the whole path into memory. This is not a very scalable
|
/* For computing the NAR hash. */
|
||||||
method for very large paths, but `copyPath' is mainly used for
|
auto sha256Sink = std::make_unique<HashSink>(htSHA256);
|
||||||
small files. */
|
|
||||||
StringSink sink;
|
|
||||||
if (method == FileIngestionMethod::Recursive)
|
|
||||||
dumpPath(srcPath, sink, filter);
|
|
||||||
else
|
|
||||||
sink.s = make_ref<std::string>(readFile(srcPath));
|
|
||||||
|
|
||||||
return addToStoreFromDump(*sink.s, name, method, hashAlgo, repair);
|
/* For computing the store path. In recursive SHA-256 mode, this
|
||||||
|
is the same as the NAR hash, so no need to do it again. */
|
||||||
|
std::unique_ptr<HashSink> hashSink =
|
||||||
|
method == FileIngestionMethod::Recursive && hashAlgo == htSHA256
|
||||||
|
? nullptr
|
||||||
|
: std::make_unique<HashSink>(hashAlgo);
|
||||||
|
|
||||||
|
/* Read the source path into memory, but only if it's up to
|
||||||
|
narBufferSize bytes. If it's larger, write it to a temporary
|
||||||
|
location in the Nix store. If the subsequently computed
|
||||||
|
destination store path is already valid, we just delete the
|
||||||
|
temporary path. Otherwise, we move it to the destination store
|
||||||
|
path. */
|
||||||
|
bool inMemory = true;
|
||||||
|
std::string nar;
|
||||||
|
|
||||||
|
auto source = sinkToSource([&](Sink & sink) {
|
||||||
|
|
||||||
|
LambdaSink sink2([&](const unsigned char * buf, size_t len) {
|
||||||
|
(*sha256Sink)(buf, len);
|
||||||
|
if (hashSink) (*hashSink)(buf, len);
|
||||||
|
|
||||||
|
if (inMemory) {
|
||||||
|
if (nar.size() + len > settings.narBufferSize) {
|
||||||
|
inMemory = false;
|
||||||
|
sink << 1;
|
||||||
|
sink((const unsigned char *) nar.data(), nar.size());
|
||||||
|
nar.clear();
|
||||||
|
} else {
|
||||||
|
nar.append((const char *) buf, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!inMemory) sink(buf, len);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (method == FileIngestionMethod::Recursive)
|
||||||
|
dumpPath(srcPath, sink2, filter);
|
||||||
|
else
|
||||||
|
readFile(srcPath, sink2);
|
||||||
|
});
|
||||||
|
|
||||||
|
std::unique_ptr<AutoDelete> delTempDir;
|
||||||
|
Path tempPath;
|
||||||
|
|
||||||
|
try {
|
||||||
|
/* Wait for the source coroutine to give us some dummy
|
||||||
|
data. This is so that we don't create the temporary
|
||||||
|
directory if the NAR fits in memory. */
|
||||||
|
readInt(*source);
|
||||||
|
|
||||||
|
auto tempDir = createTempDir(realStoreDir, "add");
|
||||||
|
delTempDir = std::make_unique<AutoDelete>(tempDir);
|
||||||
|
tempPath = tempDir + "/x";
|
||||||
|
|
||||||
|
if (method == FileIngestionMethod::Recursive)
|
||||||
|
restorePath(tempPath, *source);
|
||||||
|
else
|
||||||
|
writeFile(tempPath, *source);
|
||||||
|
|
||||||
|
} catch (EndOfFile &) {
|
||||||
|
if (!inMemory) throw;
|
||||||
|
/* The NAR fits in memory, so we didn't do restorePath(). */
|
||||||
|
}
|
||||||
|
|
||||||
|
auto sha256 = sha256Sink->finish();
|
||||||
|
|
||||||
|
Hash hash = hashSink ? hashSink->finish().first : sha256.first;
|
||||||
|
|
||||||
|
auto dstPath = makeFixedOutputPath(method, hash, name);
|
||||||
|
|
||||||
|
addTempRoot(dstPath);
|
||||||
|
|
||||||
|
if (repair || !isValidPath(dstPath)) {
|
||||||
|
|
||||||
|
/* The first check above is an optimisation to prevent
|
||||||
|
unnecessary lock acquisition. */
|
||||||
|
|
||||||
|
auto realPath = Store::toRealPath(dstPath);
|
||||||
|
|
||||||
|
PathLocks outputLock({realPath});
|
||||||
|
|
||||||
|
if (repair || !isValidPath(dstPath)) {
|
||||||
|
|
||||||
|
deletePath(realPath);
|
||||||
|
|
||||||
|
autoGC();
|
||||||
|
|
||||||
|
if (inMemory) {
|
||||||
|
/* Restore from the NAR in memory. */
|
||||||
|
StringSource source(nar);
|
||||||
|
if (method == FileIngestionMethod::Recursive)
|
||||||
|
restorePath(realPath, source);
|
||||||
|
else
|
||||||
|
writeFile(realPath, source);
|
||||||
|
} else {
|
||||||
|
/* Move the temporary path we restored above. */
|
||||||
|
if (rename(tempPath.c_str(), realPath.c_str()))
|
||||||
|
throw Error("renaming '%s' to '%s'", tempPath, realPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
canonicalisePathMetaData(realPath, -1); // FIXME: merge into restorePath
|
||||||
|
|
||||||
|
optimisePath(realPath);
|
||||||
|
|
||||||
|
ValidPathInfo info(dstPath);
|
||||||
|
info.narHash = sha256.first;
|
||||||
|
info.narSize = sha256.second;
|
||||||
|
info.ca = FixedOutputHash { .method = method, .hash = hash };
|
||||||
|
registerValidPath(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
outputLock.setDeletion(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dstPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1121,8 +1229,7 @@ StorePath LocalStore::addTextToStore(const string & name, const string & s,
|
||||||
|
|
||||||
if (repair || !isValidPath(dstPath)) {
|
if (repair || !isValidPath(dstPath)) {
|
||||||
|
|
||||||
Path realPath = realStoreDir + "/";
|
auto realPath = Store::toRealPath(dstPath);
|
||||||
realPath += dstPath.to_string();
|
|
||||||
|
|
||||||
PathLocks outputLock({realPath});
|
PathLocks outputLock({realPath});
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#include "ref.hh"
|
#include "ref.hh"
|
||||||
#include "types.hh"
|
#include "types.hh"
|
||||||
|
#include "fmt.hh"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
@ -10,7 +10,9 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include "fmt.hh"
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
/* Before 4.7, gcc's std::exception uses empty throw() specifiers for
|
/* 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
|
* its (virtual) destructor and what() in c++11 mode, in violation of spec
|
||||||
|
|
|
@ -81,7 +81,6 @@ public:
|
||||||
|
|
||||||
log(ei.level, oss.str());
|
log(ei.level, oss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void startActivity(ActivityId act, Verbosity lvl, ActivityType type,
|
void startActivity(ActivityId act, Verbosity lvl, ActivityType type,
|
||||||
const std::string & s, const Fields & fields, ActivityId parent)
|
const std::string & s, const Fields & fields, ActivityId parent)
|
||||||
|
|
Loading…
Reference in a new issue