Created
January 1, 2024 05:30
-
-
Save rrbutani/286ba7198b92373d4c4d84ea81564980 to your computer and use it in GitHub Desktop.
eggnogg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
inputs = { | |
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable; | |
flake-utils.url = github:numtide/flake-utils; | |
}; | |
outputs = { nixpkgs, flake-utils, self }: flake-utils.lib.eachDefaultSystem (system: let | |
np = nixpkgs.legacyPackages.${system}; | |
inherit (np) lib; | |
# TODO: macOS.. | |
npCross = if np.hostPlatform.isx86_64 && np.hostPlatform.isLinux then | |
import nixpkgs { | |
localSystem = system; # inherit system; | |
crossSystem = "i686-linux"; | |
} | |
else np; | |
# !!! There isn't a stable download URL so we parse the JSON response the | |
# download page yields as part of doing the fetch. | |
# | |
# We abuse `fetchurl`'s `postFetch` hook to do rather than create our own | |
# bespoke fixed-output derivation. | |
download-itch = { url, sha256, name ? "eggnogg-linux.tar.gz" }: np.callPackage ( | |
{ fetchurl | |
, jq | |
}: fetchurl { | |
inherit name url sha256; | |
curlOptsList = ["-XPOST"]; | |
nativeBuildInputs = [ jq ]; | |
postFetch = '' | |
actualUrl="$(jq -r <"$downloadedFile" '.url')" | |
# Remove `-XPOST` now: | |
curlOpts=("''${curl[@]}"); curl=() | |
for opt in "''${curlOpts[@]}"; do | |
if [[ "$opt" != '-XPOST' ]]; then curl+=("$opt"); fi | |
done | |
rm "$downloadedFile" | |
tryDownload "$actualUrl" | |
''; | |
} | |
) {}; | |
icon = np.fetchurl { | |
name = "eggnogg-icon.png"; | |
url = "http://madgarden.net/junkz/madgarden/eggnogg/icon-1.png"; | |
sha256 = "sha256-BJH1KXJht3zAl9dbwq+j9os1HMUcdrCs/Fh9RaUj5u0="; | |
}; | |
# From: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=eggnogg | |
eggnogg-classic = | |
{ lib | |
, stdenvNoCC | |
, autoPatchelfHook | |
, makeDesktopItem | |
, copyDesktopItems | |
, makeWrapper | |
# Need to be for `i686-linux` when targeting Linux. | |
, SDL | |
, SDL_mixer | |
, libglvnd | |
}: stdenvNoCC.mkDerivation (finalAttrs: { | |
pname = "eggnogg"; | |
version = "1.3.1"; # see `data/greetz.txt` | |
src = download-itch { | |
url = "https://madgarden.itch.io/eggnogg/file/908?after_download_lightbox=true"; | |
sha256 = "sha256-stMP+/0OaqUkdQfPY0g6TtoR/lDD5+hJ3pdZJhDQvFQ="; | |
}; | |
nativeBuildInputs = [ autoPatchelfHook copyDesktopItems makeWrapper ]; | |
buildInputs = [ | |
SDL | |
SDL_mixer | |
libglvnd | |
]; | |
desktopItems = [ | |
(makeDesktopItem rec { | |
name = "Eggnogg"; | |
exec = finalAttrs.pname; | |
inherit icon; | |
comment = finalAttrs.meta.description; | |
desktopName = name; | |
genericName = name; | |
categories = [ "Game" ]; | |
}) | |
]; | |
installPhase = '' | |
mkdir -p $out/bin $out/share/applications | |
mv data $out/ | |
copyDesktopItems | |
# game expects `pwd` to contain the `data` directory! | |
mv $pname $out/bin | |
wrapProgram $out/bin/$pname --chdir "$out" | |
''; | |
# binary doesn't read cli args; no easy way to test.. | |
# TODO: unfree? | |
meta = { | |
description = "A competitive arcade game of immortals sword-fighting to the death."; | |
homepage = "https://madgarden.itch.io/eggnogg"; | |
maintainers = with lib.maintainers; [ rrbutani ]; | |
# requires a platform that can run 32-bit x86 code! | |
platforms = with lib.systems.inspect; [ patterns.isx86_32 ]; # TODO: macOS? | |
badPlatforms = with lib.systems.inspect; [ platformPatterns.isStatic ]; | |
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; | |
}; | |
}); | |
eggnogg-plus = | |
{ lib | |
, stdenvNoCC | |
, autoPatchelfHook | |
, makeDesktopItem | |
, copyDesktopItems | |
, makeWrapper | |
, unzip | |
, SDL2 | |
, libglvnd | |
}: stdenvNoCC.mkDerivation (finalAttrs: { | |
pname = "eggnoggplus"; | |
version = "BETA"; # see `data/greetz.txt` | |
src = download-itch { | |
name = "eggnoggplus-linux.zip"; | |
url = "https://madgarden.itch.io/eggnogg/file/138869?source=game_download"; | |
sha256 = "sha256-U/rIGEZ4h3CFr1HRaWhthm9nmyGhTVkRXbw8M/PRd+M="; | |
}; | |
nativeBuildInputs = [ autoPatchelfHook copyDesktopItems makeWrapper unzip ]; | |
buildInputs = [ | |
SDL2 | |
libglvnd | |
]; | |
desktopItems = [ | |
(makeDesktopItem rec { | |
name = "Eggnogg+"; | |
exec = finalAttrs.pname; | |
inherit icon; | |
comment = finalAttrs.meta.description; | |
desktopName = name; | |
genericName = name; | |
categories = [ "Game" ]; | |
}) | |
]; | |
installPhase = '' | |
mkdir -p $out/bin $out/share/applications | |
mv data $out/ | |
copyDesktopItems | |
# game expects `pwd` to contain the `data` directory! | |
mv $pname $out/bin | |
wrapProgram $out/bin/$pname --chdir "$out" | |
''; | |
# binary doesn't read cli args; no easy way to test.. | |
# TODO: unfree? | |
meta = { | |
description = "A competitive arcade game of immortals sword-fighting to the death."; | |
homepage = "https://madgarden.itch.io/eggnogg"; | |
maintainers = with lib.maintainers; [ rrbutani ]; | |
# requires a platform that can run 64-bit x86 code! | |
platforms = with lib.systems.inspect; [ patterns.isx86_64 ]; # TODO: macOS? | |
badPlatforms = with lib.systems.inspect; [ platformPatterns.isStatic ]; | |
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; | |
}; | |
}); | |
in { | |
# TODO: | |
# assert np.hostPlatform.canExecute npCross.hostPlatform | |
# | |
# for eggnogg classic | |
# Eggnogg Classic is a 32-bit x86 binary: | |
# | |
# Build using the cross stdenv *but* override the libraries so we can lean | |
# on the cache for `i686` libraries (these don't build successfully under | |
# cross yet anyways...). | |
packages.eggnogg-classic = npCross.callPackage eggnogg-classic | |
(lib.optionalAttrs (npCross.hostPlatform.isx86_32 && npCross.hostPlatform.isLinux) { | |
inherit (np.pkgsi686Linux) SDL SDL_mixer libglvnd; | |
}); | |
# Eggnogg Plus is a 64-bit x86 binary; no need for cross. | |
packages.eggnogg-plus = np.callPackage eggnogg-plus {}; | |
packages.default = self.packages.${system}.eggnogg-plus; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment