diff options
author | Thiago Kenji Okada <thiagokokada@gmail.com> | 2022-05-22 20:59:03 +0100 |
---|---|---|
committer | Thiago Kenji Okada <thiagokokada@gmail.com> | 2022-05-23 09:22:40 +0100 |
commit | 56dd7b9b1c5534fb653e4fee2c0b9e7543084ddb (patch) | |
tree | 756cc96dce3222086cc8dc90c1d8a0ba4f7844f5 /pkgs/tools/misc/mons | |
parent | 6323f3ccbaa5bacf5a62244c3ad6fca065f319d4 (diff) |
mons: migrate to resholve.mkDerivation
This allows us to have a purer package, and also we can remove the patch to xrandr.
Diffstat (limited to 'pkgs/tools/misc/mons')
-rw-r--r-- | pkgs/tools/misc/mons/default.nix | 76 | ||||
-rw-r--r-- | pkgs/tools/misc/mons/xrandr.patch | 14 |
2 files changed, 67 insertions, 23 deletions
diff --git a/pkgs/tools/misc/mons/default.nix b/pkgs/tools/misc/mons/default.nix index 920cab1763b8e..923c61532c6f5 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 6cbcdf9d514ee..0000000000000 --- 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 |