{ lib, stdenv, electron, fetchFromGitHub, fetchurl, fetchYarnDeps, fixup-yarn-lock, autoPatchelfHook, writableTmpDirAsHomeHook, git, copyDesktopItems, makeDesktopItem, makeWrapper, nodejs, yarn, alsa-lib, at-spi2-atk, cairo, cups, ffmpeg, flac, gcc-unwrapped, glibc, gtk3, libgbm, libglvnd, libpng, libpulseaudio, libjpeg, libxkbcommon, libxslt, nspr, nss, pango, }: stdenv.mkDerivation (finalAttrs: { pname = "unofficial-homestuck-collection"; version = "2.7.0"; src = fetchFromGitHub { owner = "GiovanH"; repo = "unofficial-homestuck-collection"; rev = "v${finalAttrs.version}"; hash = "sha256-rCeWayu32+Y3JRgqTLe36AcxZT+mXZnEaEAkJbL3iI0="; leaveDotGit = true; }; patches = [ ./0001-fix-source.patch ]; offlineCache = fetchYarnDeps { yarnLock = "${finalAttrs.src}/yarn.lock"; hash = "sha256-mo5Ir/pLoqc6K/0AOJqKC0yup7vx9UrNfQ+casIgBCo="; }; phantomJS = fetchurl { url = "https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2"; hash = "sha256-ht2aS/Su5F8ahMn2HPGUfB1tzpuejSqQcQXaeFJGDS8="; }; nativeBuildInputs = [ autoPatchelfHook copyDesktopItems fixup-yarn-lock git makeWrapper nodejs writableTmpDirAsHomeHook yarn ]; buildInputs = [ alsa-lib at-spi2-atk cairo cups flac gtk3 libgbm libpng libpulseaudio libjpeg libxkbcommon libxslt nspr nss pango ]; env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; configurePhase = '' runHook preConfigure # setup yarn fixup-yarn-lock yarn.lock yarn config --offline set ignore-engines true yarn config --offline set yarn-offline-mirror $offlineCache yarn install --offline --frozen-lockfile --ignore-scripts --no-progress patchShebangs node_modules # fixup node_modules cp $phantomJS node_modules/phantomjs-prebuilt/phantomjs.tar.bz2 patch node_modules/phantomjs-prebuilt/install.js ${./phantomjs.patch} touch node_modules/electron/path.txt runHook postConfigure ''; buildPhase = '' runHook preBuild pushd node_modules/phantomjs-prebuilt node install.js popd make src/imods.tar.gz make src/js/crc_imods.json env NODE_OPTIONS=--max_old_space_size=8192 \ yarn run vue-cli-service electron:build \ --linux --dir \ -c.electronDist=${electron.dist} \ -c.electronVersion=${electron.version} \ --config ${./electron-builder.yml} runHook postBuild ''; installPhase = '' runHook preInstall install -Dm644 build/icons/16x16.png $out/share/icons/hicolor/16x16/apps/unofficial-homestuck-collection.png install -Dm644 build/icons/24x24.png $out/share/icons/hicolor/24x24/apps/unofficial-homestuck-collection.png install -Dm644 build/icons/32x32.png $out/share/icons/hicolor/32x32/apps/unofficial-homestuck-collection.png install -Dm644 build/icons/48x48.png $out/share/icons/hicolor/48x48/apps/unofficial-homestuck-collection.png install -Dm644 build/icons/64x64.png $out/share/icons/hicolor/64x64/apps/unofficial-homestuck-collection.png install -Dm644 build/icons/128x128.png $out/share/icons/hicolor/128x128/apps/unofficial-homestuck-collection.png install -Dm644 build/icons/256x256.png $out/share/icons/hicolor/256x256/apps/unofficial-homestuck-collection.png install -Dm644 build/icons/512x512.png $out/share/icons/hicolor/512x512/apps/unofficial-homestuck-collection.png install -Dm644 build/icons/1024x1024.png $out/share/icons/hicolor/1024x1024/apps/unofficial-homestuck-collection.png mkdir -p $out/share/unofficial-homestuck-collection $out/bin cp -r dist_electron/linux-unpacked/* $out/share/unofficial-homestuck-collection makeWrapper $out/share/unofficial-homestuck-collection/unofficial-homestuck-collection $out/bin/unofficial-homestuck-collection \ --set LD_LIBRARY_PATH "${ lib.makeLibraryPath [ glibc gcc-unwrapped.lib libglvnd ] }" \ --add-flags --no-sandbox runHook postInstall ''; desktopItems = [ (makeDesktopItem { name = "unofficial-homestuck-collection"; exec = "unofficial-homestuck-collection"; icon = "unofficial-homestuck-collection"; desktopName = "unofficial-homestuck-collection"; categories = ["Game"]; mimeTypes = ["x-scheme-handler/mspa"]; }) ]; meta = { description = "Offline collection of Homestuck and its related works"; homepage = "https://homestuck.giovanh.com/unofficial-homestuck-collection/"; changelog = "https://github.com/GiovanH/unofficial-homestuck-collection/releases/tag/v${finalAttrs.version}"; license = lib.licenses.gpl3; maintainers = with lib.maintainers; [ kenshineto ]; mainProgram = "unofficial-homestuck-collection"; # phantomjs does not support aarch64 :( # TODO: kenshineto: macos support, i dont own a mac platforms = ["x86_64-linux"]; }; })