about summary refs log tree commit diff
path: root/pkgs/tools/misc/mons
diff options
context:
space:
mode:
authorThiago Kenji Okada <thiagokokada@gmail.com>2021-02-27 18:21:04 -0300
committerThiago Kenji Okada <thiagokokada@gmail.com>2021-02-28 20:57:52 -0300
commitd79c466e99a0159cd7c6d62320c41f3e6957a73e (patch)
tree715c6a385da2b07a4e7edd3a3659dadd0cc05ad2 /pkgs/tools/misc/mons
parent3081bd0ca972974f343abaedd13cfe0014379a6b (diff)
mons: declare xrandr explicitly instead of using it from PATH
mons tries to detect if xrandr is installed in the PATH, failing
otherwise. However, this is not the way that packages are generally
packaged in nixpkgs.

This commit changes it to hardcode the path of xrandr explicitly instead
of depending of xrandr being declared in PATH.
Diffstat (limited to 'pkgs/tools/misc/mons')
-rw-r--r--pkgs/tools/misc/mons/default.nix10
-rw-r--r--pkgs/tools/misc/mons/xrandr.patch14
2 files changed, 24 insertions, 0 deletions
diff --git a/pkgs/tools/misc/mons/default.nix b/pkgs/tools/misc/mons/default.nix
index a24e4869829c8..920cab1763b8e 100644
--- a/pkgs/tools/misc/mons/default.nix
+++ b/pkgs/tools/misc/mons/default.nix
@@ -12,6 +12,16 @@ stdenv.mkDerivation rec {
     fetchSubmodules = true;
   };
 
+  patches = [
+    # Substitute xrandr path with @xrandr@ so we can replace it with
+    # real path in substituteInPlace
+    ./xrandr.patch
+  ];
+
+  postPatch = ''
+    substituteInPlace mons.sh --replace '@xrandr@' '${xrandr}/bin/xrandr'
+  '';
+
   nativeBuildInputs = [ help2man ];
   makeFlags = [
     "DESTDIR=$(out)"
diff --git a/pkgs/tools/misc/mons/xrandr.patch b/pkgs/tools/misc/mons/xrandr.patch
new file mode 100644
index 0000000000000..6cbcdf9d514ee
--- /dev/null
+++ b/pkgs/tools/misc/mons/xrandr.patch
@@ -0,0 +1,14 @@
+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