3
0
Fork 0
forked from mirrors/nixpkgs

mons: migrate to resholve.mkDerivation

This allows us to have a purer package, and also we can remove the patch
to xrandr.
This commit is contained in:
Thiago Kenji Okada 2022-05-22 20:59:03 +01:00
parent 6323f3ccba
commit 56dd7b9b1c
2 changed files with 67 additions and 23 deletions

View file

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

View file

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