-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep splitting libcmd headers & files #7748
Merged
tomberek
merged 3 commits into
NixOS:master
from
obsidiansystems:split-other-installables
Feb 20, 2023
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,7 @@ outputs/ | |
|
||
*.a | ||
*.o | ||
*.o.tmp | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "util.hh" | ||
#include "editor-for.hh" | ||
|
||
namespace nix { | ||
|
||
Strings editorFor(const Path & file, uint32_t line) | ||
{ | ||
auto editor = getEnv("EDITOR").value_or("cat"); | ||
auto args = tokenizeString<Strings>(editor); | ||
if (line > 0 && ( | ||
editor.find("emacs") != std::string::npos || | ||
editor.find("nano") != std::string::npos || | ||
editor.find("vim") != std::string::npos || | ||
editor.find("kak") != std::string::npos)) | ||
args.push_back(fmt("+%d", line)); | ||
args.push_back(file); | ||
return args; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#include "types.hh" | ||
|
||
namespace nix { | ||
|
||
/* Helper function to generate args that invoke $EDITOR on | ||
filename:lineno. */ | ||
Strings editorFor(const Path & file, uint32_t line); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#include "globals.hh" | ||
#include "installable-attr-path.hh" | ||
#include "outputs-spec.hh" | ||
#include "util.hh" | ||
#include "command.hh" | ||
#include "attr-path.hh" | ||
#include "common-eval-args.hh" | ||
#include "derivations.hh" | ||
#include "eval-inline.hh" | ||
#include "eval.hh" | ||
#include "get-drvs.hh" | ||
#include "store-api.hh" | ||
#include "shared.hh" | ||
#include "flake/flake.hh" | ||
#include "eval-cache.hh" | ||
#include "url.hh" | ||
#include "registry.hh" | ||
#include "build-result.hh" | ||
|
||
#include <regex> | ||
#include <queue> | ||
|
||
#include <nlohmann/json.hpp> | ||
|
||
namespace nix { | ||
|
||
InstallableAttrPath::InstallableAttrPath( | ||
ref<EvalState> state, | ||
SourceExprCommand & cmd, | ||
Value * v, | ||
const std::string & attrPath, | ||
ExtendedOutputsSpec extendedOutputsSpec) | ||
: InstallableValue(state) | ||
, cmd(cmd) | ||
, v(allocRootValue(v)) | ||
, attrPath(attrPath) | ||
, extendedOutputsSpec(std::move(extendedOutputsSpec)) | ||
{ } | ||
|
||
std::pair<Value *, PosIdx> InstallableAttrPath::toValue(EvalState & state) | ||
{ | ||
auto [vRes, pos] = findAlongAttrPath(state, attrPath, *cmd.getAutoArgs(state), **v); | ||
state.forceValue(*vRes, pos); | ||
return {vRes, pos}; | ||
} | ||
|
||
DerivedPathsWithInfo InstallableAttrPath::toDerivedPaths() | ||
{ | ||
auto v = toValue(*state).first; | ||
|
||
Bindings & autoArgs = *cmd.getAutoArgs(*state); | ||
|
||
DrvInfos drvInfos; | ||
getDerivations(*state, *v, "", autoArgs, drvInfos, false); | ||
|
||
// Backward compatibility hack: group results by drvPath. This | ||
// helps keep .all output together. | ||
std::map<StorePath, OutputsSpec> byDrvPath; | ||
|
||
for (auto & drvInfo : drvInfos) { | ||
auto drvPath = drvInfo.queryDrvPath(); | ||
if (!drvPath) | ||
throw Error("'%s' is not a derivation", what()); | ||
|
||
auto newOutputs = std::visit(overloaded { | ||
[&](const ExtendedOutputsSpec::Default & d) -> OutputsSpec { | ||
std::set<std::string> outputsToInstall; | ||
for (auto & output : drvInfo.queryOutputs(false, true)) | ||
outputsToInstall.insert(output.first); | ||
return OutputsSpec::Names { std::move(outputsToInstall) }; | ||
}, | ||
[&](const ExtendedOutputsSpec::Explicit & e) -> OutputsSpec { | ||
return e; | ||
}, | ||
}, extendedOutputsSpec.raw()); | ||
|
||
auto [iter, didInsert] = byDrvPath.emplace(*drvPath, newOutputs); | ||
|
||
if (!didInsert) | ||
iter->second = iter->second.union_(newOutputs); | ||
} | ||
|
||
DerivedPathsWithInfo res; | ||
for (auto & [drvPath, outputs] : byDrvPath) | ||
res.push_back({ | ||
.path = DerivedPath::Built { | ||
.drvPath = drvPath, | ||
.outputs = outputs, | ||
}, | ||
}); | ||
|
||
return res; | ||
} | ||
|
||
InstallableAttrPath InstallableAttrPath::parse( | ||
ref<EvalState> state, | ||
SourceExprCommand & cmd, | ||
Value * v, | ||
std::string_view prefix, | ||
ExtendedOutputsSpec extendedOutputsSpec) | ||
{ | ||
return { | ||
state, cmd, v, | ||
prefix == "." ? "" : std::string { prefix }, | ||
extendedOutputsSpec | ||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "globals.hh" | ||
#include "installable-value.hh" | ||
#include "outputs-spec.hh" | ||
#include "util.hh" | ||
#include "command.hh" | ||
#include "attr-path.hh" | ||
#include "common-eval-args.hh" | ||
#include "derivations.hh" | ||
#include "eval-inline.hh" | ||
#include "eval.hh" | ||
#include "get-drvs.hh" | ||
#include "store-api.hh" | ||
#include "shared.hh" | ||
#include "eval-cache.hh" | ||
#include "url.hh" | ||
#include "registry.hh" | ||
#include "build-result.hh" | ||
|
||
#include <regex> | ||
#include <queue> | ||
|
||
#include <nlohmann/json.hpp> | ||
|
||
namespace nix { | ||
|
||
class InstallableAttrPath : public InstallableValue | ||
{ | ||
SourceExprCommand & cmd; | ||
RootValue v; | ||
std::string attrPath; | ||
ExtendedOutputsSpec extendedOutputsSpec; | ||
|
||
InstallableAttrPath( | ||
ref<EvalState> state, | ||
SourceExprCommand & cmd, | ||
Value * v, | ||
const std::string & attrPath, | ||
ExtendedOutputsSpec extendedOutputsSpec); | ||
|
||
std::string what() const override { return attrPath; }; | ||
|
||
std::pair<Value *, PosIdx> toValue(EvalState & state) override; | ||
|
||
DerivedPathsWithInfo toDerivedPaths() override; | ||
|
||
public: | ||
|
||
static InstallableAttrPath parse( | ||
ref<EvalState> state, | ||
SourceExprCommand & cmd, | ||
Value * v, | ||
std::string_view prefix, | ||
ExtendedOutputsSpec extendedOutputsSpec); | ||
}; | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh oops sorry this snuck in here. Clang build temp files like this, which I noticed when I started developing with clang, and so I added this line while working. They are deleted by Clang after the build is complete, but if you run
git status
while a build is in progress (say in another terminal), they clutter the output.I had meant to PR this separately; let me know if I still should.