tmux-tea
tmux-tea copied to clipboard
[ENH]: add to nixpkgs for easier installation on NixOS
Description
It would be great if the plugin could be natively installed via NixOS (see https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=tmuxPlugins).
Additional Information
This can easily be achieved by coping a short block into this file: https://github.com/NixOS/nixpkgs/blob/master/pkgs/misc/tmux-plugins/default.nix
tmux-tea = mkTmuxPlugin rec {
pluginName = "tea";
version = "unstable-2024-06-02";
src = pkgs.fetchFromGitHub {
owner = "2KAbhishek";
repo = "tmux-tea";
rev = "8a150154a68a1a1d0c575098a1aa649da4090371";
hash = "sha256-NGD2raQyhaeLRLvApyX/eX5y//rsaK/DuB0UTv4LkBw=";
};
meta = {
homepage = "https://github.com/2KAbhishek/tmux-tea";
description = "tmux sessions as easy as tea";
license = lib.licenses.gpl3Only;
};
};
This should work fine. I am currently already testing it with such an install on my setup: https://github.com/f4z3r/nix/blob/bd8b91c4c1eaf779a6f9ffbfb0761c3baf629bee/home/apps/tmux/default.nix#L98
Hey @f4z3r thanks for setting up this issue (along with the others)
They are on my radar, will try to get to those as soon as I get some time
Appreciate it
Hi @2KAbhishek , no worries. Let me know if I can help in some way. I just didn't want to open PRs to publish your software in some registries without your consent.
@f4z3r I am new to adding nixpkgs, was wondering about the hash in the pkg definition, how do you generate this?
hash = "sha256-NGD2raQyhaeLRLvApyX/eX5y//rsaK/DuB0UTv4LkBw=";
You can either try and build with a wrong hash to get the package manager to tell you which one is the real one, or you can rely on nix hash-path to get the hash:
git clone <repo> /tmp/repo
cd /tmp/repo
git checkout <revision>
rm -rf .git
cd /tmp
nix hash-path /tmp/repo
The last command should then return the hash of the repo at the specified revision.
Oh, I am not running a nix system right now, can you please send me the latest hash for this with the latest pull from main
The hash of the latest commit on main is sha256-WctBTsmuycbzTTiVqFlv+ttlELNn6sATbA/uJ/CcbXo=.
Note that you don't need to run a nix system to have nix installed. It is a standalone package manager that you can install on pretty much any Linux distro to be used side-by-side to your standard distro package manager.
I think we also need to add the dependencies for fzf and zoxide with this.
tmux-tea = mkTmuxPlugin rec {
pluginName = "tea";
version = "unstable-2024-06-02";
src = pkgs.fetchFromGitHub {
owner = "2KAbhishek";
repo = "tmux-tea";
rev = "101ed293407914b6651f9a2a2079d988e03ac8d9";
hash = "sha256-NGD2raQyhaeLRLvApyX/eX5y//rsaK/DuB0UTv4LkBw=";
};
meta = {
homepage = "https://github.com/2KAbhishek/tmux-tea";
description = "tmux sessions as easy as tea";
license = lib.licenses.gpl3Only;
};
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram $out/share/tmux-plugins/tmux-tea/bin/tea.sh \
--prefix PATH : ${with pkgs; lib.makeBinPath (
[ pkgs.fzf pkgs.zoxide ]
)}
find $target -type f -print0 | xargs -0 sed -i -e 's|fzf |${pkgs.fzf}/bin/fzf |g'
find $target -type f -print0 | xargs -0 sed -i -e 's|zoxide |${pkgs.zoxide}/bin/zoxide |g'
'';
};
How does this look to you?
Also is there a possibility to symlink the file bin/tea.sh as tea somewhere accessible to $PATH, do you know how that can be done?
Looks very good! There are a few small things I found out while testing this:
recin the function call ofmkTmuxPluginis superfluous.- In
${with pkgs; lib.makeBinPath ([ pkgs.fzf pkgs.zoxide ])}you can either dropwith pkgs;or drop thepkgsprefixes forfzfandzoxide. tea.shneeds to be an executable to be wrapped bywrapProgram. You therefore need something likechmod +x $target/bin/tea.shbefore calling the wrapper.
Your usage of the postInstall is very nice to ensure fzf and zoxide are available for the plugin 👍🏽 I tested that this does what is expected, and it seemed to work.
I would also use $target mostly rather than recreating the $out/share/tmux-plugins path, since that is created in the mkTmuxPlugin function and might be subject to change. I would therefore have something like:
tmux-tea = mkTmuxPlugin {
pluginName = "tea";
version = "unstable-2024-06-02";
src = pkgs.fetchFromGitHub {
owner = "2KAbhishek";
repo = "tmux-tea";
rev = "101ed293407914b6651f9a2a2079d988e03ac8d9";
hash = "sha256-NGD2raQyhaeLRLvApyX/eX5y//rsaK/DuB0UTv4LkBw=";
};
meta = {
homepage = "https://github.com/2KAbhishek/tmux-tea";
description = "tmux sessions as easy as tea";
license = lib.licenses.gpl3Only;
};
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
chmod +x $target/bin/tea.sh
wrapProgram $target/bin/tea.sh \
--prefix PATH : ${with pkgs; lib.makeBinPath (
[ fzf zoxide ]
)}
find $target -type f -print0 | xargs -0 sed -i -e 's|fzf |${pkgs.fzf}/bin/fzf |g'
find $target -type f -print0 | xargs -0 sed -i -e 's|zoxide |${pkgs.zoxide}/bin/zoxide |g'
'';
};
Regarding making tea available as a binary in the path, I am currently trying out various things.
I tried various things in the postInstall hook such as:
mkdir -p $out/bin
cp $target/bin/tea.sh $out/bin/tea
As typically nix will automatically pick up "binaries" in the $out/bin directory. However, that did not end up in my path when I built it this way. I will continue to have a look on how this can be achieved. I should get some time on the weekend at the latest to check this out in more detail.
Thanks, I'm planning to setup nix on my system this weekend as well, can do more experiments then :)
I have invested a little more into it, but still didn't manage to get the binary to be exposed under /run/current-system/sw/bin ...
Maybe a good idea would be to just open a PR and ask for support from the person that will review it on the nixpkgs repo. They really know their $hit and will be able to tell you in no time.
@f4z3r apologies for the radio silence on this, but I didn't get too much into nix back then, were you able to resolve this in any other manner?
No worries. I tried various things, but I did not manage to get the binary exposed in the PATH. I have too little understanding of how derivations work as it seems to figure this one out. Nixpkgs maintainers will help for sure though.
Alright, I'll leave this open, just in case I venture into the nix world again :)