Compare commits
20 Commits
makefs-sou
...
2.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d5c985aed | ||
|
|
b84c4c0770 | ||
|
|
64484c4da3 | ||
|
|
506339f5a9 | ||
|
|
ff695dd150 | ||
|
|
0cf2815007 | ||
|
|
8867e65128 | ||
|
|
20624d9a3b | ||
|
|
577470728c | ||
|
|
cf266f34ac | ||
|
|
3fdeae0f0a | ||
|
|
1131d73050 | ||
|
|
a669798b0b | ||
|
|
7a02b3e247 | ||
|
|
f31ba044e7 | ||
|
|
311ea23e2f | ||
|
|
ccdd12bbfa | ||
|
|
70331bb91d | ||
|
|
663f0a1a21 | ||
|
|
b58c51f8d6 |
@@ -70,7 +70,7 @@
|
||||
- [Hacking](contributing/hacking.md)
|
||||
- [CLI guideline](contributing/cli-guideline.md)
|
||||
- [Release Notes](release-notes/release-notes.md)
|
||||
- [Release 2.4 (2021-XX-XX)](release-notes/rl-2.4.md)
|
||||
- [Release 2.4 (2021-11-01)](release-notes/rl-2.4.md)
|
||||
- [Release 2.3 (2019-09-04)](release-notes/rl-2.3.md)
|
||||
- [Release 2.2 (2019-01-11)](release-notes/rl-2.2.md)
|
||||
- [Release 2.1 (2018-09-02)](release-notes/rl-2.1.md)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Release 2.4 (2021-10-XX)
|
||||
# Release 2.4 (2021-11-01)
|
||||
|
||||
This is the first release in more than two years and is the result of
|
||||
more than 2800 commits from 195 contributors since release 2.3.
|
||||
@@ -286,8 +286,35 @@ more than 2800 commits from 195 contributors since release 2.3.
|
||||
to your `nix.conf` if you want to use it, or pass
|
||||
`--extra-experimental-features nix-command` on the command line.
|
||||
|
||||
* The old `nix run` has been renamed to `nix shell` (and there is a
|
||||
new `nix run` that does something else, as described above).
|
||||
* The `nix` command no longer has a syntax for referring to packages
|
||||
in a channel. This means that the following no longer works:
|
||||
|
||||
> nix build nixpkgs.hello # Nix 2.3
|
||||
|
||||
Instead, you can either use the `#` syntax to select a package from
|
||||
a flake, e.g.
|
||||
|
||||
> nix build nixpkgs#hello
|
||||
|
||||
Or, if you want to use the `nixpkgs` channel in the `NIX_PATH`
|
||||
environment variable:
|
||||
|
||||
> nix build -f '<nixpkgs>' hello
|
||||
|
||||
* The old `nix run` has been renamed to `nix shell`, while there is a
|
||||
new `nix run` that runs a default command. So instead of
|
||||
|
||||
> nix run nixpkgs.hello -c hello # Nix 2.3
|
||||
|
||||
you should use
|
||||
|
||||
> nix shell nixpkgs#hello -c hello
|
||||
|
||||
or just
|
||||
|
||||
> nix run nixpkgs#hello
|
||||
|
||||
if the command you want to run has the same name as the package.
|
||||
|
||||
* It is now an error to modify the `plugin-files` setting via a
|
||||
command-line flag that appears after the first non-flag argument to
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
then ""
|
||||
else "pre${builtins.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}_${self.shortRev or "dirty"}";
|
||||
|
||||
officialRelease = false;
|
||||
officialRelease = true;
|
||||
|
||||
linux64BitSystems = [ "x86_64-linux" "aarch64-linux" ];
|
||||
linuxSystems = linux64BitSystems ++ [ "i686-linux" ];
|
||||
|
||||
@@ -91,7 +91,7 @@ define build-library
|
||||
$(1)_PATH := $$(_d)/$$($(1)_NAME).$(SO_EXT)
|
||||
|
||||
$$($(1)_PATH): $$($(1)_OBJS) $$(_libs) | $$(_d)/
|
||||
$$(trace-ld) $(CXX) -o $$(abspath $$@) -shared $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE)) $$($(1)_LDFLAGS_UNINSTALLED) $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED)
|
||||
$$(trace-ld) $(CXX) -o $$(abspath $$@) -shared $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE)) $$($(1)_LDFLAGS_UNINSTALLED)
|
||||
|
||||
ifndef HOST_DARWIN
|
||||
$(1)_LDFLAGS_USE += -Wl,-rpath,$$(abspath $$(_d))
|
||||
@@ -105,7 +105,7 @@ define build-library
|
||||
$$(eval $$(call create-dir, $$($(1)_INSTALL_DIR)))
|
||||
|
||||
$$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $(DESTDIR)$$($(1)_INSTALL_DIR)/
|
||||
$$(trace-ld) $(CXX) -o $$@ -shared $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED)) $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED)
|
||||
$$(trace-ld) $(CXX) -o $$@ -shared $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
|
||||
|
||||
$(1)_LDFLAGS_USE_INSTALLED += -L$$(DESTDIR)$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
|
||||
ifndef HOST_DARWIN
|
||||
@@ -125,8 +125,8 @@ define build-library
|
||||
$(1)_PATH := $$(_d)/$$($(1)_NAME).a
|
||||
|
||||
$$($(1)_PATH): $$($(1)_OBJS) | $$(_d)/
|
||||
$(trace-ld) $(LD) -Ur -o $$(_d)/$$($(1)_NAME).o $$?
|
||||
$(trace-ar) $(AR) crs $$@ $$(_d)/$$($(1)_NAME).o
|
||||
$$(trace-ld) $(LD) -Ur -o $$(_d)/$$($(1)_NAME).o $$?
|
||||
$$(trace-ar) $(AR) crs $$@ $$(_d)/$$($(1)_NAME).o
|
||||
|
||||
$(1)_LDFLAGS_USE += $$($(1)_PATH) $$($(1)_LDFLAGS)
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ define build-program
|
||||
$$(eval $$(call create-dir, $$(_d)))
|
||||
|
||||
$$($(1)_PATH): $$($(1)_OBJS) $$(_libs) | $$(_d)/
|
||||
$$(trace-ld) $(CXX) -o $$@ $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE)) $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS)
|
||||
$$(trace-ld) $(CXX) -o $$@ $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
|
||||
|
||||
$(1)_INSTALL_DIR ?= $$(bindir)
|
||||
|
||||
@@ -49,7 +49,7 @@ define build-program
|
||||
_libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH))
|
||||
|
||||
$(DESTDIR)$$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $(DESTDIR)$$($(1)_INSTALL_DIR)/
|
||||
$$(trace-ld) $(CXX) -o $$@ $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED)) $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS)
|
||||
$$(trace-ld) $(CXX) -o $$@ $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
|
||||
|
||||
else
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ poly_service_installed_check() {
|
||||
poly_service_uninstall_directions() {
|
||||
echo "$1. Remove macOS-specific components:"
|
||||
if should_create_volume && test_nix_volume_mountd_installed; then
|
||||
darwin_volume_uninstall_directions
|
||||
nix_volume_mountd_uninstall_directions
|
||||
fi
|
||||
if test_nix_daemon_installed; then
|
||||
nix_daemon_uninstall_directions
|
||||
|
||||
@@ -130,11 +130,14 @@ static int main_build_remote(int argc, char * * argv)
|
||||
for (auto & m : machines) {
|
||||
debug("considering building on remote machine '%s'", m.storeUri);
|
||||
|
||||
if (m.enabled && std::find(m.systemTypes.begin(),
|
||||
m.systemTypes.end(),
|
||||
neededSystem) != m.systemTypes.end() &&
|
||||
if (m.enabled
|
||||
&& (neededSystem == "builtin"
|
||||
|| std::find(m.systemTypes.begin(),
|
||||
m.systemTypes.end(),
|
||||
neededSystem) != m.systemTypes.end()) &&
|
||||
m.allSupported(requiredFeatures) &&
|
||||
m.mandatoryMet(requiredFeatures)) {
|
||||
m.mandatoryMet(requiredFeatures))
|
||||
{
|
||||
rightType = true;
|
||||
AutoCloseFD free;
|
||||
uint64_t load = 0;
|
||||
|
||||
@@ -752,7 +752,7 @@ std::pair<bool, std::string> EvalState::resolveSearchPathElem(const SearchPathEl
|
||||
res = { true, path };
|
||||
else {
|
||||
logWarning({
|
||||
.msg = hintfmt("warning: Nix search path entry '%1%' does not exist, ignoring", elem.second)
|
||||
.msg = hintfmt("Nix search path entry '%1%' does not exist, ignoring", elem.second)
|
||||
});
|
||||
res = { false, "" };
|
||||
}
|
||||
|
||||
@@ -575,7 +575,7 @@ static Bindings::iterator getAttr(
|
||||
// Adding another trace for the function name to make it clear
|
||||
// which call received wrong arguments.
|
||||
e.addTrace(pos, hintfmt("while invoking '%s'", funcName));
|
||||
throw;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -616,7 +616,9 @@ void DerivationGoal::tryToBuild()
|
||||
/* Don't do a remote build if the derivation has the attribute
|
||||
`preferLocalBuild' set. Also, check and repair modes are only
|
||||
supported for local builds. */
|
||||
bool buildLocally = buildMode != bmNormal || parsedDrv->willBuildLocally(worker.store);
|
||||
bool buildLocally =
|
||||
(buildMode != bmNormal || parsedDrv->willBuildLocally(worker.store))
|
||||
&& settings.maxBuildJobs.get() != 0;
|
||||
|
||||
if (!buildLocally) {
|
||||
switch (tryBuildHook()) {
|
||||
|
||||
@@ -948,7 +948,7 @@ void LocalDerivationGoal::startBuilder()
|
||||
FdSource source(builderOut.readSide.get());
|
||||
auto ex = readError(source);
|
||||
ex.addTrace({}, "while setting up the build environment");
|
||||
throw;
|
||||
throw ex;
|
||||
}
|
||||
debug("sandbox setup: " + msg);
|
||||
msgs.push_back(std::move(msg));
|
||||
|
||||
@@ -235,6 +235,7 @@ struct ClientSettings
|
||||
}
|
||||
else if (trusted
|
||||
|| name == settings.buildTimeout.name
|
||||
|| name == settings.buildRepeat.name
|
||||
|| name == "connect-timeout"
|
||||
|| (name == "builders" && value == ""))
|
||||
settings.set(name, value);
|
||||
|
||||
@@ -716,15 +716,32 @@ struct curlFileTransfer : public FileTransfer
|
||||
}
|
||||
};
|
||||
|
||||
ref<curlFileTransfer> makeCurlFileTransfer()
|
||||
{
|
||||
return make_ref<curlFileTransfer>();
|
||||
}
|
||||
|
||||
ref<FileTransfer> getFileTransfer()
|
||||
{
|
||||
static ref<FileTransfer> fileTransfer = makeFileTransfer();
|
||||
static ref<curlFileTransfer> fileTransfer = makeCurlFileTransfer();
|
||||
|
||||
// this has to be done in its own scope to make sure that the lock is released
|
||||
// before creating a new fileTransfer instance.
|
||||
auto needsRecreation = [&]() -> bool {
|
||||
auto state = fileTransfer->state_.lock();
|
||||
return state->quit;
|
||||
};
|
||||
|
||||
if (needsRecreation()) {
|
||||
fileTransfer = makeCurlFileTransfer();
|
||||
}
|
||||
|
||||
return fileTransfer;
|
||||
}
|
||||
|
||||
ref<FileTransfer> makeFileTransfer()
|
||||
{
|
||||
return make_ref<curlFileTransfer>();
|
||||
return makeCurlFileTransfer();
|
||||
}
|
||||
|
||||
std::future<FileTransferResult> FileTransfer::enqueueFileTransfer(const FileTransferRequest & request)
|
||||
|
||||
@@ -10,6 +10,6 @@ libstore-tests_SOURCES := $(wildcard $(d)/*.cc)
|
||||
|
||||
libstore-tests_CXXFLAGS += -I src/libstore -I src/libutil
|
||||
|
||||
libstore-tests_LIBS = libstore
|
||||
libstore-tests_LIBS = libstore libutil
|
||||
|
||||
libstore-tests_LDFLAGS := $(GTEST_LIBS)
|
||||
|
||||
@@ -17,7 +17,7 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
ref<T>(const ref<T> & r)
|
||||
ref(const ref<T> & r)
|
||||
: p(r.p)
|
||||
{ }
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <limits.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <numeric>
|
||||
|
||||
namespace nix {
|
||||
|
||||
/* ----------- tests for util.hh ------------------------------------------------*/
|
||||
@@ -282,6 +284,17 @@ namespace nix {
|
||||
ASSERT_EQ(decoded, s);
|
||||
}
|
||||
|
||||
TEST(base64Encode, encodeAndDecodeNonPrintable) {
|
||||
char s[256];
|
||||
std::iota(std::rbegin(s), std::rend(s), 0);
|
||||
|
||||
auto encoded = base64Encode(s);
|
||||
auto decoded = base64Decode(encoded);
|
||||
|
||||
EXPECT_EQ(decoded.length(), 255);
|
||||
ASSERT_EQ(decoded, s);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* base64Decode
|
||||
* --------------------------------------------------------------------------*/
|
||||
@@ -294,6 +307,10 @@ namespace nix {
|
||||
ASSERT_EQ(base64Decode("cXVvZCBlcmF0IGRlbW9uc3RyYW5kdW0="), "quod erat demonstrandum");
|
||||
}
|
||||
|
||||
TEST(base64Decode, decodeThrowsOnInvalidChar) {
|
||||
ASSERT_THROW(base64Decode("cXVvZCBlcm_0IGRlbW9uc3RyYW5kdW0="), Error);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* toLower
|
||||
* --------------------------------------------------------------------------*/
|
||||
|
||||
@@ -1436,8 +1436,7 @@ std::string filterANSIEscapes(const std::string & s, bool filterAll, unsigned in
|
||||
}
|
||||
|
||||
|
||||
static char base64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
static std::array<char, 256> base64DecodeChars;
|
||||
constexpr char base64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
string base64Encode(std::string_view s)
|
||||
{
|
||||
@@ -1462,12 +1461,15 @@ string base64Encode(std::string_view s)
|
||||
|
||||
string base64Decode(std::string_view s)
|
||||
{
|
||||
static std::once_flag flag;
|
||||
std::call_once(flag, [](){
|
||||
base64DecodeChars = { (char)-1 };
|
||||
constexpr char npos = -1;
|
||||
constexpr std::array<char, 256> base64DecodeChars = [&]() {
|
||||
std::array<char, 256> result{};
|
||||
for (auto& c : result)
|
||||
c = npos;
|
||||
for (int i = 0; i < 64; i++)
|
||||
base64DecodeChars[(int) base64Chars[i]] = i;
|
||||
});
|
||||
result[base64Chars[i]] = i;
|
||||
return result;
|
||||
}();
|
||||
|
||||
string res;
|
||||
unsigned int d = 0, bits = 0;
|
||||
@@ -1477,7 +1479,7 @@ string base64Decode(std::string_view s)
|
||||
if (c == '\n') continue;
|
||||
|
||||
char digit = base64DecodeChars[(unsigned char) c];
|
||||
if (digit == -1)
|
||||
if (digit == npos)
|
||||
throw Error("invalid character in Base64 string: '%c'", c);
|
||||
|
||||
bits += 6;
|
||||
|
||||
@@ -200,13 +200,13 @@ namespace {
|
||||
void NixRepl::mainLoop(const std::vector<std::string> & files)
|
||||
{
|
||||
string error = ANSI_RED "error:" ANSI_NORMAL " ";
|
||||
std::cout << "Welcome to Nix version " << nixVersion << ". Type :? for help." << std::endl << std::endl;
|
||||
notice("Welcome to Nix " + nixVersion + ". Type :? for help.\n");
|
||||
|
||||
for (auto & i : files)
|
||||
loadedFiles.push_back(i);
|
||||
|
||||
reloadFiles();
|
||||
if (!loadedFiles.empty()) std::cout << std::endl;
|
||||
if (!loadedFiles.empty()) notice("");
|
||||
|
||||
// Allow nix-repl specific settings in .inputrc
|
||||
rl_readline_name = "nix-repl";
|
||||
@@ -396,6 +396,8 @@ bool NixRepl::processLine(string line)
|
||||
{
|
||||
if (line == "") return true;
|
||||
|
||||
_isInterrupted = false;
|
||||
|
||||
string command, arg;
|
||||
|
||||
if (line[0] == ':') {
|
||||
@@ -479,9 +481,10 @@ bool NixRepl::processLine(string line)
|
||||
else if (command == ":t") {
|
||||
Value v;
|
||||
evalString(arg, v);
|
||||
std::cout << showType(v) << std::endl;
|
||||
logger->cout(showType(v));
|
||||
}
|
||||
|
||||
} else if (command == ":u") {
|
||||
else if (command == ":u") {
|
||||
Value v, f, result;
|
||||
evalString(arg, v);
|
||||
evalString("drv: (import <nixpkgs> {}).runCommand \"shell\" { buildInputs = [ drv ]; } \"\"", f);
|
||||
@@ -498,17 +501,11 @@ bool NixRepl::processLine(string line)
|
||||
Path drvPathRaw = state->store->printStorePath(drvPath);
|
||||
|
||||
if (command == ":b") {
|
||||
/* We could do the build in this process using buildPaths(),
|
||||
but doing it in a child makes it easier to recover from
|
||||
problems / SIGINT. */
|
||||
try {
|
||||
runNix("nix", {"build", "--no-link", drvPathRaw});
|
||||
auto drv = state->store->readDerivation(drvPath);
|
||||
std::cout << std::endl << "this derivation produced the following outputs:" << std::endl;
|
||||
for (auto & i : drv.outputsAndOptPaths(*state->store))
|
||||
std::cout << fmt(" %s -> %s\n", i.first, state->store->printStorePath(*i.second.second));
|
||||
} catch (ExecError &) {
|
||||
}
|
||||
state->store->buildPaths({DerivedPath::Built{drvPath}});
|
||||
auto drv = state->store->readDerivation(drvPath);
|
||||
logger->cout("\nThis derivation produced the following outputs:");
|
||||
for (auto & i : drv.outputsAndOptPaths(*state->store))
|
||||
logger->cout(" %s -> %s", i.first, state->store->printStorePath(*i.second.second));
|
||||
} else if (command == ":i") {
|
||||
runNix("nix-env", {"-i", drvPathRaw});
|
||||
} else {
|
||||
@@ -541,9 +538,9 @@ bool NixRepl::processLine(string line)
|
||||
+ concatStringsSep(" ", args) + "\n\n";
|
||||
}
|
||||
|
||||
markdown += trim(stripIndentation(doc->doc));
|
||||
markdown += stripIndentation(doc->doc);
|
||||
|
||||
std::cout << renderMarkdownToTerminal(markdown);
|
||||
logger->cout(trim(renderMarkdownToTerminal(markdown)));
|
||||
} else
|
||||
throw Error("value does not have documentation");
|
||||
}
|
||||
@@ -626,9 +623,9 @@ void NixRepl::reloadFiles()
|
||||
|
||||
bool first = true;
|
||||
for (auto & i : old) {
|
||||
if (!first) std::cout << std::endl;
|
||||
if (!first) notice("");
|
||||
first = false;
|
||||
std::cout << format("Loading '%1%'...") % i << std::endl;
|
||||
notice("Loading '%1%'...", i);
|
||||
loadFile(i);
|
||||
}
|
||||
}
|
||||
@@ -639,7 +636,7 @@ void NixRepl::addAttrsToScope(Value & attrs)
|
||||
state->forceAttrs(attrs);
|
||||
for (auto & i : *attrs.attrs)
|
||||
addVarToScope(i.name, *i.value);
|
||||
std::cout << format("Added %1% variables.") % attrs.attrs->size() << std::endl;
|
||||
notice("Added %1% variables.", attrs.attrs->size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ isDaemonNewer () {
|
||||
[[ -n "${NIX_DAEMON_PACKAGE:-}" ]] || return 0
|
||||
local requiredVersion="$1"
|
||||
local daemonVersion=$($NIX_DAEMON_PACKAGE/bin/nix-daemon --version | cut -d' ' -f3)
|
||||
return [[ $(nix eval --expr "builtins.compareVersions ''$daemonVersion'' ''2.4''") -ge 0 ]]
|
||||
[[ $(nix eval --expr "builtins.compareVersions ''$daemonVersion'' ''$requiredVersion''") -ge 0 ]]
|
||||
}
|
||||
|
||||
requireDaemonNewerThan () {
|
||||
|
||||
@@ -2,7 +2,7 @@ source common.sh
|
||||
|
||||
# 27ce722638 required some incompatible changes to the nix file, so skip this
|
||||
# tests for the older versions
|
||||
requireDaemonNewerThan "2.4pre20210622"
|
||||
requireDaemonNewerThan "2.4pre20210712"
|
||||
|
||||
clearStore
|
||||
|
||||
|
||||
Reference in New Issue
Block a user