-
-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
tmuxPlugins.tmux-fzf: init at unstable-2020-11-12 #95275
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -377,6 +377,41 @@ in rec { | |
}; | ||
}; | ||
|
||
tmux-fzf = mkDerivation { | ||
pluginName = "tmux-fzf"; | ||
version = "unstable-2020-11-23"; | ||
src = fetchFromGitHub { | ||
owner = "sainnhe"; | ||
repo = "tmux-fzf"; | ||
rev = "312685b2a7747b61f1f4a96bd807819f1450479d"; | ||
sha256 = "1z0zmsf8asxs9wbwvkiyd81h93wb2ikl8nxxc26sdpi6l333q5s9"; | ||
}; | ||
KyleOndy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
postInstall = '' | ||
find $target -type f -print0 | xargs -0 sed -i -e 's|fzf |${pkgs.fzf}/bin/fzf |g' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would recommend you take a look at existing substitute functions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very cool. Thanks for that link. That seems like a much better way to go. |
||
find $target -type f -print0 | xargs -0 sed -i -e 's|sed |${pkgs.gnused}/bin/sed |g' | ||
find $target -type f -print0 | xargs -0 sed -i -e 's|tput |${pkgs.ncurses}/bin/tput |g' | ||
''; | ||
meta = { | ||
homepage = "https://github.com/sainnhe/tmux-fzf"; | ||
description = "Use fzf to manage your tmux work environment! "; | ||
longDescription = | ||
'' | ||
Features: | ||
* Manage sessions (attach, detach*, rename, kill*). | ||
* Manage windows (switch, link, move, swap, rename, kill*). | ||
* Manage panes (switch, break, join*, swap, layout, kill*, resize). | ||
* Multiple selection (support for actions marked by *). | ||
* Search commands and append to command prompt. | ||
* Search key bindings and execute. | ||
* User menu. | ||
* Popup window support. | ||
''; | ||
license = stdenv.lib.licenses.mit; | ||
platforms = stdenv.lib.platforms.unix; | ||
maintainers = with stdenv.lib.maintainers; [ kyleondy ]; | ||
KyleOndy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
}; | ||
|
||
urlview = mkDerivation { | ||
pluginName = "urlview"; | ||
version = "unstable-2016-01-06"; | ||
|
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.
🙋 Since
tmux-fzf
expectsfzf
to be available at runtime, we need to patch scripts/.fzf-tmux to look for the executable in the nix store. You can find examples of this inpostInstall
hooks inside this file.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.
Should I also patch
sed
?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.
@KyleOndy excellent suggestion, we should indeed 😃
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.
I'm happy to do that work; I am just curious how complete this should be? Feel free to reroute me to a more general forum for this if appropriate.
Should I patch all instances on binary calls to use the executable in the nix store?
grep
?xargs
? The calls totmux
itself?This is where my lack of deeper knowledge of nix come in, and I admit I have not finished RTFM, so if that is the right move, let me know.
If the system is going to resolve the binary to the nix store eventually, what is the reason or patching the script directly? If the purpose is to ensure the binary is available, shouldn't that be resolved with a dependeny?
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.
The aim to is create a derivation that captures all dependencies (at the exception of
tmux
perhaps) to use the package. This can be verified in a hermetic environment provided bynix-shell --pure
.I recommend to first checkout the PR with
nixpkgs-review
. This will checkout the PR in a temporary directory, build the derivation and spawn an interactive shell.# run the command at the root of `nixpkgs` repo nixpkgs-review pr 95275
Inside the temporary directory find
shell.nix
and replace its content with the snippet below. This will provide a shell with tmux, the plugin and a tmux config file.Then run
nix-shell --pure
(by default will useshell.nix
in the current directory). Once the shell started, runtmux -f tmux.config
to test the plugin. There we can observe the plugin is not yet functional.I know of two options to specify dependencies, 1) patch the source files to reference nix store location 2) prefix the entry point's
PATH
withwrapProgram
(example).Based on how the plugin is built,
wrapProgram
could be a neat solution.Now, onto the existing
dependencies
attribute, it appears to do nothing. I would be looking at deprecating its use.On this output. It shows
fzf
is installed in your profile, but the plugin should work irrespective of whether it is in your profile.Let me know if it does not make sense or you have further questions. I am learning too 🤓
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.
Thank you so much for this write up. I appreciate the time it took. This connected a lot of dots for me, and made things much clearer.
I don't know why it wasn't obvious to me, but this comment cleared it all up.
I'll give this some time tonight and hope to have it all working.
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.
I was able to get the plugin working using the following as my
shell.nix
. Notably I dropped theset -g @plugin 'sainnhe/tmux-fzf'
line as therun
command takes care of loading the plugin. The plugin also requiresncurses
.I was able to get the plugin working using the following as my
shell.nix
. I am still unclear on how to declare thefzf
andncurses
dependencies.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.
This is looking good @KyleOndy, good spot on the
ncurses
dependency.When it comes to declaring dependencies, you have effectively done so when referring to
pkgs.<package>
in the substitution steps. This can be observed by looking at derivation's inputs.In the output find
inputDrvs
(the derivation's direct dependencies)Note 1
<nixpkgs>
This is a reference to the location of nixpkgs repository. When in a nix-review pr xxx shell, the<nixpkgs>
references a locally checked out version of nixpkgs with the PR diff.