at 24.11-pre 92 lines 3.1 kB view raw
1{ callPackage, lib, stdenv, fetchFromGitHub, git, zsh }: 2 3stdenv.mkDerivation rec { 4 pname = "gitstatus"; 5 version = "1.5.5"; 6 7 src = fetchFromGitHub { 8 owner = "romkatv"; 9 repo = "gitstatus"; 10 rev = "v${version}"; 11 sha256 = "sha256-b+9bwJ87VV6rbOPobkwMkDXGH34STjYPlt8wCRR5tEc="; 12 }; 13 14 buildInputs = [ (callPackage ./romkatv_libgit2.nix { }) ]; 15 16 postPatch = '' 17 sed -i '1i GITSTATUS_AUTO_INSTALL=''${GITSTATUS_AUTO_INSTALL-0}' gitstatus.plugin.sh 18 sed -i '1i GITSTATUS_AUTO_INSTALL=''${GITSTATUS_AUTO_INSTALL-0}' gitstatus.plugin.zsh 19 sed -i "1a GITSTATUS_DAEMON=$out/bin/gitstatusd" install 20 ''; 21 22 installPhase = '' 23 install -Dm755 usrbin/gitstatusd $out/bin/gitstatusd 24 install -Dm444 gitstatus.plugin.sh -t $out/share/gitstatus/ 25 install -Dm444 gitstatus.plugin.zsh -t $out/share/gitstatus/ 26 install -Dm555 install -t $out/share/gitstatus/ 27 install -Dm444 build.info -t $out/share/gitstatus/ 28 29 # the fallback path is wrong in the case of home-manager 30 # because the FHS directories don't start at / 31 substituteInPlace install \ 32 --replace "_gitstatus_install_main ." "_gitstatus_install_main $out" 33 ''; 34 35 # Don't install the "install" and "build.info" files, which the end user 36 # should not need to worry about. 37 pathsToLink = [ 38 "/bin/gitstatusd" 39 "/share/gitstatus/gitstatus.plugin.sh" 40 "/share/gitstatus/gitstatus.plugin.zsh" 41 ]; 42 43 # The install check sets up an empty Git repository and a minimal zshrc that 44 # invokes gitstatus.plugin.zsh. It runs zsh against this zshrc and verifies 45 # that the script was sourced successfully and that the "gitstatus_query" 46 # command ran successfully. This tests the binary itself and the zsh 47 # integration. 48 nativeInstallCheckInputs = [ git zsh ]; 49 doInstallCheck = true; 50 installCheckPhase = '' 51 TEMP=$(mktemp -d) 52 cd "$TEMP" 53 54 git init 55 56 echo ' 57 GITSTATUS_LOG_LEVEL=DEBUG 58 . $out/share/gitstatus/gitstatus.plugin.zsh || exit 1 59 60 gitstatus_stop NIX_TEST && gitstatus_start NIX_TEST 61 gitstatus_query NIX_TEST 62 if [[ $? -ne 0 ]]; then 63 print -- "Something went wrong with gitstatus" 64 exit 1 65 elif [[ $VCS_STATUS_RESULT != "ok-sync" ]]; then 66 print -- "Not in a Git repo" 67 exit 1 68 else 69 print -- "OK" 70 exit 0 71 fi 72 ' > .zshrc 73 74 # If we try to run zsh like "zsh -i -c true" or "zsh -i > output" then job 75 # control will be disabled in the shell and the gitstatus plugin script 76 # will fail when it tries to set the MONITOR option. As a workaround, we 77 # run zsh as a full-fledged independent process and then wait for it to 78 # exit. (The "exit" statements in the zshrc ensure that zsh will exit 79 # almost immediately after starting.) 80 ZDOTDIR=. zsh -i & 81 wait $! 82 ''; 83 84 meta = with lib; { 85 description = "10x faster implementation of `git status` command"; 86 homepage = "https://github.com/romkatv/gitstatus"; 87 license = licenses.gpl3Only; 88 maintainers = with maintainers; [ mmlb hexa SuperSandro2000 ]; 89 platforms = platforms.all; 90 mainProgram = "gitstatusd"; 91 }; 92}