mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 09:06:15 +02:00
Write "T x" instead of "auto x = T"
That's just silly. Hopefully this also fixes the Debian build failure: http://hydra.nixos.org/build/40371644
This commit is contained in:
parent
46e36f9b73
commit
5039d3b9de
1 changed files with 32 additions and 35 deletions
|
@ -21,10 +21,10 @@ extern char ** environ;
|
||||||
*/
|
*/
|
||||||
std::vector<string> shellwords(const string & s)
|
std::vector<string> shellwords(const string & s)
|
||||||
{
|
{
|
||||||
auto whitespace = std::regex("^(\\s+).*");
|
std::regex whitespace("^(\\s+).*");
|
||||||
auto begin = s.cbegin();
|
auto begin = s.cbegin();
|
||||||
auto res = std::vector<string>{};
|
std::vector<string> res;
|
||||||
auto cur = stringstream{};
|
std::stringstream cur;
|
||||||
enum state {
|
enum state {
|
||||||
sBegin,
|
sBegin,
|
||||||
sQuote
|
sQuote
|
||||||
|
@ -33,7 +33,7 @@ std::vector<string> shellwords(const string & s)
|
||||||
auto it = begin;
|
auto it = begin;
|
||||||
for (; it != s.cend(); ++it) {
|
for (; it != s.cend(); ++it) {
|
||||||
if (st == sBegin) {
|
if (st == sBegin) {
|
||||||
auto match = std::smatch{};
|
std::smatch match;
|
||||||
if (regex_search(it, s.cend(), match, whitespace)) {
|
if (regex_search(it, s.cend(), match, whitespace)) {
|
||||||
cur << string(begin, it);
|
cur << string(begin, it);
|
||||||
res.push_back(cur.str());
|
res.push_back(cur.str());
|
||||||
|
@ -76,26 +76,26 @@ int main(int argc, char ** argv)
|
||||||
auto packages = false;
|
auto packages = false;
|
||||||
auto interactive = true;
|
auto interactive = true;
|
||||||
|
|
||||||
auto instArgs = Strings{};
|
Strings instArgs;
|
||||||
auto buildArgs = Strings{};
|
Strings buildArgs;
|
||||||
auto exprs = Strings{};
|
Strings exprs;
|
||||||
|
|
||||||
auto shell = getEnv("SHELL", "/bin/sh");
|
auto shell = getEnv("SHELL", "/bin/sh");
|
||||||
auto envCommand = string{}; // interactive shell
|
std::string envCommand; // interactive shell
|
||||||
auto envExclude = Strings{};
|
Strings envExclude;
|
||||||
|
|
||||||
auto myName = runEnv ? "nix-shell" : "nix-build";
|
auto myName = runEnv ? "nix-shell" : "nix-build";
|
||||||
|
|
||||||
auto inShebang = false;
|
auto inShebang = false;
|
||||||
auto script = string{};
|
std::string script;
|
||||||
auto savedArgs = std::vector<string>{};
|
std::vector<string> savedArgs;
|
||||||
|
|
||||||
auto tmpDir = AutoDelete{createTempDir("", myName)};
|
AutoDelete tmpDir(createTempDir("", myName));
|
||||||
|
|
||||||
auto outLink = string("./result");
|
std::string outLink = "./result";
|
||||||
auto drvLink = (Path) tmpDir + "/derivation";
|
auto drvLink = (Path) tmpDir + "/derivation";
|
||||||
|
|
||||||
auto args = std::vector<string>{};
|
std::vector<string> args;
|
||||||
for (int i = 1; i < argc; ++i)
|
for (int i = 1; i < argc; ++i)
|
||||||
args.push_back(argv[i]);
|
args.push_back(argv[i]);
|
||||||
// Heuristic to see if we're invoked as a shebang script, namely, if we
|
// Heuristic to see if we're invoked as a shebang script, namely, if we
|
||||||
|
@ -110,7 +110,7 @@ int main(int argc, char ** argv)
|
||||||
inShebang = true;
|
inShebang = true;
|
||||||
for (int i = 2; i < argc - 1; ++i)
|
for (int i = 2; i < argc - 1; ++i)
|
||||||
savedArgs.push_back(argv[i]);
|
savedArgs.push_back(argv[i]);
|
||||||
args = std::vector<string>{};
|
std::vector<string> args;
|
||||||
for (auto line : lines) {
|
for (auto line : lines) {
|
||||||
line = chomp(line);
|
line = chomp(line);
|
||||||
std::smatch match;
|
std::smatch match;
|
||||||
|
@ -284,7 +284,7 @@ int main(int argc, char ** argv)
|
||||||
execArgs = "-a PERL";
|
execArgs = "-a PERL";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto joined = stringstream{};
|
std::ostringstream joined;
|
||||||
for (const auto & i : savedArgs)
|
for (const auto & i : savedArgs)
|
||||||
joined << shellEscape(i) << ' ';
|
joined << shellEscape(i) << ' ';
|
||||||
|
|
||||||
|
@ -320,7 +320,7 @@ int main(int argc, char ** argv)
|
||||||
|
|
||||||
if (packages) {
|
if (packages) {
|
||||||
instArgs.push_back("--expr");
|
instArgs.push_back("--expr");
|
||||||
auto joined = stringstream{};
|
std::ostringstream joined;
|
||||||
joined << "with import <nixpkgs> { }; runCommand \"shell\" { buildInputs = [ ";
|
joined << "with import <nixpkgs> { }; runCommand \"shell\" { buildInputs = [ ";
|
||||||
for (const auto & i : exprs)
|
for (const auto & i : exprs)
|
||||||
joined << '(' << i << ") ";
|
joined << '(' << i << ") ";
|
||||||
|
@ -338,14 +338,14 @@ int main(int argc, char ** argv)
|
||||||
|
|
||||||
for (auto & expr : exprs) {
|
for (auto & expr : exprs) {
|
||||||
// Instantiate.
|
// Instantiate.
|
||||||
auto drvPaths = std::vector<string>{};
|
std::vector<string> drvPaths;
|
||||||
if (!std::regex_match(expr, std::regex("^/.*\\.drv$"))) {
|
if (!std::regex_match(expr, std::regex("^/.*\\.drv$"))) {
|
||||||
// If we're in a #! script, interpret filenames relative to the
|
// If we're in a #! script, interpret filenames relative to the
|
||||||
// script.
|
// script.
|
||||||
if (inShebang && !packages)
|
if (inShebang && !packages)
|
||||||
expr = absPath(expr, dirOf(script));
|
expr = absPath(expr, dirOf(script));
|
||||||
|
|
||||||
auto instantiateArgs = Strings{"--add-root", drvLink, "--indirect"};
|
Strings instantiateArgs{"--add-root", drvLink, "--indirect"};
|
||||||
for (const auto & arg : instArgs)
|
for (const auto & arg : instArgs)
|
||||||
instantiateArgs.push_back(arg);
|
instantiateArgs.push_back(arg);
|
||||||
instantiateArgs.push_back(expr);
|
instantiateArgs.push_back(expr);
|
||||||
|
@ -365,7 +365,7 @@ int main(int argc, char ** argv)
|
||||||
auto drv = store->derivationFromPath(drvPath);
|
auto drv = store->derivationFromPath(drvPath);
|
||||||
|
|
||||||
// Build or fetch all dependencies of the derivation.
|
// Build or fetch all dependencies of the derivation.
|
||||||
auto nixStoreArgs = Strings{"-r", "--no-output", "--no-gc-warning"};
|
Strings nixStoreArgs{"-r", "--no-output", "--no-gc-warning"};
|
||||||
for (const auto & arg : buildArgs)
|
for (const auto & arg : buildArgs)
|
||||||
nixStoreArgs.push_back(arg);
|
nixStoreArgs.push_back(arg);
|
||||||
for (const auto & input : drv.inputDrvs)
|
for (const auto & input : drv.inputDrvs)
|
||||||
|
@ -378,14 +378,14 @@ int main(int argc, char ** argv)
|
||||||
// Set the environment.
|
// Set the environment.
|
||||||
auto tmp = getEnv("TMPDIR", getEnv("XDG_RUNTIME_DIR", "/tmp"));
|
auto tmp = getEnv("TMPDIR", getEnv("XDG_RUNTIME_DIR", "/tmp"));
|
||||||
if (pure) {
|
if (pure) {
|
||||||
auto skippedEnv = std::vector<string>{"HOME", "USER", "LOGNAME", "DISPLAY", "PATH", "TERM", "IN_NIX_SHELL", "TZ", "PAGER", "NIX_BUILD_SHELL"};
|
std::vector<string> skippedEnv{"HOME", "USER", "LOGNAME", "DISPLAY", "PATH", "TERM", "IN_NIX_SHELL", "TZ", "PAGER", "NIX_BUILD_SHELL"};
|
||||||
auto removed = std::vector<string>{};
|
std::vector<string> removed;
|
||||||
for (auto i = size_t{0}; environ[i]; ++i) {
|
for (auto i = size_t{0}; environ[i]; ++i) {
|
||||||
auto eq = strchr(environ[i], '=');
|
auto eq = strchr(environ[i], '=');
|
||||||
if (!eq)
|
if (!eq)
|
||||||
// invalid env, just keep going
|
// invalid env, just keep going
|
||||||
continue;
|
continue;
|
||||||
auto name = string(environ[i], eq);
|
std::string name(environ[i], eq);
|
||||||
if (find(skippedEnv.begin(), skippedEnv.end(), name) == skippedEnv.end())
|
if (find(skippedEnv.begin(), skippedEnv.end(), name) == skippedEnv.end())
|
||||||
removed.emplace_back(std::move(name));
|
removed.emplace_back(std::move(name));
|
||||||
}
|
}
|
||||||
|
@ -435,11 +435,11 @@ int main(int argc, char ** argv)
|
||||||
// ./result, ./result-dev, and so on, rather than ./result,
|
// ./result, ./result-dev, and so on, rather than ./result,
|
||||||
// ./result-2-dev, and so on. This combines multiple derivation
|
// ./result-2-dev, and so on. This combines multiple derivation
|
||||||
// paths into one "/nix/store/drv-path!out1,out2,..." argument.
|
// paths into one "/nix/store/drv-path!out1,out2,..." argument.
|
||||||
auto prevDrvPath = string{};
|
std::string prevDrvPath;
|
||||||
auto drvPaths2 = Strings{};
|
Strings drvPaths2;
|
||||||
for (const auto & drvPath : drvPaths) {
|
for (const auto & drvPath : drvPaths) {
|
||||||
auto p = drvPath;
|
auto p = drvPath;
|
||||||
auto output = string{"out"};
|
std::string output = "out";
|
||||||
std::smatch match;
|
std::smatch match;
|
||||||
if (std::regex_match(drvPath, match, std::regex("(.*)!(.*)"))) {
|
if (std::regex_match(drvPath, match, std::regex("(.*)!(.*)"))) {
|
||||||
p = match[1].str();
|
p = match[1].str();
|
||||||
|
@ -458,25 +458,22 @@ int main(int argc, char ** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Build.
|
// Build.
|
||||||
auto outPaths = Strings{};
|
Strings outPaths;
|
||||||
auto nixStoreArgs = Strings{"--add-root", outLink, "--indirect", "-r"};
|
Strings nixStoreArgs{"--add-root", outLink, "--indirect", "-r"};
|
||||||
for (const auto & arg : buildArgs)
|
for (const auto & arg : buildArgs)
|
||||||
nixStoreArgs.push_back(arg);
|
nixStoreArgs.push_back(arg);
|
||||||
for (const auto & path : drvPaths2)
|
for (const auto & path : drvPaths2)
|
||||||
nixStoreArgs.push_back(path);
|
nixStoreArgs.push_back(path);
|
||||||
auto nixStoreRes = runProgram(settings.nixBinDir + "/nix-store", false, nixStoreArgs);
|
auto nixStoreRes = runProgram(settings.nixBinDir + "/nix-store", false, nixStoreArgs);
|
||||||
for (const auto & outpath : tokenizeString<std::vector<string>>(nixStoreRes)) {
|
for (const auto & outpath : tokenizeString<std::vector<string>>(nixStoreRes))
|
||||||
outPaths.push_back(chomp(outpath));
|
outPaths.push_back(chomp(outpath));
|
||||||
}
|
|
||||||
|
|
||||||
if (dryRun)
|
if (dryRun)
|
||||||
continue;
|
continue;
|
||||||
for (const auto & outPath : outPaths) {
|
|
||||||
auto target = readLink(outPath);
|
for (const auto & outPath : outPaths)
|
||||||
std::cout << target << '\n';
|
std::cout << readLink(outPath) << '\n';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue