From 4642e8d1cf750780aa7aa7be0674491cd4b3a522 Mon Sep 17 00:00:00 2001 From: Angelo Bulfone Date: Tue, 30 May 2017 11:30:41 -0700 Subject: [PATCH] i3blocks: add optional dependencies for scripts --- .../window-managers/i3/blocks-gaps.nix | 29 ++++++++++++- .../window-managers/i3/blocks.nix | 42 ++++++++++++++++++- 2 files changed, 68 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/window-managers/i3/blocks-gaps.nix b/pkgs/applications/window-managers/i3/blocks-gaps.nix index d32e82f100e2..83fe3ef163a3 100644 --- a/pkgs/applications/window-managers/i3/blocks-gaps.nix +++ b/pkgs/applications/window-managers/i3/blocks-gaps.nix @@ -1,5 +1,16 @@ -{ fetchFromGitHub, stdenv }: +{ fetchFromGitHub, stdenv, perl, makeWrapper +, iproute, acpi, sysstat, alsaUtils +, scripts ? [ "bandwidth" "battery" "cpu_usage" "disk" "iface" + "load_average" "memory" "volume" "wifi" ] +}: +with stdenv.lib; + +let + perlscripts = [ "battery" "cpu_usage" "openvpn" "temperature" ]; + contains_any = l1: l2: 0 < length( intersectLists l1 l2 ); + +in stdenv.mkDerivation rec { name = "i3blocks-gaps-${version}"; version = "1.4"; @@ -14,6 +25,22 @@ stdenv.mkDerivation rec { makeFlags = "all"; installFlags = "PREFIX=\${out} VERSION=${version}"; + buildInputs = optional (contains_any scripts perlscripts) perl; + nativeBuildInputs = [ makeWrapper ]; + + postFixup = '' + wrapProgram $out/libexec/i3blocks/bandwidth \ + --prefix PATH : ${makeBinPath (optional (elem "bandwidth" scripts) iproute)} + wrapProgram $out/libexec/i3blocks/battery \ + --prefix PATH : ${makeBinPath (optional (elem "battery" scripts) acpi)} + wrapProgram $out/libexec/i3blocks/cpu_usage \ + --prefix PATH : ${makeBinPath (optional (elem "cpu_usage" scripts) sysstat)} + wrapProgram $out/libexec/i3blocks/iface \ + --prefix PATH : ${makeBinPath (optional (elem "iface" scripts) iproute)} + wrapProgram $out/libexec/i3blocks/volume \ + --prefix PATH : ${makeBinPath (optional (elem "volume" scripts) alsaUtils)} + ''; + meta = with stdenv.lib; { description = "A flexible scheduler for your i3bar blocks -- this is a fork to use with i3-gaps"; homepage = https://github.com/Airblader/i3blocks-gaps; diff --git a/pkgs/applications/window-managers/i3/blocks.nix b/pkgs/applications/window-managers/i3/blocks.nix index 60f13ce440c3..88bf7762dd87 100644 --- a/pkgs/applications/window-managers/i3/blocks.nix +++ b/pkgs/applications/window-managers/i3/blocks.nix @@ -1,5 +1,19 @@ -{ fetchurl, stdenv }: +{ fetchurl, stdenv, perl, makeWrapper +, iproute, acpi, sysstat, xset, playerctl +, cmus, openvpn, lm_sensors, alsaUtils +, scripts ? [ "bandwidth" "battery" "cpu_usage" "disk" "iface" + "keyindicator" "load_average" "mediaplayer" "memory" + "openvpn" "temperature" "volume" "wifi" ] +}: +with stdenv.lib; + +let + perlscripts = [ "battery" "cpu_usage" "keyindicator" + "mediaplayer" "openvpn" "temperature" ]; + contains_any = l1: l2: 0 < length( intersectLists l1 l2 ); + +in stdenv.mkDerivation rec { name = "i3blocks-${version}"; version = "1.4"; @@ -12,7 +26,31 @@ stdenv.mkDerivation rec { buildFlags = "SYSCONFDIR=/etc all"; installFlags = "PREFIX=\${out} VERSION=${version}"; - meta = with stdenv.lib; { + buildInputs = optional (contains_any scripts perlscripts) perl; + nativeBuildInputs = [ makeWrapper ]; + + postFixup = '' + wrapProgram $out/libexec/i3blocks/bandwidth \ + --prefix PATH : ${makeBinPath (optional (elem "bandwidth" scripts) iproute)} + wrapProgram $out/libexec/i3blocks/battery \ + --prefix PATH : ${makeBinPath (optional (elem "battery" scripts) acpi)} + wrapProgram $out/libexec/i3blocks/cpu_usage \ + --prefix PATH : ${makeBinPath (optional (elem "cpu_usage" scripts) sysstat)} + wrapProgram $out/libexec/i3blocks/iface \ + --prefix PATH : ${makeBinPath (optional (elem "iface" scripts) iproute)} + wrapProgram $out/libexec/i3blocks/keyindicator \ + --prefix PATH : ${makeBinPath (optional (elem "keyindicator" scripts) xset)} + wrapProgram $out/libexec/i3blocks/mediaplayer \ + --prefix PATH : ${makeBinPath (optionals (elem "mediaplayer" scripts) [playerctl cmus])} + wrapProgram $out/libexec/i3blocks/openvpn \ + --prefix PATH : ${makeBinPath (optional (elem "openvpn" scripts) openvpn)} + wrapProgram $out/libexec/i3blocks/temperature \ + --prefix PATH : ${makeBinPath (optional (elem "temperature" scripts) lm_sensors)} + wrapProgram $out/libexec/i3blocks/volume \ + --prefix PATH : ${makeBinPath (optional (elem "volume" scripts) alsaUtils)} + ''; + + meta = { description = "A flexible scheduler for your i3bar blocks"; homepage = https://github.com/vivien/i3blocks; license = licenses.gpl3;