2021-08-10 14:31:46 +00:00
|
|
|
{ callPackage, lib, stdenv, fetchFromGitHub, git, zsh }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-06-02 18:00:15 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "gitstatus";
|
2022-02-20 05:27:41 +00:00
|
|
|
version = "1.5.4";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "romkatv";
|
|
|
|
repo = "gitstatus";
|
2020-06-02 18:00:15 +00:00
|
|
|
rev = "v${version}";
|
2022-02-20 05:27:41 +00:00
|
|
|
sha256 = "sha256-mVfB3HWjvk4X8bmLEC/U8SKBRytTh/gjjuReqzN5qTk=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-08-10 14:31:46 +00:00
|
|
|
buildInputs = [ (callPackage ./romkatv_libgit2.nix { }) ];
|
|
|
|
|
|
|
|
postPatch = ''
|
2020-10-07 09:15:18 +00:00
|
|
|
sed -i '1i GITSTATUS_AUTO_INSTALL=''${GITSTATUS_AUTO_INSTALL-0}' gitstatus.plugin.sh
|
2020-09-25 04:45:31 +00:00
|
|
|
sed -i '1i GITSTATUS_AUTO_INSTALL=''${GITSTATUS_AUTO_INSTALL-0}' gitstatus.plugin.zsh
|
|
|
|
sed -i "1a GITSTATUS_DAEMON=$out/bin/gitstatusd" install
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
2021-08-10 14:31:46 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
installPhase = ''
|
|
|
|
install -Dm755 usrbin/gitstatusd $out/bin/gitstatusd
|
2021-08-10 14:31:46 +00:00
|
|
|
install -Dm444 gitstatus.plugin.sh -t $out/share/gitstatus/
|
|
|
|
install -Dm444 gitstatus.plugin.zsh -t $out/share/gitstatus/
|
|
|
|
install -Dm555 install -t $out/share/gitstatus/
|
|
|
|
install -Dm444 build.info -t $out/share/gitstatus/
|
|
|
|
|
|
|
|
# the fallback path is wrong in the case of home-manager
|
|
|
|
# because the FHS directories don't start at /
|
|
|
|
substituteInPlace install \
|
|
|
|
--replace "_gitstatus_install_main ." "_gitstatus_install_main $out"
|
2020-09-25 04:45:31 +00:00
|
|
|
'';
|
2021-08-10 14:31:46 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
# Don't install the "install" and "build.info" files, which the end user
|
|
|
|
# should not need to worry about.
|
|
|
|
pathsToLink = [
|
|
|
|
"/bin/gitstatusd"
|
2021-08-10 14:31:46 +00:00
|
|
|
"/share/gitstatus/gitstatus.plugin.sh"
|
|
|
|
"/share/gitstatus/gitstatus.plugin.zsh"
|
2020-09-25 04:45:31 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# The install check sets up an empty Git repository and a minimal zshrc that
|
|
|
|
# invokes gitstatus.plugin.zsh. It runs zsh against this zshrc and verifies
|
|
|
|
# that the script was sourced successfully and that the "gitstatus_query"
|
|
|
|
# command ran successfully. This tests the binary itself and the zsh
|
|
|
|
# integration.
|
|
|
|
installCheckInputs = [ git zsh ];
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
TEMP=$(mktemp -d)
|
|
|
|
cd "$TEMP"
|
|
|
|
|
|
|
|
git init
|
|
|
|
|
|
|
|
echo '
|
|
|
|
GITSTATUS_LOG_LEVEL=DEBUG
|
2021-08-10 14:31:46 +00:00
|
|
|
. $out/share/gitstatus/gitstatus.plugin.zsh || exit 1
|
2020-09-25 04:45:31 +00:00
|
|
|
|
|
|
|
gitstatus_stop NIX_TEST && gitstatus_start NIX_TEST
|
|
|
|
gitstatus_query NIX_TEST
|
|
|
|
if [[ $? -ne 0 ]]; then
|
|
|
|
print -- "Something went wrong with gitstatus"
|
|
|
|
exit 1
|
|
|
|
elif [[ $VCS_STATUS_RESULT != "ok-sync" ]]; then
|
|
|
|
print -- "Not in a Git repo"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
print -- "OK"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
' > .zshrc
|
|
|
|
|
|
|
|
# If we try to run zsh like "zsh -i -c true" or "zsh -i > output" then job
|
|
|
|
# control will be disabled in the shell and the gitstatus plugin script
|
|
|
|
# will fail when it tries to set the MONITOR option. As a workaround, we
|
|
|
|
# run zsh as a full-fledged independent process and then wait for it to
|
|
|
|
# exit. (The "exit" statements in the zshrc ensure that zsh will exit
|
|
|
|
# almost immediately after starting.)
|
|
|
|
ZDOTDIR=. zsh -i &
|
|
|
|
wait $!
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "10x faster implementation of `git status` command";
|
|
|
|
homepage = "https://github.com/romkatv/gitstatus";
|
2020-12-29 15:07:52 +00:00
|
|
|
license = licenses.gpl3Only;
|
2021-08-10 14:31:46 +00:00
|
|
|
maintainers = with maintainers; [ mmlb hexa SuperSandro2000 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|