Unverified Commit 09b22eb8 authored by Peder Bergebakken Sundt's avatar Peder Bergebakken Sundt Committed by GitHub
Browse files

i810switch: fix build on gcc-14 & modernize (#384245)

parents 2f934679 39a2802a
Loading
Loading
Loading
Loading
+32 −13
Original line number Diff line number Diff line
@@ -2,30 +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
  src = fetchurl {
    url = "http://www16.plala.or.jp/mano-a-mano/i810switch/i810switch-${finalAttrs.version}.tar.gz";
    hash = "sha256-1xSEDjsU4fqcQyxL4ARLfACNkE3s4NYRVUZVuXnK1MM=";
  };

  nativeBuildInputs = [ installShellFiles ];

  preBuild = ''
    make clean
    make install DESTDIR=\${out}

    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
  ";

  src = fetchurl {
    url = "http://www16.plala.or.jp/mano-a-mano/i810switch/i810switch-0.6.5.tar.gz";
    sha256 = "d714840e3b14e1fa9c432c4be0044b7c008d904dece0d611554655b979cad4c3";
  };
  # 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";
  };
}
})