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

mons: migrate to resholve.mkDerivation
main
Thiago Kenji Okada 2 years ago committed by GitHub
commit d9c647d7d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 76
      pkgs/tools/misc/mons/default.nix
  2. 14
      pkgs/tools/misc/mons/xrandr.patch

@ -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;
};
}

@ -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
Loading…
Cancel
Save