i810switch: modernize

This commit is contained in:
Moraxyc 2025-02-22 21:28:42 +08:00
parent 9469c20cb8
commit 39a2802a51
No known key found for this signature in database

View File

@ -2,35 +2,49 @@
lib,
stdenv,
fetchurl,
installShellFiles,
pciutils,
}:
stdenv.mkDerivation {
stdenv.mkDerivation (finalAttrs: {
pname = "i810switch";
version = "0.6.5";
installPhase = "
sed -i -e 's+/usr++' Makefile
sed -i -e 's+^\\(.*putenv(\"PATH=\\).*$+\\1${pciutils}/sbin\");+' i810switch.c
make clean
make install DESTDIR=\${out}
";
src = fetchurl {
url = "http://www16.plala.or.jp/mano-a-mano/i810switch/i810switch-0.6.5.tar.gz";
sha256 = "d714840e3b14e1fa9c432c4be0044b7c008d904dece0d611554655b979cad4c3";
url = "http://www16.plala.or.jp/mano-a-mano/i810switch/i810switch-${finalAttrs.version}.tar.gz";
hash = "sha256-1xSEDjsU4fqcQyxL4ARLfACNkE3s4NYRVUZVuXnK1MM=";
};
nativeBuildInputs = [ installShellFiles ];
preBuild = ''
make clean
substituteInPlace i810switch.c \
--replace-fail 'define CMD_LSPCI "lspci"' 'define CMD_LSPCI "${lib.getExe' pciutils "lspci"}"'
'';
installPhase = "
runHook preInstall
install -Dm755 -t $out/bin i810switch i810rotate
installManPage i810switch.1.gz i810rotate.1.gz
runHook postInstall
";
# Ignore errors since gcc-14.
# i810switch.c:251:34: error: passing argument 2 of 'getline' from incompatible pointer type [-Wincompatible-pointer-types]
# i810switch.c:296:34: error: passing argument 2 of 'getline' from incompatible pointer type [-Wincompatible-pointer-types]
env.NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types";
meta = with lib; {
meta = {
description = "Utility for switching between the LCD and external VGA display on Intel graphics cards";
homepage = "http://www16.plala.or.jp/mano-a-mano/i810switch.html";
maintainers = [ ];
license = licenses.gpl2Only;
platforms = platforms.linux;
license = lib.licenses.gpl2Only;
platforms = lib.platforms.linux;
mainProgram = "i810switch";
};
}
})