11 stdenv.mkDerivation rec {
15 src = fetchFromGitHub {
19 sha256 = "sha256-b+9bwJ87VV6rbOPobkwMkDXGH34STjYPlt8wCRR5tEc=";
22 env.NIX_LDFLAGS = toString (
24 # required by libgit2.a
27 ++ lib.optional stdenv.hostPlatform.isDarwin "-liconv"
32 (callPackage ./romkatv_libgit2.nix { })
36 sed -i '1i GITSTATUS_AUTO_INSTALL=''${GITSTATUS_AUTO_INSTALL-0}' gitstatus.plugin.sh
37 sed -i '1i GITSTATUS_AUTO_INSTALL=''${GITSTATUS_AUTO_INSTALL-0}' gitstatus.plugin.zsh
38 sed -i "1a GITSTATUS_DAEMON=$out/bin/gitstatusd" install
42 install -Dm755 usrbin/gitstatusd $out/bin/gitstatusd
43 install -Dm444 gitstatus.plugin.sh -t $out/share/gitstatus/
44 install -Dm444 gitstatus.plugin.zsh -t $out/share/gitstatus/
45 install -Dm444 gitstatus.prompt.sh -t $out/share/gitstatus/
46 install -Dm444 gitstatus.prompt.zsh -t $out/share/gitstatus/
47 install -Dm555 install -t $out/share/gitstatus/
48 install -Dm444 build.info -t $out/share/gitstatus/
50 # the fallback path is wrong in the case of home-manager
51 # because the FHS directories don't start at /
52 substituteInPlace install \
53 --replace "_gitstatus_install_main ." "_gitstatus_install_main $out"
55 cat <<EOF > $out/bin/gitstatus-share
57 # Run this script to find the gitstatus shared folder where all the shell
58 # integration scripts are living.
59 echo $out/share/gitstatus
61 chmod +x $out/bin/gitstatus-share
64 # Don't install the "install" and "build.info" files, which the end user
65 # should not need to worry about.
68 "/share/gitstatus/gitstatus.plugin.sh"
69 "/share/gitstatus/gitstatus.plugin.zsh"
70 "/share/gitstatus/gitstatus.prompt.sh"
71 "/share/gitstatus/gitstatus.prompt.zsh"
74 # The install check sets up an empty Git repository and a minimal zshrc that
75 # invokes gitstatus.plugin.zsh. It runs zsh against this zshrc and verifies
76 # that the script was sourced successfully and that the "gitstatus_query"
77 # command ran successfully. This tests the binary itself and the zsh
79 nativeInstallCheckInputs = [
83 doInstallCheck = true;
84 installCheckPhase = ''
91 GITSTATUS_LOG_LEVEL=DEBUG
92 . $out/share/gitstatus/gitstatus.plugin.zsh || exit 1
94 gitstatus_stop NIX_TEST && gitstatus_start NIX_TEST
95 gitstatus_query NIX_TEST
96 if [[ $? -ne 0 ]]; then
97 print -- "Something went wrong with gitstatus"
99 elif [[ $VCS_STATUS_RESULT != "ok-sync" ]]; then
100 print -- "Not in a Git repo"
108 # If we try to run zsh like "zsh -i -c true" or "zsh -i > output" then job
109 # control will be disabled in the shell and the gitstatus plugin script
110 # will fail when it tries to set the MONITOR option. As a workaround, we
111 # run zsh as a full-fledged independent process and then wait for it to
112 # exit. (The "exit" statements in the zshrc ensure that zsh will exit
113 # almost immediately after starting.)
114 ZDOTDIR=. zsh -d -i &
119 description = "10x faster implementation of `git status` command";
121 To enable the included gitstatus prompt, add the appropriate line to your NixOS configuration:
122 `programs.bash.promptInit = "source $(gitstatus-share)/gitstatus.prompt.sh";`
123 `programs.zsh.promptInit = "source $(gitstatus-share)/gitstatus.prompt.zsh";`
125 See the project homepage for details on customization.
127 homepage = "https://github.com/romkatv/gitstatus";
128 license = licenses.gpl3Only;
129 maintainers = with maintainers; [
134 platforms = platforms.all;
135 mainProgram = "gitstatusd";