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 nix shell support #599

Merged
merged 2 commits into from
Jul 10, 2021
Merged

Conversation

gytis-ivaskevicius
Copy link
Contributor

nix-shell is something similar to python virtual env but more powerful, this patchset adds support for it.

pure.zsh Show resolved Hide resolved
Add comment on Nix integration

Add comment on Nix integration
pure.zsh Outdated Show resolved Hide resolved
Copy link
Collaborator

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks alright and would probably work in 99% of cases, only potential issue I see is that the nix shell may override an active virtualenv (if it's possible for them to be active at the same time).

pure.zsh Show resolved Hide resolved
@sindresorhus sindresorhus merged commit c05916f into sindresorhus:main Jul 10, 2021
@andresilva
Copy link
Contributor

Would be nice to have a way to disable this.

@gytis-ivaskevicius
Copy link
Contributor Author

unset IN_NIX_SHELL?

@andresilva
Copy link
Contributor

IN_NIX_SHELL wasn't set by this code, it works but you're assuming it isn't used for anything else besides pure. I think having a NIX_SHELL_DISABLE_PROMPT makes sense, just like it's done for VIRTUAL_ENV support.

@mafredri
Copy link
Collaborator

IN_NIX_SHELL wasn't set by this code, it works but you're assuming it isn't used for anything else besides pure. I think having a NIX_SHELL_DISABLE_PROMPT makes sense, just like it's done for VIRTUAL_ENV support.

We don't have anything like this for virtualenvs 🤔, we simply respect the user option of VIRTUAL_ENV_DISABLE_PROMPT if it is set, it's part of regular virtualenvs though, not Pure.

Is there any similar mechanism for nix shell that we could piggy-back on? We'd like to avoid adding a new configuration option for this.

@gytis-ivaskevicius
Copy link
Contributor Author

No, there is no such logic to piggyback on.
@andresilva Can you elaborate on your usecase? Whatever your use case it sounds pretty odd 🤔

@andresilva
Copy link
Contributor

We don't have anything like this for virtualenvs 🤔, we simply respect the user option of VIRTUAL_ENV_DISABLE_PROMPT if it is set, it's part of regular virtualenvs though, not Pure.

I don't use virtualenv so I didn't know this, I assumed it was something specific to pure.

@andresilva Can you elaborate on your usecase? Whatever your use case it sounds pretty odd 🤔

My use case is quite simple: I don't like this and I want to disable it. IMO the proposed solution to unset a variable that wasn't set by pure is unsatisfactory. If I have some other script that relies on IN_NIX_SHELL for detection then it will be broken.

@mafredri
Copy link
Collaborator

IMO the proposed solution to unset a variable that wasn't set by pure is unsatisfactory. If I have some other script that relies on IN_NIX_SHELL for detection then it will be broken.

I 100% agree. I've not been personally able to evaluate how nix shell can/is used since this is pretty much the first I've heard of it. Obviously if it's something that's enabled 24/7, then displaying the (excess) information is not ideal.

Would it make senses to never display nix-shell (i.e. $name is unset), instead only display it when $name has a value? My thought process is that it could be valuable to know when you're in a different "environment", or whatever it is.

If we were to add a configuration option for this, perhaps it could be added as a zstyle (zstyle :prompt:pure:environment:nix-shell show yes)?

@andresilva
Copy link
Contributor

Would it make senses to never display nix-shell (i.e. $name is unset), instead only display it when $name has a value? My thought process is that it could be valuable to know when you're in a different "environment", or whatever it is.

I don't want to bore you with the details but I don't use nix-shell directly but instead use lorri, this means that I'll always have a $name set even though I'm not interested in seeing it.

If we were to add a configuration option for this, perhaps it could be added as a zstyle (zstyle :prompt:pure:environment:nix-shell show yes)?

That would work for me.

wezzynl added a commit to wezzynl/pure that referenced this pull request Sep 7, 2021
* upstream/main:
  Remove $ prompts from install commands (sindresorhus#607)
  1.17.2
  Improve Apple Silicon compatibility (sindresorhus#606)
  1.17.1
  Do not show hostname when running in GitHub Codespaces (sindresorhus#604)
  Fix version bumping script (sindresorhus#602)
  Add another sponsor to the readme
  1.17.0
  Add nix shell support (sindresorhus#599)
  Add Homebrew install instructions (sindresorhus#591)
  Update info about Fish port (sindresorhus#586)
  Remove antigen and antibody from instruction (sindresorhus#581)
  Update a link
kutsan pushed a commit to kutsan/pure that referenced this pull request Jun 19, 2023
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.

None yet

4 participants