1{
2 fetchFromGitHub,
3 lib,
4 stdenv,
5 perl,
6 makeWrapper,
7 iproute2,
8 acpi,
9 sysstat,
10 alsa-utils,
11 scripts ? [
12 "bandwidth"
13 "battery"
14 "cpu_usage"
15 "disk"
16 "iface"
17 "load_average"
18 "memory"
19 "volume"
20 "wifi"
21 ],
22}:
23
24let
25 perlscripts = [
26 "battery"
27 "cpu_usage"
28 "openvpn"
29 "temperature"
30 ];
31 contains_any = l1: l2: 0 < lib.length (lib.intersectLists l1 l2);
32
33in
34stdenv.mkDerivation rec {
35 pname = "i3blocks-gaps";
36 version = "1.4";
37
38 src = fetchFromGitHub {
39 owner = "Airblader";
40 repo = "i3blocks-gaps";
41 rev = "4cfdf93c75f729a2c96d471004d31734e923812f";
42 sha256 = "0v9307ij8xzwdaxay3r75sd2cp453s3qb6q7dy9fks2p6wwqpazi";
43 };
44
45 makeFlags = [ "all" ];
46 installFlags = [
47 "PREFIX=\${out}"
48 "VERSION=${version}"
49 ];
50
51 buildInputs = lib.optional (contains_any scripts perlscripts) perl;
52 nativeBuildInputs = [ makeWrapper ];
53
54 postFixup =
55 lib.optionalString (lib.elem "bandwidth" scripts) ''
56 wrapProgram $out/libexec/i3blocks/bandwidth \
57 --prefix PATH : ${lib.makeBinPath [ iproute2 ]}
58 ''
59 + lib.optionalString (lib.elem "battery" scripts) ''
60 wrapProgram $out/libexec/i3blocks/battery \
61 --prefix PATH : ${lib.makeBinPath [ acpi ]}
62 ''
63 + lib.optionalString (lib.elem "cpu_usage" scripts) ''
64 wrapProgram $out/libexec/i3blocks/cpu_usage \
65 --prefix PATH : ${lib.makeBinPath [ sysstat ]}
66 ''
67 + lib.optionalString (lib.elem "iface" scripts) ''
68 wrapProgram $out/libexec/i3blocks/iface \
69 --prefix PATH : ${lib.makeBinPath [ iproute2 ]}
70 ''
71 + lib.optionalString (lib.elem "volume" scripts) ''
72 wrapProgram $out/libexec/i3blocks/volume \
73 --prefix PATH : ${lib.makeBinPath [ alsa-utils ]}
74 '';
75
76 meta = with lib; {
77 description = "Flexible scheduler for your i3bar blocks -- this is a fork to use with i3-gaps";
78 mainProgram = "i3blocks";
79 homepage = "https://github.com/Airblader/i3blocks-gaps";
80 license = licenses.gpl3;
81 maintainers = with maintainers; [ carlsverre ];
82 platforms = platforms.linux;
83 };
84}