Merge pull request #174039 from thiagokokada/migrate-mons-to-resholve

mons: migrate to resholve.mkDerivation

authored by Thiago Kenji Okada and committed by GitHub d9c647d7 4b2827e6

+67 -23
+67 -9
pkgs/tools/misc/mons/default.nix
··· 1 - { stdenv, lib, fetchFromGitHub, help2man, xrandr }: 1 + { lib 2 + , bash 3 + , coreutils 4 + , fetchFromGitHub 5 + , gawk 6 + , gnugrep 7 + , gnused 8 + , help2man 9 + , resholve 10 + , xrandr 11 + }: 2 12 3 - stdenv.mkDerivation rec { 13 + resholve.mkDerivation rec { 4 14 pname = "mons"; 5 - version = "20200320"; 15 + version = "unstable-2020-03-20"; 6 16 7 17 src = fetchFromGitHub { 8 18 owner = "Ventto"; ··· 12 22 fetchSubmodules = true; 13 23 }; 14 24 15 - patches = [ 16 - # Substitute xrandr path with @xrandr@ so we can replace it with 17 - # real path in substituteInPlace 18 - ./xrandr.patch 19 - ]; 25 + /* 26 + Remove reference to `%LIBDIR%/liblist.sh`. This would be linked to the 27 + non-resholved of the library in the final derivation. 20 28 29 + Patching out the library check; it's bad on multiple levels: 30 + 1. The check literally breaks if it fails. 31 + See https://github.com/Ventto/mons/pull/49 32 + 2. It doesn't need to do this; source would fail with a 33 + sensible message if the script was missing. 34 + 3. resholve can't wrestle with test/[] (at least until 35 + https://github.com/abathur/resholve/issues/78) 36 + */ 21 37 postPatch = '' 22 - substituteInPlace mons.sh --replace '@xrandr@' '${xrandr}/bin/xrandr' 38 + substituteInPlace mons.sh \ 39 + --replace "lib='%LIBDIR%/liblist.sh'" "" \ 40 + --replace '[ ! -r "$lib" ] && { "$lib: library not found."; exit 1; }' "" 23 41 ''; 24 42 43 + solutions = { 44 + mons = { 45 + scripts = [ "bin/mons" "lib/libshlist/liblist.sh" ]; 46 + interpreter = "${bash}/bin/sh"; 47 + inputs = [ 48 + bash 49 + coreutils 50 + gawk 51 + gnugrep 52 + gnused 53 + xrandr 54 + ]; 55 + fix = { 56 + "$lib" = [ "lib/libshlist/liblist.sh" ]; 57 + "$XRANDR" = [ "xrandr" ]; 58 + }; 59 + keep = { 60 + /* 61 + has a whole slate of *flag variables that it sets to either 62 + the true or false builtin and then executes... 63 + */ 64 + "$aFlag" = true; 65 + "$dFlag" = true; 66 + "$eFlag" = true; 67 + "$mFlag" = true; 68 + "$nFlag" = true; 69 + "$oFlag" = true; 70 + "$sFlag" = true; 71 + "$OFlag" = true; 72 + "$SFlag" = true; 73 + "$pFlag" = true; 74 + "$iFlag" = true; 75 + "$xFlag" = true; 76 + "$is_flag" = true; 77 + }; 78 + }; 79 + }; 80 + 25 81 nativeBuildInputs = [ help2man ]; 82 + 26 83 makeFlags = [ 27 84 "DESTDIR=$(out)" 28 85 "PREFIX=" ··· 33 90 homepage = "https://github.com/Ventto/mons.git"; 34 91 license = licenses.mit; 35 92 maintainers = with maintainers; [ mschneider thiagokokada ]; 93 + platforms = platforms.unix; 36 94 }; 37 95 }
-14
pkgs/tools/misc/mons/xrandr.patch
··· 1 - diff --git a/mons.sh b/mons.sh 2 - index b86ce5c..feb0f33 100755 3 - --- a/mons.sh 4 - +++ b/mons.sh 5 - @@ -151,8 +151,7 @@ main() { 6 - # ============================= 7 - 8 - [ -z "$DISPLAY" ] && { echo 'DISPLAY: no variable set.'; exit 1; } 9 - - command -vp xrandr >/dev/null 2>&1 || { echo 'xrandr: command not found.'; exit 1; } 10 - - XRANDR="$(command -pv xrandr)" 11 - + XRANDR="@xrandr@" 12 - 13 - # ============================= 14 - # Argument Checking