fish: use babelfish for hm-session-vars.sh - #4012
Conversation
|
Maybe we can make this the default conditionally based on |
|
Yes, I had that thought. I would be happy to implement that if defaulting to it outright is a bridge too far. It'd be nice if NixOS and nix-darwin did that too; the speedup is quite considerable... |
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.
|
Oh wait, I have the |
|
Can babelfish deal with the code that we know may be present in home-manager/modules/services/gpg-agent.nix Lines 240 to 244 in 58eb968 home-manager/modules/targets/generic-linux.nix Lines 59 to 64 in 58eb968 |
|
Yeah, it gets both of these correct: if test -z "$SSH_AUTH_SOCK"
set -gx SSH_AUTH_SOCK (/path/to/gnupg/bin/gpgconf --list-dirs agent-ssh-socket | string collect; or echo)
endand /nix/store/lnggzp27m91d1niswv65jdr2kkg61my0-babelfish-1.1.0/bin/babelfish < '/path/to/nix/etc/profile.d/nix.sh' | source
# reset TERM with new TERMINFO available (if any)
set -gx TERM "$TERM"respectively. In general babelfish is quite sophisticated; e.g. its author said "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." on the NixOS PR and the only mistranslation I ran into on this nontrivial script from nix-index was this comment parsing infelicity: bouk/babelfish#23. It looks like nothing else adds to |
|
Let's give it a try then! |
841a441 to
bdb3617
Compare
|
Alright, yolo version pushed :) For what it's worth, Nix ships with an |
Translate `hm-session-vars.sh` to fish at system build time, significantly decreasing shell startup time. Based on NixOS/nixpkgs#108947 by @kevingriffin.
bdb3617 to
ba9e517
Compare
hm-session-vars.sh
|
Looks good. Since this is a potentially breaking change, I'll think we'll have to wait until the 23.05 branchoff (which is happening now for NixOS). |
|
Sure; does that mean this will land in the release after 23.05 and I should move the changelog entry to that one after branch-off happens? |
|
@emilazy HM master is now 23.11 so I guess you are good to go 🙂 |
|
@ncfavier Thanks for the merge! I was just about to rebase this for the release turnover - you'll want to move the release notes to |
|
Fixed |
* 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.
Description
See NixOS/nixpkgs#108947, nix-darwin/nix-darwin#270. When enabled this brings down fish startup time from "noticeable delay" to "imperceptibly fast" for me.
The NixOS and nix-darwin versions of this construct derivations for the bash sources and place the results in
/etc/fish. I couldn't figure out if there was any point to that kind of thing so I just used the derivation directly and embedded the bash in the build script. I also didn't abstract it out at all because there's nothing else to translate at present.I wanted to port
programs.nix-index.enableFishIntegrationto use this and forego the additional shell when enabled, but babelfish isn't quite ready for it yet.I didn't add a test because I'm not sure what kind of test case would be useful within the Home Manager test framework. I guess you could check the file contains correct code for setting a specific variable, but that might break if babelfish translates it differently (but equally correctly) in the future.
I'd be tempted to forego the option and just use babelfish unconditionally, since it should handle this basic variable-setting use case perfectly, but theoretically people could have added arbitrarily complicated bash code to
home.sessionVariablesExtraand in that case this could break their configurations if they use edge-case features that babelfish doesn't yet correctly translate. If that's an acceptable tradeoff I'd be happy to amend the PR to default the option on or skip it altogether.(Also maybe
home.sessionVariablesInitshould be marked as internal?)Checklist
Change is backwards compatible.
Code formatted with
./format.Code tested through
nix-shell --pure tests -A run.allornix develop --ignore-environment .#allusing Flakes.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
If this PR adds a new module
Added myself as module maintainer. See example.
Added myself and the module files to
.github/CODEOWNERS.