Skip to content

Commit

Permalink
feat: read installable paths from stdin
Browse files Browse the repository at this point in the history
Resolves NixOS#7437 for new `nix` commands only.

If paths are also passed on the cli they will be combined with the ones
from standard input.
  • Loading branch information
nrdxp committed Jan 12, 2023
1 parent eaa20f2 commit 80b3d9a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/libcmd/installables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1089,10 +1089,18 @@ void InstallablesCommand::prepare()

Installables InstallablesCommand::load() {
Installables installables;
if (_installables.empty() && useDefaultInstallables())
if (_installables.empty() && useDefaultInstallables() && isatty(STDIN_FILENO))
// FIXME: commands like "nix profile install" should not have a
// default, probably.
_installables.push_back(".");

if (!isatty(STDIN_FILENO)) {
std::string word;
while (std::cin >> word) {
_installables.emplace_back(std::move(word));
}
}

return parseInstallables(getStore(), _installables);
}

Expand Down

0 comments on commit 80b3d9a

Please sign in to comment.