-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
nix dev
command for local dev tools and scripts
#6241
Comments
Another approach that is similar to how git does it. Provide a CLI extension mechanism:
would extend the CLI such that Separate comment: I'm not a fan of |
I'm guessing if this is adopted it could also potentially be a basis for fixing the issue #6124. My initial reaction is also concern about potential confusion of |
That's not really what I was going for with this. It makes every subcommand addition a potentially breaking change and the tab completion will not be great.
Good thing the CLI is experimental. We can still deprecate |
Since it’s not mentioned in the issue: The most straightforward way of doing that right now is to just put them in the devShell. This definitely asn’t always ideal since it means that they have to be realised eagerly (very annoying if your script is something with a huge closure that only one person will run every once in a while), but that already covers 90% of the use-cases imho. |
Strictness isn't the only problem. These It is straightforward though 🤷 I'll add this to the alternatives section. |
That’s a fair point :) Maybe we could make |
This will be redundant when
This will be useful to someone, but it doesn't replace |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/flakes-as-a-unified-format-for-profiles/29476/15 |
Another reason this is not a replacement, is that |
nix dev
command for local dev tools and scriptsnix dev
command for local dev tools and scripts
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/how-to-build-packages-in-nix-develop-nix-shell-with-zsh/58232/1 |
Is your feature request related to a problem? Please describe.
Many projects define custom scripts, tools, etc that are intended for local use during development.
apps
orpackages
are not a great place to put these, because they're not intended for public consumption (and probably don't even work outside their project's worktree).The new attribute will align closely with the proposed
nix fmt
command #6087 (comment).It can also support dev shells, or dev shells that do not run
bash
, by invoking a user-provided "shell launcher"dev
command instead of Nix's subjectively inflexiblenix develop
behavior. By convention, this would benix dev shell
and perhapsnix develop
could fall back tonix dev shell
whendevShells.<system>.default
isn't set. This way, such shells are supported in a consistent manner.Describe the solution you'd like
devTools.<system>.<name>
nix
commandnix dev <name> <args>
When
nix dev
runs, it looks up the name in the nearestflake.nix
. If not found, proceed to aflake.nix
in a higher directory.When the
<name>
is found, it executes the main program (similar tonix run
), forwarding the remaining command line arguments to the process. The process environment is extended with aFLAKE_DIRECTORY
environment variable, as many scripts operate on files relative to the project root. Perhaps also aFLAKE_ROOT
variable, which is different when the flake is a subflake.Alternatively, it could
chdir
to theFLAKE_DIRECTORY
and perhaps preserve the original working directory inFLAKE_INVOCATION_DIRECTORY
.Describe alternatives you've considered
#!nix develop
shebang scripts. These are non-trivial to write and require the flake and the script to agree on a name attribute for the environment.nix run
. Pollutes (subjectively) the flake outputs and doesn't help with the working directory. Doesn't allow customization ofnix develop
.devShell
. This isn't lazy enough and doesn't help with script workdir anchoring.task
doesn't fit interactive use cases likenix dev shell
Additional context
The text was updated successfully, but these errors were encountered: