-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Allow nix develop
to run shell code directly, similar to nix-shell --run
#6908
Comments
I much prefer the invoke-a-shell-yourself variant. Running a shell implicitly can be so much more painful in terms of quoting, variable scope, and such. And if this were introduced as a separate mode of operation (e.g. |
I'm more concerned that
I agree that it's not a deal breaker. It's just that this awkwardness compounds when doing stuff like CI workflows, where the noise escalates quickly
This also assumes that the user made the connection that their inlined bash was the issue, and needed to pass their script explicitly to the shell interpreter. |
I would also be pretty happy with doing something like:
However, this likely isn't possible, as then we are making assumptions that nix (independent of nixpkgs) is able to know what a "bash" is. But I also agree that |
I find it important that |
Thanks :)
I'm not a big fan of that as many people will have differing opinions around what shell they want to use. Especially since some shells like |
Right, that is indeed an issue. Actually, why I suggested such an option is that I want to have a solution that supports |
I actually stumbled over this ticket because I was so used to |
Add example of nix develop being used to execuate a series of script commands. This is common when doing things like CI/CD, and should be represented in the official documentation. Also useful for people looking for the 'nix develop' equivalent of 'nix-shell --run'. Related: - #6908 - #6908 (comment)
With the current behavior it is not possible to use |
@mkoura not sure I get what you mean. Do you mean that when running |
@thufschmitt Yes. More specifically with a script #! /usr/bin/env -S nix develop --accept-flake-config .#base -c bash
exec the_service and supervisor config like
the |
That's weird, since you Just tried with |
This is weird indeed. I observe the same behavior as you described above, unless I'm in nix shell of a project where I've ran into this issue.
results in
Why is
I don't know where this comes from, in any case it doesn't |
Add example of nix develop being used to execuate a series of script commands. This is common when doing things like CI/CD, and should be represented in the official documentation. Also useful for people looking for the 'nix develop' equivalent of 'nix-shell --run'. Related: - NixOS#6908 - NixOS#6908 (comment)
Is your feature request related to a problem? Please describe.
The
nix develop --command
command allows you to execute some commands, however, it requires that the first arguments is a valid target for exec. This means that usage such asnix develop --command cd somedir/ && mkdir build && cd build && cmake .. && make
will fail with something likeline 1886: exec: cd: not found
. Which is a bit odd, but makes sense if you're aware that the expected behavior is that nix will call exec on the first argument.Describe the solution you'd like
Provide a way to run an inline script. (e.g.
nix develop --run "cd somedir/ && mkdir build ...."
)Describe alternatives you've considered
For single command executions, you can just re-orient the sequences of actions:
cd somedir/ && nix develop --command ...
Or you can call bash:
Additional context
This would be similar to
nix-shell --run
The text was updated successfully, but these errors were encountered: