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

feat: add nushell support #35

Merged
merged 1 commit into from
Aug 1, 2023

Conversation

meskill
Copy link
Contributor

@meskill meskill commented Jul 28, 2023

No description provided.

@github-actions github-actions bot added the patch A patch-level change (backwards-compatible bug fixes) label Jul 28, 2023
data/env.nu Show resolved Hide resolved
@@ -110,8 +114,7 @@ fn main() -> eyre::Result<()> {
let current_exe =
current_exe().wrap_err("Unable to determine absolute path of `nix-your-shell`")?;
if args.absolute || !executable_is_on_path(&current_exe)? {
shell_code =
shell_code.replace("nix-your-shell", &format!("{current_exe} --absolute"));
shell_code = shell_code.replace("nix-your-shell", current_exe.as_str());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like adding --absolute doesn't add anything useful to the shell code, but it messes up with nushell integration

Copy link
Member

Choose a reason for hiding this comment

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

I think I wanted --absolute to be reflected here:

$ nix-your-shell fish env
# If you see this output, you probably forgot to pipe it into `source`:
# nix-your-shell fish | source
...

$ nix-your-shell --absolute fish env
# If you see this output, you probably forgot to pipe it into `source`:
# /Users/wiggles/.nix-profile/bin/nix-your-shell --absolute fish | source
...

The idea being it would show you the exact command you need to run to get the same output.

I'm not convinced it's super useful, though, so maybe we can just leave it out.

This is also straining the limits of "do a literal string replace for nix-your-shell" as a templating mechanism. It might be worth integrating an actual templating engine like MiniJinja or tera here -- what do you think? I'm loathe to lose the property of the shell snippets in data/ being actual shell code you can run unmodified, but maybe it's fine (and it seems like it'll happen sooner or later).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see now and for me this is not very useful either so I suggest to remove adding --absolute to not overcomplicate the code.

If taking about integrating templating I'd prefer not to introduce it until there is real need for this as having shell ready code could simplify integrations in more cases.

README.md Outdated Show resolved Hide resolved
@meskill meskill marked this pull request as draft July 30, 2023 13:10
@meskill meskill marked this pull request as ready for review July 30, 2023 13:30
Copy link
Member

@9999years 9999years left a comment

Choose a reason for hiding this comment

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

Hi! Thanks for sending this in!

I haven't used nushell, although I've been watching it from afar and think it's pretty neat. I'll need your expertise here and I'll also want you to maintain the nushell support in nix-your-shell as well — are you willing to do that?

Overall, this PR looks good. Let's move generate-config to nix-your-shell.passthru.generate-config and then I think we can merge this.

Comment on lines +73 to +78
```sh
nix-your-shell nu | save nix-your-shell.nu
```
Copy link
Member

Choose a reason for hiding this comment

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

Non-blocking: Maybe we should have a nix-your-shell nu install command, which generates the correct configuration and puts it in a place the shell will notice, e.g. appending it to ~/.config/nushell/config.nu?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can do something like this, but I do prefer more explicit configurations instead of messing up with user configurations. I'm still not sure what the best way to provide the integrations with nushell. One of the aspect of this - the nixos + home-manager users that won't benefit from such command and for them would be better to provide integration on home-manager side.

data/env.nu Show resolved Hide resolved
flake.nix Outdated
}
//
{
generate-config = shell: final.runCommand "nix-your-shell-config" {} ''
Copy link
Member

Choose a reason for hiding this comment

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

We might want this to have a more unique name in case downstream users apply this overlay on their entire nixpkgs. Maybe we can put it in nix-your-shell.passthru.generate-config?

https://nixos.org/manual/nixpkgs/stable/#special-variables

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've put generate-config to passthru property. Also tested that it works as before

@@ -110,8 +114,7 @@ fn main() -> eyre::Result<()> {
let current_exe =
current_exe().wrap_err("Unable to determine absolute path of `nix-your-shell`")?;
if args.absolute || !executable_is_on_path(&current_exe)? {
shell_code =
shell_code.replace("nix-your-shell", &format!("{current_exe} --absolute"));
shell_code = shell_code.replace("nix-your-shell", current_exe.as_str());
Copy link
Member

Choose a reason for hiding this comment

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

I think I wanted --absolute to be reflected here:

$ nix-your-shell fish env
# If you see this output, you probably forgot to pipe it into `source`:
# nix-your-shell fish | source
...

$ nix-your-shell --absolute fish env
# If you see this output, you probably forgot to pipe it into `source`:
# /Users/wiggles/.nix-profile/bin/nix-your-shell --absolute fish | source
...

The idea being it would show you the exact command you need to run to get the same output.

I'm not convinced it's super useful, though, so maybe we can just leave it out.

This is also straining the limits of "do a literal string replace for nix-your-shell" as a templating mechanism. It might be worth integrating an actual templating engine like MiniJinja or tera here -- what do you think? I'm loathe to lose the property of the shell snippets in data/ being actual shell code you can run unmodified, but maybe it's fine (and it seems like it'll happen sooner or later).

@meskill
Copy link
Contributor Author

meskill commented Aug 1, 2023

Hi! Thanks for sending this in!

I haven't used nushell, although I've been watching it from afar and think it's pretty neat. I'll need your expertise here and I'll also want you to maintain the nushell support in nix-your-shell as well — are you willing to do that?

Overall, this PR looks good. Let's move generate-config to nix-your-shell.passthru.generate-config and then I think we can merge this.

Thank you. I'll be glad to help with maintaining the nushell support!

I'll make the requested changes to this mr shortly

@meskill
Copy link
Contributor Author

meskill commented Aug 1, 2023

Should we change the labels of the mr as it looks like it'll affect version bump action?

@9999years 9999years added minor A minor change (backwards-compatible new functionality) and removed patch A patch-level change (backwards-compatible bug fixes) labels Aug 1, 2023
@9999years 9999years enabled auto-merge (squash) August 1, 2023 23:28
@9999years
Copy link
Member

Looks good, I'll get this merged and cut a new release.

@9999years 9999years merged commit f11e015 into MercuryTechnologies:main Aug 1, 2023
2 checks passed
@9999years
Copy link
Member

OK my release CI broke but I got it fixed and shipped this in v1.3.0.

@meskill meskill deleted the feat/nushell branch August 2, 2023 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor A minor change (backwards-compatible new functionality)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants