This repository has been archived on 2024-05-02. You can view files and clone it, but cannot push or open issues or pull requests.
home-manager-flake/lib/tmux.nix

49 lines
1.3 KiB
Nix

{ pkgs, ... }:
let
rtpPath = "share/tmux-plugins";
addRtp = path: rtpFilePath: attrs: derivation:
derivation // { rtp = "${derivation}/${path}/${rtpFilePath}"; } // {
overrideAttrs = f: mkTmuxPlugin (attrs // f attrs);
};
mkTmuxPlugin =
a@{ pluginName
, rtpFilePath ? (builtins.replaceStrings [ "-" ] [ "_" ] pluginName) + ".tmux"
, namePrefix ? "tmuxplugin-"
, src
, unpackPhase ? ""
, configurePhase ? ":"
, buildPhase ? ":"
, addonInfo ? null
, preInstall ? ""
, postInstall ? ""
, path ? pkgs.lib.getName pluginName
, ...
}:
if pkgs.lib.hasAttr "dependencies" a then
throw "dependencies attribute is obselete. see NixOS/nixpkgs#118034" # added 2021-04-01
else
addRtp "${rtpPath}/${path}" rtpFilePath a (pkgs.stdenv.mkDerivation (a // {
pname = namePrefix + pluginName;
inherit pluginName unpackPhase configurePhase buildPhase addonInfo preInstall postInstall;
installPhase = ''
runHook preInstall
target=$out/${rtpPath}/${path}
mkdir -p $out/${rtpPath}
cp -r . $target
if [ -n "$addonInfo" ]; then
echo "$addonInfo" > $target/addon-info.json
fi
runHook postInstall
'';
}));
in
{
inherit mkTmuxPlugin;
}