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 hm module #5

Merged
merged 1 commit into from
Oct 7, 2024
Merged

Conversation

pfgray
Copy link
Contributor

@pfgray pfgray commented Sep 4, 2024

This commit adds a home-manager (https://github.com/nix-community/home-manager) module to tabry to make installation & configuration of tabry easier for home-manager users.

enable = true;
enableBashIntegration = true;
tabryFiles = [
./zellij.tabry
Copy link
Owner

Choose a reason for hiding this comment

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

I should probably figure out a better example, as zellij actually does have its own shell completion... When I do, I'll change it here

One useful example I may make (especially when I get delegation working better) is you could have your own aliases dc r, dc e, etc. -- one command with subcommands delegated to different commands -- and have shell completion for all the subcommands ... right now I don't actually know an easy way of doing that without tabry.


programs.bash.initExtra = lib.mkIf cfg.enableBashIntegration (
''
export TABRY_IMPORTS_PATH="${tabryFileDir}:$TABRY_IMPORTS_PATH"
Copy link
Owner

Choose a reason for hiding this comment

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

This should be TABRY_IMPORT_PATH (variable used in the rust version -- TABRY_IMPORTS_PATH is used in the ruby version), right?

@pfgray
Copy link
Contributor Author

pfgray commented Sep 10, 2024

One issue I'm running into right now with the home-manager module is that during installation, the module will move the tabry files into a folder in the nix store (which is immutable), and add that to TABRY_IMPORT_PATH.

tabry will pick up those files fine, but then it tries to write a cache file in the same folder it found the .tabry file in. Since that file is in the nix store, tabry encounters a permission error and fails.

I'm wondering if you think it would make sense to have the cache folder tabry uses be configurable? I can take a stab at that if you want.

cc @evanbattaglia

@evanbattaglia
Copy link
Owner

I'm wondering if you think it would make sense to have the cache folder tabry uses be configurable? I can take a stab at that if you want.

cc @evanbattaglia

Sure you can take a shot at that, let me know if you have any rust questions.
I've been actually curious if it saves much to cache the JSON format or if the parser is fast enough for most every tabry file... I haven't tested it. If it's easier there could also be an option to just not cache the JSON.

@pfgray
Copy link
Contributor Author

pfgray commented Sep 10, 2024

I'm wondering if you think it would make sense to have the cache folder tabry uses be configurable? I can take a stab at that if you want.
cc @evanbattaglia

Sure you can take a shot at that, let me know if you have any rust questions. I've been actually curious if it saves much to cache the JSON format or if the parser is fast enough for most every tabry file... I haven't tested it. If it's easier there could also be an option to just not cache the JSON.

Actually, I think it'll just be easy enough to compile the json ahead of time, during installation... I didn't realize tabry will skip compiling if it already has a .json file compiled previously 👍

@pfgray pfgray force-pushed the add_nix_hm_module branch 2 times, most recently from 06d3626 to a7b8e3a Compare September 11, 2024 00:31
@pfgray
Copy link
Contributor Author

pfgray commented Sep 11, 2024

Ok, this is in a pretty good state, now!


programs.fish.shellInit = lib.mkIf cfg.enableFishIntegration (
''
set -x TABRY_IMPORT_PATH "${tabryImportsPath}:$TABRY_IMPORTS_PATH"
Copy link
Owner

Choose a reason for hiding this comment

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

The second one on this line should also be $TABRY_IMPORT_PATH, right? (And in the bash.initExtra below, and the comment above)

@evanbattaglia evanbattaglia merged commit aebf1e8 into evanbattaglia:master Oct 7, 2024
1 check passed
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.

2 participants