diff --git a/pkgs/tools/misc/mons/default.nix b/pkgs/tools/misc/mons/default.nix index 920cab1763b..923c61532c6 100644 --- a/pkgs/tools/misc/mons/default.nix +++ b/pkgs/tools/misc/mons/default.nix @@ -1,8 +1,18 @@ -{ stdenv, lib, fetchFromGitHub, help2man, xrandr }: +{ lib +, bash +, coreutils +, fetchFromGitHub +, gawk +, gnugrep +, gnused +, help2man +, resholve +, xrandr +}: -stdenv.mkDerivation rec { +resholve.mkDerivation rec { pname = "mons"; - version = "20200320"; + version = "unstable-2020-03-20"; src = fetchFromGitHub { owner = "Ventto"; @@ -12,17 +22,64 @@ stdenv.mkDerivation rec { fetchSubmodules = true; }; - patches = [ - # Substitute xrandr path with @xrandr@ so we can replace it with - # real path in substituteInPlace - ./xrandr.patch - ]; + /* + Remove reference to `%LIBDIR%/liblist.sh`. This would be linked to the + non-resholved of the library in the final derivation. + Patching out the library check; it's bad on multiple levels: + 1. The check literally breaks if it fails. + See https://github.com/Ventto/mons/pull/49 + 2. It doesn't need to do this; source would fail with a + sensible message if the script was missing. + 3. resholve can't wrestle with test/[] (at least until + https://github.com/abathur/resholve/issues/78) + */ postPatch = '' - substituteInPlace mons.sh --replace '@xrandr@' '${xrandr}/bin/xrandr' + substituteInPlace mons.sh \ + --replace "lib='%LIBDIR%/liblist.sh'" "" \ + --replace '[ ! -r "$lib" ] && { "$lib: library not found."; exit 1; }' "" ''; + solutions = { + mons = { + scripts = [ "bin/mons" "lib/libshlist/liblist.sh" ]; + interpreter = "${bash}/bin/sh"; + inputs = [ + bash + coreutils + gawk + gnugrep + gnused + xrandr + ]; + fix = { + "$lib" = [ "lib/libshlist/liblist.sh" ]; + "$XRANDR" = [ "xrandr" ]; + }; + keep = { + /* + has a whole slate of *flag variables that it sets to either + the true or false builtin and then executes... + */ + "$aFlag" = true; + "$dFlag" = true; + "$eFlag" = true; + "$mFlag" = true; + "$nFlag" = true; + "$oFlag" = true; + "$sFlag" = true; + "$OFlag" = true; + "$SFlag" = true; + "$pFlag" = true; + "$iFlag" = true; + "$xFlag" = true; + "$is_flag" = true; + }; + }; + }; + nativeBuildInputs = [ help2man ]; + makeFlags = [ "DESTDIR=$(out)" "PREFIX=" @@ -33,5 +90,6 @@ stdenv.mkDerivation rec { homepage = "https://github.com/Ventto/mons.git"; license = licenses.mit; maintainers = with maintainers; [ mschneider thiagokokada ]; + platforms = platforms.unix; }; } diff --git a/pkgs/tools/misc/mons/xrandr.patch b/pkgs/tools/misc/mons/xrandr.patch deleted file mode 100644 index 6cbcdf9d514..00000000000 --- a/pkgs/tools/misc/mons/xrandr.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/mons.sh b/mons.sh -index b86ce5c..feb0f33 100755 ---- a/mons.sh -+++ b/mons.sh -@@ -151,8 +151,7 @@ main() { - # ============================= - - [ -z "$DISPLAY" ] && { echo 'DISPLAY: no variable set.'; exit 1; } -- command -vp xrandr >/dev/null 2>&1 || { echo 'xrandr: command not found.'; exit 1; } -- XRANDR="$(command -pv xrandr)" -+ XRANDR="@xrandr@" - - # ============================= - # Argument Checking