Merge pull request #330634 from r-ryantm/auto-update/circumflex
[NixPkgs.git] / pkgs / shells / bash / undistract-me / default.nix
blobb15903e779ea929c08441b61300fa5b9d772d8fd
1 { lib
2 , stdenvNoCC
3 , fetchFromGitHub
4 , fetchpatch
5 , coreutils
6 , gnused
7 , libnotify
8 , pulseaudio
9 , sound-theme-freedesktop
10 , xprop
13 stdenvNoCC.mkDerivation rec {
14   pname = "undistract-me";
15   version = "unstable-2020-08-09";
17   src = fetchFromGitHub {
18     owner = "jml";
19     repo = pname;
20     rev = "2f8ac25c6ad8efcf160d2b480825b1cbb6772aab";
21     hash = "sha256-Qw7Cu9q0ZgK/RTvyDdHM5N3eBaKjtYqYH0J+hKMUZX8=";
22   };
24   patches = [
25     # Don't block the terminal when notification sound is played
26     #
27     # See https://github.com/jml/undistract-me/pull/69
28     (fetchpatch {
29       url = "https://github.com/jml/undistract-me/commit/2356ebbe8bf2bcb4b95af1ae2bcdc786ce7cc6e8.patch";
30       sha256 = "sha256-Ij3OXTOnIQsYhKVmqjChhN1q4ASZ7waOkfQTTp5XfPo=";
31     })
33     # Fix showing notifications when using Wayland apps with XWayland
34     # running, or connection to X server fails.
35     #
36     # NOTE: Without a real X server, notifications will not be
37     # suppressed when the window running the command is focused.
38     #
39     # See https://github.com/jml/undistract-me/pull/71
40     (fetchpatch {
41       url = "https://github.com/jml/undistract-me/commit/3f4ceaf5a4eba8e3cb02236c48247f87e3d1124f.patch";
42       sha256 = "sha256-9AK9Jp3TXJ75Y+jwZXlwQ6j54FW1rOBddoktrm0VX68=";
43     })
44   ];
46   strictDeps = true;
48   # Patch in dependencies. Can't use makeWrapper because the bash
49   # functions will be sourced and invoked in a different environment
50   # for each command invocation.
51   postPatch = ''
52     for script in *.bash *.sh; do
53       substituteInPlace "$script" \
54         --replace /usr/share/undistract-me "$out/share/undistract-me" \
55         --replace basename ${coreutils}/bin/basename \
56         --replace 'cut ' '${coreutils}/bin/cut ' \
57         --replace date ${coreutils}/bin/date \
58         --replace dirname ${coreutils}/bin/dirname \
59         --replace sed ${gnused}/bin/sed \
60         --replace notify-send ${libnotify}/bin/notify-send \
61         --replace paplay ${pulseaudio}/bin/paplay \
62         --replace /usr/share/sounds/freedesktop ${sound-theme-freedesktop}/share/sounds/freedesktop \
63         --replace xprop ${xprop}/bin/xprop
64     done
65   '';
67   installPhase = ''
68     mkdir -p "$out/share/undistract-me" "$out/etc/profile.d" "$out/share/licenses/undistract-me"
69     cp long-running.bash "$out/share/undistract-me"
70     cp preexec.bash "$out/share/undistract-me"
71     cp undistract-me.sh "$out/etc/profile.d"
72     cp LICENSE "$out/share/licenses/undistract-me"
73   '';
75   meta = with lib; {
76     description = "Notifies you when long-running terminal commands complete";
77     homepage = "https://github.com/jml/undistract-me";
78     license = licenses.mit;
79     maintainers = with maintainers; [ kira-bruneau ];
80   };