From ef169558cd630c4b7aa5b9ef4b86a13fb0628a3c Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 3 Nov 2024 12:55:20 -0300 Subject: [PATCH] higan: refactor - nixfmt-rfc-style --- pkgs/by-name/hi/higan/package.nix | 267 ++++++++++-------- .../0001-include-cmath.patch} | 0 .../0002-sips-to-png2icns.patch} | 0 3 files changed, 145 insertions(+), 122 deletions(-) rename pkgs/by-name/hi/higan/{001-include-cmath.patch => patches/0001-include-cmath.patch} (100%) rename pkgs/by-name/hi/higan/{002-sips-to-png2icns.patch => patches/0002-sips-to-png2icns.patch} (100%) diff --git a/pkgs/by-name/hi/higan/package.nix b/pkgs/by-name/hi/higan/package.nix index e75d5615ccb1..01cad29145c2 100644 --- a/pkgs/by-name/hi/higan/package.nix +++ b/pkgs/by-name/hi/higan/package.nix @@ -1,22 +1,24 @@ -{ lib -, SDL2 -, alsa-lib -, fetchFromGitHub -, gtk3 -, gtksourceview3 -, libGL -, libGLU -, libX11 -, libXv -, libao -, libicns -, libpulseaudio -, openal -, pkg-config -, runtimeShell -, stdenv -, udev -, unstableGitUpdater +{ + lib, + SDL2, + alsa-lib, + fetchFromGitHub, + gtk3, + gtksourceview3, + libGL, + libGLU, + libX11, + libXv, + libao, + libicns, + libpulseaudio, + openal, + installShellFiles, + pkg-config, + runtimeShell, + stdenv, + udev, + unstableGitUpdater, }: stdenv.mkDerivation (finalAttrs: { @@ -30,124 +32,144 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-M8WaPrOPSRKxhYcf6ffNkDzITkCltNF9c/zl0GmfJrI="; }; - nativeBuildInputs = [ - pkg-config - ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ - libicns - ]; + nativeBuildInputs = + [ + installShellFiles + pkg-config + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + libicns + ]; - buildInputs = [ - SDL2 - libao - ] ++ lib.optionals stdenv.hostPlatform.isLinux [ - alsa-lib - gtk3 - gtksourceview3 - libGL - libGLU - libX11 - libXv - libpulseaudio - openal - udev - ]; + buildInputs = + [ + SDL2 + libao + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + alsa-lib + gtk3 + gtksourceview3 + libGL + libGLU + libX11 + libXv + libpulseaudio + openal + udev + ]; patches = [ # Includes cmath header - ./001-include-cmath.patch + ./patches/0001-include-cmath.patch # Uses png2icns instead of sips - ./002-sips-to-png2icns.patch + ./patches/0002-sips-to-png2icns.patch ]; dontConfigure = true; enableParallelBuilding = true; - buildPhase = let - platform = - if stdenv.hostPlatform.isLinux - then "linux" - else if stdenv.hostPlatform.isDarwin - then "macos" - else if stdenv.hostPlatform.isBSD - then "bsd" - else if stdenv.hostPlatform.isWindows - then "windows" - else throw "Unknown platform for higan: ${stdenv.hostPlatform.system}"; - in '' - runHook preBuild - - make -C higan-ui -j$NIX_BUILD_CORES \ - compiler=${stdenv.cc.targetPrefix}c++ \ - platform=${platform} \ - openmp=true \ - hiro=gtk3 \ - build=accuracy \ - local=false \ - cores="cv fc gb gba md ms msx ngp pce sfc sg ws" - - make -C icarus -j$NIX_BUILD_CORES \ - compiler=${stdenv.cc.targetPrefix}c++ \ - platform=${platform} \ - openmp=true \ - hiro=gtk3 - - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - - '' + (if stdenv.hostPlatform.isDarwin then '' - mkdir ${placeholder "out"} - mv higan/out/higan.app ${placeholder "out"}/ - mv icarus/out/icarus.app ${placeholder "out"}/ - '' else '' - install -d ${placeholder "out"}/bin - install higan-ui/out/higan -t ${placeholder "out"}/bin/ - install icarus/out/icarus -t ${placeholder "out"}/bin/ - - install -d ${placeholder "out"}/share/applications - install higan-ui/resource/higan.desktop -t ${placeholder "out"}/share/applications/ - install icarus/resource/icarus.desktop -t ${placeholder "out"}/share/applications/ - - install -d ${placeholder "out"}/share/pixmaps - install higan/higan/resource/higan.svg ${placeholder "out"}/share/pixmaps/higan-icon.svg - install higan/higan/resource/logo.png ${placeholder "out"}/share/pixmaps/higan-icon.png - install icarus/resource/icarus.svg ${placeholder "out"}/share/pixmaps/icarus-icon.svg - install icarus/resource/icarus.png ${placeholder "out"}/share/pixmaps/icarus-icon.png - '') + '' - install -d ${placeholder "out"}/share/higan - cp -rd extras/ higan/System/ ${placeholder "out"}/share/higan/ - - install -d ${placeholder "out"}/share/icarus - cp -rd icarus/Database icarus/Firmware ${placeholder "out"}/share/icarus/ - '' + ( - # A dirty workaround, suggested by @cpages: - # we create a first-run script to populate - # $HOME with all the stuff needed at runtime + buildPhase = let - dest = if stdenv.hostPlatform.isDarwin - then "\\$HOME/Library/Application Support/higan" - else "\\$HOME/higan"; - in '' - mkdir -p ${placeholder "out"}/bin - cat < ${placeholder "out"}/bin/higan-init.sh - #!${runtimeShell} + platform = + if stdenv.hostPlatform.isLinux then + "linux" + else if stdenv.hostPlatform.isDarwin then + "macos" + else if stdenv.hostPlatform.isBSD then + "bsd" + else if stdenv.hostPlatform.isWindows then + "windows" + else + throw "Unknown platform for higan: ${stdenv.hostPlatform.system}"; + in + '' + runHook preBuild - cp --recursive --update ${placeholder "out"}/share/higan/System/ "${dest}"/ + make -C higan-ui -j$NIX_BUILD_CORES \ + compiler=${stdenv.cc.targetPrefix}c++ \ + platform=${platform} \ + openmp=true \ + hiro=gtk3 \ + build=accuracy \ + local=false \ + cores="cv fc gb gba md ms msx ngp pce sfc sg ws" - EOF + make -C icarus -j$NIX_BUILD_CORES \ + compiler=${stdenv.cc.targetPrefix}c++ \ + platform=${platform} \ + openmp=true \ + hiro=gtk3 - chmod +x ${placeholder "out"}/bin/higan-init.sh - '') + '' + runHook postBuild + ''; - runHook postInstall - ''; + installPhase = + '' + runHook preInstall - passthru.updateScript = unstableGitUpdater {}; + '' + + ( + if stdenv.hostPlatform.isDarwin then + '' + mkdir $out + mv higan/out/higan.app $out/ + mv icarus/out/icarus.app $out/ + '' + else + '' + installBin higan-ui/out/higan icarus/out/icarus - meta = with lib; { + install -d $out/share/applications + install higan-ui/resource/higan.desktop -t $out/share/applications/ + install icarus/resource/icarus.desktop -t $out/share/applications/ + + install -d $out/share/pixmaps + install higan/higan/resource/higan.svg $out/share/pixmaps/higan-icon.svg + install higan/higan/resource/logo.png $out/share/pixmaps/higan-icon.png + install icarus/resource/icarus.svg $out/share/pixmaps/icarus-icon.svg + install icarus/resource/icarus.png $out/share/pixmaps/icarus-icon.png + '' + ) + + '' + install -d $out/share/higan + cp -rd extras/ higan/System/ $out/share/higan/ + + install -d $out/share/icarus + cp -rd icarus/Database icarus/Firmware $out/share/icarus/ + '' + + ( + # A dirty workaround, suggested by @cpages: + # we create a first-run script to populate + # $HOME with all the stuff needed at runtime + let + dest = + if stdenv.hostPlatform.isDarwin then + "\\$HOME/Library/Application Support/higan" + else + "\\$HOME/higan"; + in + '' + mkdir -p $out/bin + cat < $out/bin/higan-init.sh + #!${runtimeShell} + + cp --recursive --update $out/share/higan/System/ "${dest}"/ + + EOF + + chmod +x $out/bin/higan-init.sh + '' + ) + + '' + + runHook postInstall + ''; + + passthru.updateScript = unstableGitUpdater { }; + + meta = { homepage = "https://github.com/higan-emu/higan"; description = "Open-source, cycle-accurate multi-system emulator"; longDescription = '' @@ -161,10 +183,11 @@ stdenv.mkDerivation (finalAttrs: { Neo Geo Pocket Color, WonderSwan, WonderSwan Color, SwanCrystal, Pocket Challenge V2. ''; - license = licenses.gpl3Plus; - maintainers = with maintainers; [ AndersonTorres ]; - platforms = platforms.unix; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ AndersonTorres ]; + platforms = lib.platforms.unix; broken = stdenv.hostPlatform.isDarwin; }; }) # TODO: select between Qt and GTK3 +# TODO: call Darwin hackers to deal with respective problems diff --git a/pkgs/by-name/hi/higan/001-include-cmath.patch b/pkgs/by-name/hi/higan/patches/0001-include-cmath.patch similarity index 100% rename from pkgs/by-name/hi/higan/001-include-cmath.patch rename to pkgs/by-name/hi/higan/patches/0001-include-cmath.patch diff --git a/pkgs/by-name/hi/higan/002-sips-to-png2icns.patch b/pkgs/by-name/hi/higan/patches/0002-sips-to-png2icns.patch similarity index 100% rename from pkgs/by-name/hi/higan/002-sips-to-png2icns.patch rename to pkgs/by-name/hi/higan/patches/0002-sips-to-png2icns.patch