From c5bd564c69ec1fb4f2ffc1091653d99ebc87e284 Mon Sep 17 00:00:00 2001 From: Benjamin Hipple Date: Sun, 6 Oct 2019 16:54:56 -0400 Subject: [PATCH 01/20] nix doctor: add more logging output to checks When running nix doctor on a healthy system, it just prints the store URI and nothing else. This makes it unclear whether the system is in a good state and what check(s) it actually ran, since some of the checks are optional depending on the store type. This commit updates nix doctor to print an colored log message for every check that it does, and explicitly state whether that check was a PASS or FAIL to make it clear to the user whether the system passed its checkup with the doctor. Fixes #3084 --- src/nix/doctor.cc | 67 +++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/src/nix/doctor.cc b/src/nix/doctor.cc index 7b5444619..795236c5f 100644 --- a/src/nix/doctor.cc +++ b/src/nix/doctor.cc @@ -1,11 +1,17 @@ +#include + #include "command.hh" +#include "logging.hh" #include "serve-protocol.hh" #include "shared.hh" #include "store-api.hh" +#include "util.hh" #include "worker-protocol.hh" using namespace nix; +namespace { + std::string formatProtocol(unsigned int proto) { if (proto) { @@ -16,6 +22,18 @@ std::string formatProtocol(unsigned int proto) return "unknown"; } +bool checkPass(const std::string & msg) { + logger->log(ANSI_GREEN "[PASS] " ANSI_NORMAL + msg); + return true; +} + +bool checkFail(const std::string & msg) { + logger->log(ANSI_RED "[FAIL] " ANSI_NORMAL + msg); + return false; +} + +} + struct CmdDoctor : StoreCommand { bool success = true; @@ -27,13 +45,12 @@ struct CmdDoctor : StoreCommand std::string description() override { - return "check your system for potential problems"; + return "check your system for potential problems and print a PASS or FAIL for each check."; } void run(ref store) override { - std::cout << "Store uri: " << store->getUri() << std::endl; - std::cout << std::endl; + logger->log("Running checks against store uri: " + store->getUri()); auto type = getStoreType(); @@ -56,15 +73,14 @@ struct CmdDoctor : StoreCommand dirs.insert(dirOf(canonPath(dir + "/nix-env", true))); if (dirs.size() != 1) { - std::cout << "Warning: multiple versions of nix found in PATH." << std::endl; - std::cout << std::endl; + std::stringstream ss; + ss << "Multiple versions of nix found in PATH:\n"; for (auto & dir : dirs) - std::cout << " " << dir << std::endl; - std::cout << std::endl; - return false; + ss << " " << dir << "\n"; + return checkFail(ss.str()); } - return true; + return checkPass("PATH contains only one nix version."); } bool checkProfileRoots(ref store) @@ -87,17 +103,17 @@ struct CmdDoctor : StoreCommand } if (!dirs.empty()) { - std::cout << "Warning: found profiles outside of " << settings.nixStateDir << "/profiles." << std::endl; - std::cout << "The generation this profile points to might not have a gcroot and could be" << std::endl; - std::cout << "garbage collected, resulting in broken symlinks." << std::endl; - std::cout << std::endl; + std::stringstream ss; + ss << "Found profiles outside of " << settings.nixStateDir << "/profiles.\n" + << "The generation this profile points to might not have a gcroot and could be\n" + << "garbage collected, resulting in broken symlinks.\n\n"; for (auto & dir : dirs) - std::cout << " " << dir << std::endl; - std::cout << std::endl; - return false; + ss << " " << dir << "\n"; + ss << "\n"; + return checkFail(ss.str()); } - return true; + return checkPass("All profiles are gcroots."); } bool checkStoreProtocol(unsigned int storeProto) @@ -107,17 +123,16 @@ struct CmdDoctor : StoreCommand : PROTOCOL_VERSION; if (clientProto != storeProto) { - std::cout << "Warning: protocol version of this client does not match the store." << std::endl; - std::cout << "While this is not necessarily a problem it's recommended to keep the client in" << std::endl; - std::cout << "sync with the daemon." << std::endl; - std::cout << std::endl; - std::cout << "Client protocol: " << formatProtocol(clientProto) << std::endl; - std::cout << "Store protocol: " << formatProtocol(storeProto) << std::endl; - std::cout << std::endl; - return false; + std::stringstream ss; + ss << "Warning: protocol version of this client does not match the store.\n" + << "While this is not necessarily a problem it's recommended to keep the client in\n" + << "sync with the daemon.\n\n" + << "Client protocol: " << formatProtocol(clientProto) << "\n" + << "Store protocol: " << formatProtocol(storeProto) << "\n\n"; + return checkFail(ss.str()); } - return true; + return checkPass("Client protocol matches store protocol."); } }; From 73ff84f6a820ac1c6e0fe502692432c8945fd8b0 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Wed, 23 Oct 2019 15:29:16 +0200 Subject: [PATCH 02/20] nix repl: add :edit command This allows to have a repl-centric workflow to working on nixpkgs. Usage: :edit - heuristic that find the package file path :edit - just open the editor on the file path Once invoked, `nix repl` will open $EDITOR on that file path. Once the editor exits, `nix repl` will automatically reload itself. --- src/nix/repl.cc | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/nix/repl.cc b/src/nix/repl.cc index f857b2e89..79f365cdb 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -22,6 +22,7 @@ extern "C" { #include "shared.hh" #include "eval.hh" #include "eval-inline.hh" +#include "attr-path.hh" #include "store-api.hh" #include "common-eval-args.hh" #include "get-drvs.hh" @@ -440,6 +441,7 @@ bool NixRepl::processLine(string line) << " = Bind expression to variable\n" << " :a Add attributes from resulting set to scope\n" << " :b Build derivation\n" + << " :e Open the derivation in $EDITOR\n" << " :i Build derivation, then install result into current profile\n" << " :l Load Nix expression and add it to scope\n" << " :p Evaluate and print expression recursively\n" @@ -466,6 +468,61 @@ bool NixRepl::processLine(string line) reloadFiles(); } + else if (command == ":e" || command == ":edit") { + Value v; + evalString(arg, v); + + std::string filename; + int lineno = 0; + + if (v.type == tPath || v.type == tString) { + PathSet context; + filename = state.coerceToString(noPos, v, context); + lineno = 0; + } else { + // assume it's a derivation + Value * v2; + try { + auto dummyArgs = state.allocBindings(0); + v2 = findAlongAttrPath(state, "meta.position", *dummyArgs, v); + } catch (Error &) { + throw Error("package '%s' has no source location information", arg); + } + + auto pos = state.forceString(*v2); + debug("position is %s", pos); + + auto colon = pos.rfind(':'); + if (colon == std::string::npos) + throw Error("cannot parse meta.position attribute '%s'", pos); + + filename = std::string(pos, 0, colon); + try { + lineno = std::stoi(std::string(pos, colon + 1)); + } catch (std::invalid_argument & e) { + throw Error("cannot parse line number '%s'", pos); + } + + } + + // Open in EDITOR + auto editor = getEnv("EDITOR", "cat"); + auto args = tokenizeString(editor); + if (lineno > 0 && ( + editor.find("emacs") != std::string::npos || + editor.find("nano") != std::string::npos || + editor.find("vim") != std::string::npos)) + args.push_back(fmt("+%d", lineno)); + args.push_back(filename); + editor = args.front(); + args.pop_front(); + runProgram(editor, args); + + // Reload right after exiting the editor + state.resetFileCache(); + reloadFiles(); + } + else if (command == ":t") { Value v; evalString(arg, v); From 207a537343ace1d39ac125059456d832a5237f2e Mon Sep 17 00:00:00 2001 From: zimbatm Date: Wed, 23 Oct 2019 16:48:28 +0200 Subject: [PATCH 03/20] libutil: add editorFor heuristic --- src/libutil/args.cc | 13 +++++++++++++ src/libutil/args.hh | 3 +++ src/nix/edit.cc | 17 +++++------------ src/nix/repl.cc | 11 ++--------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/libutil/args.cc b/src/libutil/args.cc index 7af2a1bf7..35ec3e4ab 100644 --- a/src/libutil/args.cc +++ b/src/libutil/args.cc @@ -178,6 +178,19 @@ Strings argvToStrings(int argc, char * * argv) return args; } +Strings editorFor(std::string filename, int lineno) +{ + auto editor = getEnv("EDITOR", "cat"); + auto args = tokenizeString(editor); + if (lineno > 0 && ( + editor.find("emacs") != std::string::npos || + editor.find("nano") != std::string::npos || + editor.find("vim") != std::string::npos)) + args.push_back(fmt("+%d", lineno)); + args.push_back(filename); + return args; +} + std::string renderLabels(const Strings & labels) { std::string res; diff --git a/src/libutil/args.hh b/src/libutil/args.hh index ad5fcca39..22702c2d8 100644 --- a/src/libutil/args.hh +++ b/src/libutil/args.hh @@ -190,6 +190,9 @@ public: Strings argvToStrings(int argc, char * * argv); +/* Helper function to generate args that invoke $EDITOR on filename:lineno */ +Strings editorFor(std::string filename, int lineno); + /* Helper function for rendering argument labels. */ std::string renderLabels(const Strings & labels); diff --git a/src/nix/edit.cc b/src/nix/edit.cc index a6169f118..3a27b9cca 100644 --- a/src/nix/edit.cc +++ b/src/nix/edit.cc @@ -59,22 +59,15 @@ struct CmdEdit : InstallableCommand throw Error("cannot parse line number '%s'", pos); } - auto editor = getEnv("EDITOR", "cat"); - - auto args = tokenizeString(editor); - - if (editor.find("emacs") != std::string::npos || - editor.find("nano") != std::string::npos || - editor.find("vim") != std::string::npos) - args.push_back(fmt("+%d", lineno)); - - args.push_back(filename); - stopProgressBar(); + auto args = editorFor(filename, lineno); + execvp(args.front().c_str(), stringsToCharPtrs(args).data()); - throw SysError("cannot run editor '%s'", editor); + std::string command; + for (const auto &arg : args) command += " '" + arg + "'"; + throw SysError("cannot run command%s", command); } }; diff --git a/src/nix/repl.cc b/src/nix/repl.cc index 79f365cdb..d4334cf7f 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -506,15 +506,8 @@ bool NixRepl::processLine(string line) } // Open in EDITOR - auto editor = getEnv("EDITOR", "cat"); - auto args = tokenizeString(editor); - if (lineno > 0 && ( - editor.find("emacs") != std::string::npos || - editor.find("nano") != std::string::npos || - editor.find("vim") != std::string::npos)) - args.push_back(fmt("+%d", lineno)); - args.push_back(filename); - editor = args.front(); + auto args = editorFor(filename, lineno); + auto editor = args.front(); args.pop_front(); runProgram(editor, args); From 59c72497696eaafa294c34699795788d24d68c68 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Wed, 23 Oct 2019 17:21:10 +0200 Subject: [PATCH 04/20] libexpr: add findDerivationFilename extract the derivation to filename:lineno heuristic --- src/libexpr/attr-path.cc | 28 ++++++++++++++++++++++++++++ src/libexpr/attr-path.hh | 5 +++++ src/nix/edit.cc | 23 ++--------------------- src/nix/repl.cc | 23 +---------------------- 4 files changed, 36 insertions(+), 43 deletions(-) diff --git a/src/libexpr/attr-path.cc b/src/libexpr/attr-path.cc index b0f80db32..7a6d8dfd0 100644 --- a/src/libexpr/attr-path.cc +++ b/src/libexpr/attr-path.cc @@ -93,4 +93,32 @@ Value * findAlongAttrPath(EvalState & state, const string & attrPath, } +std::tuple findDerivationFilename(EvalState & state, Value & v, std::string what) +{ + Value * v2; + try { + auto dummyArgs = state.allocBindings(0); + v2 = findAlongAttrPath(state, "meta.position", *dummyArgs, v); + } catch (Error &) { + throw Error("package '%s' has no source location information", what); + } + + auto pos = state.forceString(*v2); + + auto colon = pos.rfind(':'); + if (colon == std::string::npos) + throw Error("cannot parse meta.position attribute '%s'", pos); + + std::string filename(pos, 0, colon); + int lineno; + try { + lineno = std::stoi(std::string(pos, colon + 1)); + } catch (std::invalid_argument & e) { + throw Error("cannot parse line number '%s'", pos); + } + + return std::make_tuple(filename, lineno); +} + + } diff --git a/src/libexpr/attr-path.hh b/src/libexpr/attr-path.hh index 46a341950..dca94cc78 100644 --- a/src/libexpr/attr-path.hh +++ b/src/libexpr/attr-path.hh @@ -4,10 +4,15 @@ #include #include +#include namespace nix { Value * findAlongAttrPath(EvalState & state, const string & attrPath, Bindings & autoArgs, Value & vIn); +/* Heuristic to find the filename and lineno or a derivation. */ +std::tuple findDerivationFilename(EvalState & state, + Value & v, std::string what); + } diff --git a/src/nix/edit.cc b/src/nix/edit.cc index 3a27b9cca..a4aa40bed 100644 --- a/src/nix/edit.cc +++ b/src/nix/edit.cc @@ -36,28 +36,9 @@ struct CmdEdit : InstallableCommand auto v = installable->toValue(*state); - Value * v2; - try { - auto dummyArgs = state->allocBindings(0); - v2 = findAlongAttrPath(*state, "meta.position", *dummyArgs, *v); - } catch (Error &) { - throw Error("package '%s' has no source location information", installable->what()); - } - - auto pos = state->forceString(*v2); - debug("position is %s", pos); - - auto colon = pos.rfind(':'); - if (colon == std::string::npos) - throw Error("cannot parse meta.position attribute '%s'", pos); - - std::string filename(pos, 0, colon); + std::string filename; int lineno; - try { - lineno = std::stoi(std::string(pos, colon + 1)); - } catch (std::invalid_argument & e) { - throw Error("cannot parse line number '%s'", pos); - } + std::tie(filename, lineno) = findDerivationFilename(*state, *v, installable->what()); stopProgressBar(); diff --git a/src/nix/repl.cc b/src/nix/repl.cc index d4334cf7f..5cfb408f7 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -481,28 +481,7 @@ bool NixRepl::processLine(string line) lineno = 0; } else { // assume it's a derivation - Value * v2; - try { - auto dummyArgs = state.allocBindings(0); - v2 = findAlongAttrPath(state, "meta.position", *dummyArgs, v); - } catch (Error &) { - throw Error("package '%s' has no source location information", arg); - } - - auto pos = state.forceString(*v2); - debug("position is %s", pos); - - auto colon = pos.rfind(':'); - if (colon == std::string::npos) - throw Error("cannot parse meta.position attribute '%s'", pos); - - filename = std::string(pos, 0, colon); - try { - lineno = std::stoi(std::string(pos, colon + 1)); - } catch (std::invalid_argument & e) { - throw Error("cannot parse line number '%s'", pos); - } - + std::tie(filename, lineno) = findDerivationFilename(state, v, arg); } // Open in EDITOR From 70cab0587dcbc2d0600c07c96b477a2ea2fcd6f3 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 25 Oct 2019 07:23:05 -0400 Subject: [PATCH 05/20] Switch to nixpkgs 19.09 --- release.nix | 2 +- shell.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/release.nix b/release.nix index 0fe683518..8fcf04680 100644 --- a/release.nix +++ b/release.nix @@ -1,5 +1,5 @@ { nix ? builtins.fetchGit ./. -, nixpkgs ? builtins.fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.03.tar.gz +, nixpkgs ? builtins.fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.09.tar.gz , officialRelease ? false , systems ? [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ] }: diff --git a/shell.nix b/shell.nix index 8167f87a2..9c504f024 100644 --- a/shell.nix +++ b/shell.nix @@ -1,6 +1,6 @@ { useClang ? false }: -with import (builtins.fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.03.tar.gz) {}; +with import (builtins.fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.09.tar.gz) {}; with import ./release-common.nix { inherit pkgs; }; From ec448f8bb694b6f9546e49fe6a79b86ff2b2f90a Mon Sep 17 00:00:00 2001 From: zimbatm Date: Mon, 28 Oct 2019 21:22:38 +0100 Subject: [PATCH 06/20] libexpr: findDerivationFilename return Pos instead of tuple --- src/libexpr/attr-path.cc | 8 +++++--- src/libexpr/attr-path.hh | 6 ++---- src/nix/edit.cc | 6 +++--- src/nix/repl.cc | 4 +++- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/libexpr/attr-path.cc b/src/libexpr/attr-path.cc index 7a6d8dfd0..c86dbeebb 100644 --- a/src/libexpr/attr-path.cc +++ b/src/libexpr/attr-path.cc @@ -93,7 +93,7 @@ Value * findAlongAttrPath(EvalState & state, const string & attrPath, } -std::tuple findDerivationFilename(EvalState & state, Value & v, std::string what) +Pos findDerivationFilename(EvalState & state, Value & v, std::string what) { Value * v2; try { @@ -110,14 +110,16 @@ std::tuple findDerivationFilename(EvalState & state, Value & v throw Error("cannot parse meta.position attribute '%s'", pos); std::string filename(pos, 0, colon); - int lineno; + unsigned int lineno; try { lineno = std::stoi(std::string(pos, colon + 1)); } catch (std::invalid_argument & e) { throw Error("cannot parse line number '%s'", pos); } - return std::make_tuple(filename, lineno); + Symbol file = state.symbols.create(filename); + + return { file, lineno, 0 }; } diff --git a/src/libexpr/attr-path.hh b/src/libexpr/attr-path.hh index dca94cc78..716e5ba27 100644 --- a/src/libexpr/attr-path.hh +++ b/src/libexpr/attr-path.hh @@ -4,15 +4,13 @@ #include #include -#include namespace nix { Value * findAlongAttrPath(EvalState & state, const string & attrPath, Bindings & autoArgs, Value & vIn); -/* Heuristic to find the filename and lineno or a derivation. */ -std::tuple findDerivationFilename(EvalState & state, - Value & v, std::string what); +/* Heuristic to find the filename and lineno or a nix value. */ +Pos findDerivationFilename(EvalState & state, Value & v, std::string what); } diff --git a/src/nix/edit.cc b/src/nix/edit.cc index a4aa40bed..d0607747d 100644 --- a/src/nix/edit.cc +++ b/src/nix/edit.cc @@ -36,9 +36,9 @@ struct CmdEdit : InstallableCommand auto v = installable->toValue(*state); - std::string filename; - int lineno; - std::tie(filename, lineno) = findDerivationFilename(*state, *v, installable->what()); + Pos pos = findDerivationFilename(*state, *v, installable->what()); + std::string filename(pos.file); + int lineno(pos.line); stopProgressBar(); diff --git a/src/nix/repl.cc b/src/nix/repl.cc index 5cfb408f7..ed67c285f 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -481,7 +481,9 @@ bool NixRepl::processLine(string line) lineno = 0; } else { // assume it's a derivation - std::tie(filename, lineno) = findDerivationFilename(state, v, arg); + Pos pos = findDerivationFilename(state, v, arg); + filename = pos.file; + lineno = pos.line; } // Open in EDITOR From 3774fe55fd6c96e80cc91e13fe0a231ce836ac47 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Mon, 28 Oct 2019 21:36:34 +0100 Subject: [PATCH 07/20] editorFor: take a pos object instead --- src/libutil/args.cc | 8 ++++---- src/libutil/args.hh | 3 ++- src/nix/edit.cc | 4 +--- src/nix/repl.cc | 13 +++++-------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/libutil/args.cc b/src/libutil/args.cc index 35ec3e4ab..b7baad375 100644 --- a/src/libutil/args.cc +++ b/src/libutil/args.cc @@ -178,16 +178,16 @@ Strings argvToStrings(int argc, char * * argv) return args; } -Strings editorFor(std::string filename, int lineno) +Strings editorFor(Pos pos) { auto editor = getEnv("EDITOR", "cat"); auto args = tokenizeString(editor); - if (lineno > 0 && ( + if (pos.line > 0 && ( editor.find("emacs") != std::string::npos || editor.find("nano") != std::string::npos || editor.find("vim") != std::string::npos)) - args.push_back(fmt("+%d", lineno)); - args.push_back(filename); + args.push_back(fmt("+%d", pos.line)); + args.push_back(pos.file); return args; } diff --git a/src/libutil/args.hh b/src/libutil/args.hh index 22702c2d8..1e29bd4fa 100644 --- a/src/libutil/args.hh +++ b/src/libutil/args.hh @@ -5,6 +5,7 @@ #include #include "util.hh" +#include "nixexpr.hh" namespace nix { @@ -191,7 +192,7 @@ public: Strings argvToStrings(int argc, char * * argv); /* Helper function to generate args that invoke $EDITOR on filename:lineno */ -Strings editorFor(std::string filename, int lineno); +Strings editorFor(Pos pos); /* Helper function for rendering argument labels. */ std::string renderLabels(const Strings & labels); diff --git a/src/nix/edit.cc b/src/nix/edit.cc index d0607747d..553765f13 100644 --- a/src/nix/edit.cc +++ b/src/nix/edit.cc @@ -37,12 +37,10 @@ struct CmdEdit : InstallableCommand auto v = installable->toValue(*state); Pos pos = findDerivationFilename(*state, *v, installable->what()); - std::string filename(pos.file); - int lineno(pos.line); stopProgressBar(); - auto args = editorFor(filename, lineno); + auto args = editorFor(pos); execvp(args.front().c_str(), stringsToCharPtrs(args).data()); diff --git a/src/nix/repl.cc b/src/nix/repl.cc index ed67c285f..683a117f3 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -472,22 +472,19 @@ bool NixRepl::processLine(string line) Value v; evalString(arg, v); - std::string filename; - int lineno = 0; + Pos pos; if (v.type == tPath || v.type == tString) { PathSet context; - filename = state.coerceToString(noPos, v, context); - lineno = 0; + auto filename = state.coerceToString(noPos, v, context); + pos.file = state.symbols.create(filename); } else { // assume it's a derivation - Pos pos = findDerivationFilename(state, v, arg); - filename = pos.file; - lineno = pos.line; + pos = findDerivationFilename(state, v, arg); } // Open in EDITOR - auto args = editorFor(filename, lineno); + auto args = editorFor(pos); auto editor = args.front(); args.pop_front(); runProgram(editor, args); From d407f4d15f86aca585e0edebc5bc74ab8b1bebd1 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Mon, 28 Oct 2019 21:37:22 +0100 Subject: [PATCH 08/20] nix repl: also handle lambda edit --- src/nix/repl.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nix/repl.cc b/src/nix/repl.cc index 683a117f3..35c7aec66 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -478,6 +478,8 @@ bool NixRepl::processLine(string line) PathSet context; auto filename = state.coerceToString(noPos, v, context); pos.file = state.symbols.create(filename); + } else if (v.type == tLambda) { + pos = v.lambda.fun->pos; } else { // assume it's a derivation pos = findDerivationFilename(state, v, arg); From 9a2505965667267f03a8385926f3b31a47732ed5 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Mon, 28 Oct 2019 21:40:02 +0100 Subject: [PATCH 09/20] findDerivationFilename: add FIXME --- src/libexpr/attr-path.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libexpr/attr-path.cc b/src/libexpr/attr-path.cc index c86dbeebb..06b472d8b 100644 --- a/src/libexpr/attr-path.cc +++ b/src/libexpr/attr-path.cc @@ -103,6 +103,8 @@ Pos findDerivationFilename(EvalState & state, Value & v, std::string what) throw Error("package '%s' has no source location information", what); } + // FIXME: is it possible to extract the Pos object instead of doing this + // toString + parsing? auto pos = state.forceString(*v2); auto colon = pos.rfind(':'); From 99aac72a16544637e9ab2e14c7b28f64b4638c8e Mon Sep 17 00:00:00 2001 From: Kevin Stock Date: Wed, 30 Oct 2019 16:53:04 -0400 Subject: [PATCH 10/20] docs: fix upper bound on number of consumed cores --- doc/manual/advanced-topics/cores-vs-jobs.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manual/advanced-topics/cores-vs-jobs.xml b/doc/manual/advanced-topics/cores-vs-jobs.xml index eba645faf..4d58ac7c5 100644 --- a/doc/manual/advanced-topics/cores-vs-jobs.xml +++ b/doc/manual/advanced-topics/cores-vs-jobs.xml @@ -36,8 +36,8 @@ to , unless equals 0, in which case NIX_BUILD_CORES will be the total number of cores in the system. -The total number of consumed cores is a simple multiplication, - * NIX_BUILD_CORES. +The maximum number of consumed cores is a simple multiplication, + * NIX_BUILD_CORES. The balance on how to set these two independent variables depends upon each builder's workload and hardware. Here are a few example From f1d4ba2afd1169b6c15248e50e30b592e514bb21 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 1 Nov 2019 13:25:15 -0400 Subject: [PATCH 11/20] Update man to show that nix-shell allows --arg --- doc/manual/command-ref/opt-common.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/manual/command-ref/opt-common.xml b/doc/manual/command-ref/opt-common.xml index b8a2f260e..28ec42bbc 100644 --- a/doc/manual/command-ref/opt-common.xml +++ b/doc/manual/command-ref/opt-common.xml @@ -243,9 +243,10 @@ name value This option is accepted by - nix-env, nix-instantiate and - nix-build. When evaluating Nix expressions, the - expression evaluator will automatically try to call functions that + nix-env, nix-instantiate, + nix-shellnix-build. + When evaluating Nix expressions, the expression evaluator will + automatically try to call functions that it encounters. It can automatically call functions for which every argument has a default value (e.g., { argName ? From 808cb6444e33c413fad220d2cf9c565fa68614f0 Mon Sep 17 00:00:00 2001 From: Kevin Stock Date: Sat, 2 Nov 2019 17:55:53 -0400 Subject: [PATCH 12/20] docs: xref doesn't render in title The `post-build-hook` text currently appears in the index, but not on the actual title line of the section, this follows the pattern used in a previous section to get a reference into a title. --- doc/manual/advanced-topics/post-build-hook.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/advanced-topics/post-build-hook.xml b/doc/manual/advanced-topics/post-build-hook.xml index 3dc43ee79..08a7a772f 100644 --- a/doc/manual/advanced-topics/post-build-hook.xml +++ b/doc/manual/advanced-topics/post-build-hook.xml @@ -5,7 +5,7 @@ version="5.0" > -Using the <xref linkend="conf-post-build-hook" /> +Using the <option linkend="conf-post-build-hook">post-build-hook</option> Uploading to an S3-compatible binary cache after each build From cea05e5ee758daad40047db0b861980d80da2e85 Mon Sep 17 00:00:00 2001 From: Kevin Stock Date: Mon, 4 Nov 2019 16:23:03 -0500 Subject: [PATCH 13/20] docs: correct default location of log directory --- doc/manual/command-ref/env-common.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/command-ref/env-common.xml b/doc/manual/command-ref/env-common.xml index 6a3aaae71..696d68c34 100644 --- a/doc/manual/command-ref/env-common.xml +++ b/doc/manual/command-ref/env-common.xml @@ -122,7 +122,7 @@ $ mount -o bind /mnt/otherdisk/nix /nix NIX_LOG_DIR Overrides the location of the Nix log directory - (default prefix/log/nix). + (default prefix/var/log/nix). From 1b600ecd14049985dc1001d22d6495810ca418a0 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 5 Nov 2019 10:25:09 +0100 Subject: [PATCH 14/20] Don't use SOCK_CLOEXEC on macOS https://hydra.nixos.org/build/105428308 --- src/libutil/util.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libutil/util.cc b/src/libutil/util.cc index d29802bcd..34c1d96dc 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -1567,7 +1567,11 @@ std::unique_ptr createInterruptCallback(std::function AutoCloseFD createUnixDomainSocket(const Path & path, mode_t mode) { - AutoCloseFD fdSocket = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); + AutoCloseFD fdSocket = socket(PF_UNIX, SOCK_STREAM + #ifdef SOCK_CLOEXEC + | SOCK_CLOEXEC + #endif + , 0); if (!fdSocket) throw SysError("cannot create Unix domain socket"); From e1725ba946aa89271bd8ef83f9ecc2e2dc6eb5df Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 5 Nov 2019 11:12:25 +0100 Subject: [PATCH 15/20] Fix VM tests --- tests/nix-copy-closure.nix | 4 ++-- tests/remote-builds.nix | 4 ++-- tests/setuid.nix | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/nix-copy-closure.nix b/tests/nix-copy-closure.nix index 0dc147fb3..bb5db7410 100644 --- a/tests/nix-copy-closure.nix +++ b/tests/nix-copy-closure.nix @@ -8,11 +8,11 @@ makeTest (let pkgA = pkgs.cowsay; pkgB = pkgs.wget; pkgC = pkgs.hello; in { nodes = { client = - { config, pkgs, ... }: + { config, lib, pkgs, ... }: { virtualisation.writableStore = true; virtualisation.pathsInNixDB = [ pkgA ]; nix.package = nix; - nix.binaryCaches = [ ]; + nix.binaryCaches = lib.mkForce [ ]; }; server = diff --git a/tests/remote-builds.nix b/tests/remote-builds.nix index b867f13b4..18d490830 100644 --- a/tests/remote-builds.nix +++ b/tests/remote-builds.nix @@ -40,7 +40,7 @@ in builder2 = builder; client = - { config, pkgs, ... }: + { config, lib, pkgs, ... }: { nix.maxJobs = 0; # force remote building nix.distributedBuilds = true; nix.buildMachines = @@ -60,7 +60,7 @@ in virtualisation.writableStore = true; virtualisation.pathsInNixDB = [ config.system.build.extraUtils ]; nix.package = nix; - nix.binaryCaches = [ ]; + nix.binaryCaches = lib.mkForce [ ]; programs.ssh.extraConfig = "ConnectTimeout 30"; }; }; diff --git a/tests/setuid.nix b/tests/setuid.nix index 77e83c8d6..63d3c05cb 100644 --- a/tests/setuid.nix +++ b/tests/setuid.nix @@ -10,7 +10,7 @@ makeTest { { config, lib, pkgs, ... }: { virtualisation.writableStore = true; nix.package = nix; - nix.binaryCaches = [ ]; + nix.binaryCaches = lib.mkForce [ ]; nix.nixPath = [ "nixpkgs=${lib.cleanSource pkgs.path}" ]; virtualisation.pathsInNixDB = [ pkgs.stdenv pkgs.pkgsi686Linux.stdenv ]; }; From 81a9b93689c76a9b90134bcc5ad8a6b851590599 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 5 Nov 2019 11:21:32 +0100 Subject: [PATCH 16/20] Fix manual build --- doc/manual/command-ref/opt-common.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/command-ref/opt-common.xml b/doc/manual/command-ref/opt-common.xml index 28ec42bbc..6a8107be9 100644 --- a/doc/manual/command-ref/opt-common.xml +++ b/doc/manual/command-ref/opt-common.xml @@ -244,7 +244,7 @@ This option is accepted by nix-env, nix-instantiate, - nix-shellnix-build. + nix-shell and nix-build. When evaluating Nix expressions, the expression evaluator will automatically try to call functions that it encounters. It can automatically call functions for which every From b4e260d887441fde9ab568dff7c21a77d7cff904 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 5 Nov 2019 16:00:30 +0100 Subject: [PATCH 17/20] Disable shellcheck It's broken at the moment: https://hydra.nixos.org/build/105746055 Also it pulls in GHC which is a pretty big dependency. --- release.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.nix b/release.nix index 8fcf04680..e512a7671 100644 --- a/release.nix +++ b/release.nix @@ -128,7 +128,7 @@ let in runCommand "nix-binary-tarball-${version}" - { nativeBuildInputs = lib.optional (system != "aarch64-linux") shellcheck; + { #nativeBuildInputs = lib.optional (system != "aarch64-linux") shellcheck; meta.description = "Distribution-independent Nix bootstrap binaries for ${system}"; } '' From b874272f7a121a859e7c05abe4d7818bc852eba8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 30 Oct 2019 14:43:09 +0100 Subject: [PATCH 18/20] Make --enable-gc the default --- configure.ac | 4 ++-- release-common.nix | 4 +--- release.nix | 2 -- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index ebe6d4267..4a6eaac8a 100644 --- a/configure.ac +++ b/configure.ac @@ -255,8 +255,8 @@ fi # Whether to use the Boehm garbage collector. AC_ARG_ENABLE(gc, AC_HELP_STRING([--enable-gc], - [enable garbage collection in the Nix expression evaluator (requires Boehm GC) [default=no]]), - gc=$enableval, gc=no) + [enable garbage collection in the Nix expression evaluator (requires Boehm GC) [default=yes]]), + gc=$enableval, gc=yes) if test "$gc" = yes; then PKG_CHECK_MODULES([BDW_GC], [bdw-gc]) CXXFLAGS="$BDW_GC_CFLAGS $CXXFLAGS" diff --git a/release-common.nix b/release-common.nix index 2e8a951b9..11944a631 100644 --- a/release-common.nix +++ b/release-common.nix @@ -30,9 +30,7 @@ rec { }); configureFlags = - [ - "--enable-gc" - ] ++ lib.optionals stdenv.isLinux [ + lib.optionals stdenv.isLinux [ "--with-sandbox-shell=${sh}/bin/busybox" ]; diff --git a/release.nix b/release.nix index e512a7671..0b74de390 100644 --- a/release.nix +++ b/release.nix @@ -25,8 +25,6 @@ let buildInputs = tarballDeps ++ buildDeps; - configureFlags = "--enable-gc"; - postUnpack = '' (cd $sourceRoot && find . -type f) | cut -c3- > $sourceRoot/.dist-files cat $sourceRoot/.dist-files From 7614a127a0ef52868c35fa9d6ae6398b7297d408 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 6 Nov 2019 10:35:31 +0100 Subject: [PATCH 19/20] Fix binaryTarball test --- release.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.nix b/release.nix index 0b74de390..c5bee782a 100644 --- a/release.nix +++ b/release.nix @@ -260,7 +260,7 @@ let x86_64-linux = "${build.x86_64-linux}"; } EOF - su - alice -c 'nix upgrade-nix -vvv --nix-store-paths-url file:///tmp/paths.nix' + su - alice -c 'nix --experimental-features nix-command upgrade-nix -vvv --nix-store-paths-url file:///tmp/paths.nix' (! [ -L /home/alice/.profile-1-link ]) su - alice -c 'PAGER= nix-store -qR ${build.x86_64-linux}' From 35732a95bcdc0a4b4492845205e6283fcc88fd0d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 6 Nov 2019 10:36:06 +0100 Subject: [PATCH 20/20] Disable the evalNixpkgs test It constantly OOMs. https://hydra.nixos.org/build/105784912 --- release.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/release.nix b/release.nix index c5bee782a..b137f1d2d 100644 --- a/release.nix +++ b/release.nix @@ -269,6 +269,7 @@ let umount /nix ''); # */ + /* tests.evalNixpkgs = import (nixpkgs + "/pkgs/top-level/make-tarball.nix") { inherit nixpkgs; @@ -276,6 +277,7 @@ let nix = build.x86_64-linux; officialRelease = false; }; + */ tests.evalNixOS = pkgs.runCommand "eval-nixos" { buildInputs = [ build.x86_64-linux ]; } @@ -324,7 +326,7 @@ let tests.remoteBuilds tests.nix-copy-closure tests.binaryTarball - tests.evalNixpkgs + #tests.evalNixpkgs tests.evalNixOS installerScript ];