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
fish: native environment #108947
fish: native environment #108947
Conversation
Since you're probably most familiar with the tools rn. Is there a reason |
CC @bouk (#107834 (comment)) |
@toonn I actually started with that approach here, but decided against it because interpolation was a problem: it's done eagerly, so if your config has |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is intriguing, I'd argue against switching to babelfish as the default. According to the project's own README, there is still some amount of work left to do. If anybody depends on any of those not-yet-implemented features (e.g. one of the "bunch of arithmetic expressions"), their system might no longer work as expected.
@cole-h Thank you for the comment. I'd like to hear from @bouk about what those are specifically and generally how suitable this is. Should it not be a suitable default, is there any path forward that allows those for whom this would work to use it? Perhaps some kind of option on the fish module? The speedup in my shell is great, and I'd love to find some way to get it to others. |
ff8afab
to
d93fba2
Compare
081cd23
to
8a7d95a
Compare
@cole-h I've committed a version with new configuration, defaulted to false, on the fish module that enables this behavior. I'd be grateful if you could take a look. |
8a7d95a
to
8fd8172
Compare
I'd say babelfish will work fine for 100% of the use case we have in Nixpkgs. At some point I manually went though everything to make sure it does. What it doesn't support yet are quite niche and definitely not used in nixpkgs shell inits (things like arithmetic expressions). I will gladly take on the maintenance burden if we do find something that it doesn't work with. I know for me the speed up has been very noticeable. |
@bouk I'm not only talking about inside Nixpkgs, but also in users' configs. No matter how niche, if a user relies on some unimplemented arithmetic expression in the shell inits in their local configs, using babelfish will break their setup. I'm more in favor of an option where users opt into potential breakage (which, thankfully, @kevingriffin has done here). I'm glad you're interested in maintaining this, however, and look forward to it being feature-complete! |
8fd8172
to
d97b0d5
Compare
@cole-h I've added a commit which I believe addresses all of your feedback. If it looks good, I can squash it and port the changes back to nix-darwin. |
@cole-h I just rebased onto master to get the new babelfish package. I also squashed all of my commits into a single commit, just in case this ends up being mergeable once you've done some more testing. Thank you for the help! |
@bouk I'm seeing this in my testing:
Somewhere an extra space is entering into the equation, but I can't work out where it's coming in. The path in (Incidentally, I don't see this on macOS with virtually the same module) |
@kevingriffin could you post a gist of the contents of setEnvironment.fish? And maybe the untranslated bash equivalent? |
Sure. I'll note that fish: https://gist.github.com/kevingriffin/ec289a13ed6176f96e4b9f9e1d250637 edit: actually, no, Looks like it's this: /etc/fish
❯ set -gx BAZ_PATH "a:b"
/etc/fish
❯ echo $BAZ_PATH
a b
/etc/fish
❯ set -gx TEST_PATH "$HOME"'/.nix-defexpr/channels'(test -n "$BAZ_PATH" && echo :$BAZ_PATH || echo)
/etc/fish
❯ echo $TEST_PATH
/home/kevin/.nix-defexpr/channels a b The problem being that |
@bouk I've opened bouk/babelfish#9 |
@kevingriffin I've released version 1.0.1, please give that a shot. Thanks for taking a close look 👍 |
That was quick! It works in my testing. I'll package 1.0.1 and submit a PR for it. |
Configuration may be ran through fenv at shell start time (as previously) or translated to fish at build time with the babelfish package.
158429a
to
1ef2f29
Compare
I rebased against master to build against babelfish 1.0.1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diff LGTM, and functionality seems to work fine. Thanks for your collaboration on this, @kevingriffin and @bouk!
Unless anybody finds anything wrong, I plan on merging this tomorrow morning (probably around 10 AM Pacific).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work on this @kevingriffin 👍🏻
Let's see how it works for people, and maybe it could be the default further down the line.
About half an hour early, but 🚀 |
This is similar to the option in nixpkgs[1], and has similar benefits, e.g. faster launching speed. [1]: NixOS/nixpkgs#108947
This is similar to the option in nixpkgs[1], and has similar benefits, e.g. faster launching speed. [1]: NixOS/nixpkgs#108947
Translates `hm-session-vars.sh` to fish at system build time when enabled, significantly speeding up shell startup time. Based on NixOS/nixpkgs#108947 by @kevingriffin.
Translates `hm-session-vars.sh` to fish at system build time when enabled, significantly speeding up shell startup time. Based on NixOS/nixpkgs#108947 by @kevingriffin.
Translate `hm-session-vars.sh` to fish at system build time, significantly decreasing shell startup time. Based on NixOS/nixpkgs#108947 by @kevingriffin.
Translate `hm-session-vars.sh` to fish at system build time, significantly decreasing shell startup time. Based on NixOS/nixpkgs#108947 by @kevingriffin.
* home-environment: add `home.sessionVariablesPackage` Allow the `hm-session-vars.sh` derivation to be referenced from other modules, e.g. to translate it to fish with babelfish at build time. * fish: use babelfish for `hm-session-vars.sh` Translate `hm-session-vars.sh` to fish at system build time, significantly decreasing shell startup time. Based on NixOS/nixpkgs#108947 by @kevingriffin.
* home-environment: add `home.sessionVariablesPackage` Allow the `hm-session-vars.sh` derivation to be referenced from other modules, e.g. to translate it to fish with babelfish at build time. * fish: use babelfish for `hm-session-vars.sh` Translate `hm-session-vars.sh` to fish at system build time, significantly decreasing shell startup time. Based on NixOS/nixpkgs#108947 by @kevingriffin.
Motivation for this change
fish shell startup with
programs.fish.enable
set is about 2x slower than without based on my testsand reports from others. Tracing reveals calls to
fenv
being the vast majority of the time.A plugin called babelfish, which I've added as a package in #108946, can be used to pre-compute native fish code from bash at system build time, eliminating the need to call
fenv
during each shell launch.This pull request is based off of #108946, but can be rebased onto master if #108946 is accepted.
I've removed calls to fenv for the init configuration specified on the fish module's configuration, as I couldn't find a reason for these to need translation, since the configuration is local to the fish module itself.
A similar pull request exists for nix-darwin, LnL7/nix-darwin#270, where I've vendored the package until it lands in nixpkgs.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)