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

Add support for the 'nix develop' command #34

Merged
merged 1 commit into from
Jul 20, 2024

Conversation

calebstewart
Copy link
Contributor

@calebstewart calebstewart commented Jun 3, 2024

This PR is based on the fork mentioned in #30. I chose to make a separate fork instead of using @manuelbb-upb 's fork since theirs included a flake, which doesn't seem necessary to implement this feature. I tested by overriding the nixpkgs version like so:

  any-nix-shell = pkgs.any-nix-shell.overrideAttrs {
    src = inputs.any-nix-shell-with-develop;
  };

where inputs.any-nix-shell-with-develop is from my flake inputs:

{
  inputs = {
    any-nix-shell-with-develop = {
      url = "github:calebstewart/any-nix-shell/add-nix-develop-support";
      flake = false;
    };
  };
}

I use zsh, and don't know/use the other shells supported here much or at all, so this has only been tested in zsh.

@haslersn
Copy link
Owner

As already argued in #12 (comment), I deliberately didn't support nix develop, because there's already the nix shell command for the case where you want your default shell. Do you disagree with my argument there?

@thiagokokada thiagokokada mentioned this pull request Jul 17, 2024
@thenbe
Copy link

thenbe commented Jul 19, 2024

Let me know if we're not talking about the same thing, but nix develop is used for devshell outputs from a flake.nix. An example would be the devshell shown here (search for the word jq on that page). That devshell, the one with jq, can be activated by running nix develop. But it cannot be activated by running nix shell.

For these kinds of workflows, this PR is required to activate a shell other than bash (such as zsh). Without this PR, one must explicitly call exec zsh in each devshell declaration (across all projects), as can be illustrated in this example. I believe that avoiding this explicit call is the desired behavior behind this PR (and issue).

@thenbe
Copy link

thenbe commented Jul 19, 2024

fwiw, I also tested this on zsh (it works) using this overlay:

any-nix-shell = prev.any-nix-shell.overrideAttrs (_old: rec {
  version = "2537e5c6901ef934f8f44d61bcfe938b0fc9fa71";
  src = prev.fetchFromGitHub {
    owner = "haslersn";
    repo = "any-nix-shell";
    rev = version;
    sha256 = "sha256-j1DE0WTBGLmBLoPmqST9YVj9Jc4Mp8WXQILmPBzRlbM=";
  };
  patches = [
    (prev.fetchpatch {
      url = "https://github.com/haslersn/any-nix-shell/pull/34.patch";
      sha256 = "sha256-r+sBN/akxip9QJpRzHRMUAUoRHzMlLx4K/SP38OQQOE=";
    })
  ];
});

@haslersn haslersn merged commit e61713d into haslersn:master Jul 20, 2024
@bryceberger
Copy link

This doesn't work on fish.

> fish --version
fish, version 3.7.1

> nix develop
test: Expected a combining operator like '-a' at index 4
develop = run or test develop = develop
              ^
- (line 11): 
    if test $argv[1] = run or test $argv[1] = develop
       ^
in function 'nix' with arguments 'develop'

The correct syntax is if test $argv[1] = run -o $argv[1] = develop

@haslersn
Copy link
Owner

haslersn commented Jul 22, 2024

@bryceberger it seems there is a semicolon or linebreak missing before the or. Then it would work, right?

@bryceberger
Copy link

Yep, any of the three would work.

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 this pull request may close these issues.

4 participants