Compare commits

...

3 Commits

Author SHA1 Message Date
Jörg Thalheim ac566dea95
update from upstream 2021-03-14 23:16:57 +01:00
Jörg Thalheim 0f22a976e5
update nixpkgs 2021-03-14 23:16:46 +01:00
Jörg Thalheim 9205107bd6
add gitignore 2021-03-14 23:16:31 +01:00
3 changed files with 72 additions and 19 deletions

42
.gitignore vendored Normal file
View File

@ -0,0 +1,42 @@
.DS_Store
.idea
*.log
tmp/
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# build directory
/build

View File

@ -2,11 +2,11 @@
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1605370193,
"narHash": "sha256-YyMTf3URDL/otKdKgtoMChu4vfVL3vCMkRqpGifhUn0=",
"lastModified": 1614513358,
"narHash": "sha256-LakhOx3S1dRjnh0b5Dg3mbZyH0ToC9I8Y2wKSkBaTzU=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5021eac20303a61fafe17224c087f5519baed54d",
"rev": "5466c5bbece17adaab2d82fae80b46e807611bf3",
"type": "github"
},
"original": {
@ -17,11 +17,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1606657618,
"narHash": "sha256-I/sA0wtjqy1JVqHX2HnqdJNqulap+mj8hp/kRreW36o=",
"lastModified": 1615756511,
"narHash": "sha256-rcuG5eYBtDlN0yTJdFw8GktML7Og1hFctp44wE3MHp4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a86b1f48bf373706e5ef50547ceeaeaec9ee7d34",
"rev": "87acb6d60bfe9469475dbaa80df90971aaa21997",
"type": "github"
},
"original": {

View File

@ -1,6 +1,8 @@
#include <map>
#include <iostream>
#include <iomanip>
#include <thread>
#include <algorithm>
#include <nix/config.h>
#include <nix/shared.hh>
@ -41,9 +43,15 @@ struct MyArgs : MixEvalArgs, MixCommonArgs
.longName = "help",
.description = "show usage information",
.handler = {[&]() {
printHelp(programName, std::cout);
throw Exit();
}}
std::cout << "Usage:" << std::endl;
std::cout << " " << "hydra-eval-jobs [options] expr" << std::endl;
for (const auto & [name, flag] : longFlags) {
if (hiddenCategories.count(flag->category)) {
continue;
}
printf(" --%-20s %s\n", name.c_str(), flag->description.c_str());
}
}},
});
addFlag({
@ -96,12 +104,12 @@ static std::string queryMetaStrings(EvalState & state, DrvInfo & drv, const stri
rec = [&](Value & v) {
state.forceValue(v);
if (v.type == tString)
if (v.type() == nString)
res.push_back(v.string.s);
else if (v.isList())
for (unsigned int n = 0; n < v.listSize(); ++n)
rec(*v.listElems()[n]);
else if (v.type == tAttrs) {
else if (v.type() == nAttrs) {
auto a = v.attrs->find(state.symbols.create(subAttribute));
if (a != v.attrs->end())
res.push_back(state.forceString(*a->value));
@ -219,7 +227,7 @@ static void worker(
for (unsigned int n = 0; n < a->value->listSize(); ++n) {
auto v = a->value->listElems()[n];
state.forceValue(*v);
if (v->type == tString)
if (v->type() == nString)
job["namedConstituents"].push_back(state.forceStringNoCtx(*v));
}
}
@ -242,7 +250,7 @@ static void worker(
reply["job"] = std::move(job);
}
else if (v->type == tAttrs) {
else if (v->type() == nAttrs) {
auto attrs = nlohmann::json::array();
StringSet ss;
for (auto & i : v->attrs->lexicographicOrder()) {
@ -256,18 +264,19 @@ static void worker(
reply["attrs"] = std::move(attrs);
}
else if (v->type == tNull)
else if (v->type() == nNull)
;
else throw TypeError("attribute '%s' is %s, which is not supported", attrPath, showType(*v));
} catch (EvalError & e) {
auto msg = e.msg();
// Transmits the error we got from the previous evaluation
// in the JSON output.
reply["error"] = filterANSIEscapes(e.msg(), true);
reply["error"] = filterANSIEscapes(msg, true);
// Don't forget to print it into the STDERR log, this is
// what's shown in the Hydra UI.
printError("error: %s", reply["error"]);
printError(msg);
}
writeLine(to.get(), reply.dump());
@ -347,13 +356,15 @@ int main(int argc, char * * argv)
EvalState state(myArgs.searchPath, openStore());
Bindings & autoArgs = *myArgs.getAutoArgs(state);
worker(state, autoArgs, *to, *from);
} catch (std::exception & e) {
} catch (Error & e) {
nlohmann::json err;
err["error"] = e.what();
auto msg = e.msg();
err["error"] = filterANSIEscapes(msg, true);
printError(msg);
writeLine(to->get(), err.dump());
// Don't forget to print it into the STDERR log, this is
// what's shown in the Hydra UI.
printError("error: %s", err["error"]);
writeLine(to->get(), "restart");
}
},
ProcessOptions { .allowVfork = false });