Skip to content
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 develop (flake) support ? #12

Closed
drupol opened this issue Nov 20, 2021 · 11 comments
Closed

nix develop (flake) support ? #12

drupol opened this issue Nov 20, 2021 · 11 comments

Comments

@drupol
Copy link

drupol commented Nov 20, 2021

Hello,

I'm switching my projects and use more and more flakes.
When I do nix develop, it starts a bash shell instead of continue to use my current shell on fish.

Do you think it's possible to use any-nix-shell so it works with nix develop ?

@sbourdeauducq
Copy link

I guess this line needs to be modified: https://github.com/haslersn/any-nix-shell/blob/master/bin/any-nix-shell#L15

@sbourdeauducq
Copy link

sbourdeauducq commented Dec 4, 2021

This indeed fixes it for fish:

--- a/bin/any-nix-shell
+++ b/bin/any-nix-shell
@@ -12,7 +12,7 @@ end
 
 # Overwrite the nix command
 function nix
-    if test \$argv[1] = shell
+    if test \$argv[1] = shell || test \$argv[1] = develop
         set argv[1] fish
         $(which .any-nix-wrapper) \$argv
     else

The zsh code would need a similar modification.

It displays "[unknown environment]" at the right of the shell prompt though.

@drupol
Copy link
Author

drupol commented Dec 4, 2021

How about making a pull request ?

@sbourdeauducq
Copy link

.any-nix-wrapper would also need an update, otherwise it seems nix develop gets aliased to nix shell.

@haslersn
Copy link
Owner

haslersn commented Dec 4, 2021

@sbourdeauducq is right. I'm working on it.

haslersn added a commit that referenced this issue Dec 4, 2021
haslersn added a commit that referenced this issue Dec 4, 2021
haslersn added a commit that referenced this issue Dec 4, 2021
@haslersn
Copy link
Owner

haslersn commented Dec 4, 2021

nix develop and the old nix run (Nix 2.0 - 2.3) have very different command line options. Therefore, supporting nix develop would require some larger changes.

@drupol It seems in Nix 2.4 they reintroduced nix shell, which uses the user's default shell, so any-nix-shell is not required. Can you use nix shell instead of nix develop? It seems the Nix developers deliberately made it so that nix develop uses bash, in order to make debugging builds possible.

@sbourdeauducq
Copy link

Can you use nix shell instead of nix develop?

Unfortunately nix shell means using pkgs.buildEnv and not pkgs.mkShell. This means you cannot set environment variables in the shell from the flake, and also it appears that some programs such as llvm-config (or build tools using it) misbehave in the forest of symlinks created by pkgs.buildEnv.

It seems the Nix developers deliberately made it so that nix develop uses bash, in order to make debugging builds possible.

Ah yes - that would make sense...

@drupol
Copy link
Author

drupol commented Dec 5, 2021

On my side, I found a workaround: nix develop --command fish

@drupol drupol closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2023
@evanrelf
Copy link

evanrelf commented Jun 9, 2023

FYI nix-your-shell has support for nix-develop.

@drupol
Copy link
Author

drupol commented Jun 9, 2023

Unable to build it, doesn't look like the maintainer is taking care of the it anymore.

@evanrelf
Copy link

evanrelf commented Jun 9, 2023

You can get the latest release from Nixpkgs:

λ nix build nixpkgs#nix-your-shell

λ ./result/bin/nix-your-shell --version
nix-your-shell 1.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants