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

View File

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