From 235d9e218736a7d930992e7297bef1182d69fd60 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Thu, 9 Feb 2023 13:54:06 +0100 Subject: [PATCH 1/3] lib/licenses.nix: Add cc-by-nc-nd-30 --- lib/licenses.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/licenses.nix b/lib/licenses.nix index 0c4d9d8bc9e1..601ea5866cfe 100644 --- a/lib/licenses.nix +++ b/lib/licenses.nix @@ -220,6 +220,12 @@ in mkLicense lset) ({ fullName = "Creative Commons Zero v1.0 Universal"; }; + cc-by-nc-nd-30 = { + spdxId = "CC-BY-NC-ND-3.0"; + fullName = "Creative Commons Attribution Non Commercial No Derivative Works 3.0 Unported"; + free = false; + }; + cc-by-nc-sa-20 = { spdxId = "CC-BY-NC-SA-2.0"; fullName = "Creative Commons Attribution Non Commercial Share Alike 2.0"; From 3c4b76f46e2a7301b516df31d6024782eba9ba07 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Sun, 5 Mar 2023 18:39:19 +0100 Subject: [PATCH 2/3] katawa-shoujo: init at 1.3.1 --- pkgs/games/katawa-shoujo/default.nix | 163 +++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 165 insertions(+) create mode 100644 pkgs/games/katawa-shoujo/default.nix diff --git a/pkgs/games/katawa-shoujo/default.nix b/pkgs/games/katawa-shoujo/default.nix new file mode 100644 index 000000000000..aeee79c5c029 --- /dev/null +++ b/pkgs/games/katawa-shoujo/default.nix @@ -0,0 +1,163 @@ +{ stdenvNoCC +, lib +, fetchurl +, autoPatchelfHook +, freetype +, makeWrapper +, libGL +, libGLU +# Darwin cannot handle these when devendored: +# - DYLD_LIBRARY_PATH masks system libraries with similar, differently-cased names and cause missing symbol errors +# - symlinks cause unrelated BMP image loading to fail(?) +, devendorImageLibs ? !stdenvNoCC.hostPlatform.isDarwin +, libjpeg +, libpng12 +, libX11 +, libXext +, libXi +, libXmu +, runtimeShell +, SDL_compat +, SDL_image +, SDL_ttf +, undmg +, zlib +}: + +let + stdenv = stdenvNoCC; + srcDetails = rec { + x86_64-linux = { + urlSuffix = "%5blinux-x86%5d%5b18161880%5d.tar.bz2"; + hash = "sha256-7FoFz88dWYHs2/pxkEwnmiFeeb3+slayrWknEJoAB9o="; + }; + i686-linux = x86_64-linux; + x86_64-darwin = { + urlSuffix = "%5bmac%5d%5b1DFC84A6%5d.dmg"; + hash = "sha256-Sc5BAlpJsffjcNrZ8+VU3n7G10DoqDKQn/leHDW32Y8="; + }; + }.${stdenv.hostPlatform.system} or (throw "Don't know how to fetch source for ${stdenv.hostPlatform.system}!"); +in +stdenv.mkDerivation rec { + pname = "katawa-shoujo"; + version = "1.3.1"; + + src = fetchurl { + url = "https://dl.katawa-shoujo.com/gold_${version}/%5b4ls%5d_katawa_shoujo_${version}-${srcDetails.urlSuffix}"; + inherit (srcDetails) hash; + }; + + # fetchzip requires a custom unpackPhase to handle dmg, fetchurl cannot handle undmg producing >1 directory without this + sourceRoot = "."; + + nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ + autoPatchelfHook + ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ + makeWrapper + undmg + ]; + + buildInputs = [ + freetype + SDL_compat + zlib + ] ++ lib.optionals devendorImageLibs [ + libjpeg + libpng12 + ] ++ lib.optionals stdenv.hostPlatform.isLinux [ + libX11 + libXext + libXi + libXmu + libGL + libGLU + ]; + + dontConfigure = true; + dontBuild = true; + + installPhase = let + platformDetails = with stdenv.hostPlatform; if isDarwin then rec { + arch = "darwin-x86_64"; + sourceDir = "'Katawa Shoujo'.app"; + installDir = "$out/Applications/'Katawa Shoujo'.app"; + dataDir = "${installDir}/Contents/Resources/autorun"; + bin = "${installDir}/Contents/MacOS/'Katawa Shoujo'"; + } else rec { + arch = "linux-${if isx86_64 then "x86_64" else "i686"}"; + sourceDir = "'Katawa Shoujo'-${version}-linux"; + installDir = "$out/share/katawa-shoujo"; + dataDir = installDir; + bin = "${installDir}/'Katawa Shoujo'.sh"; + }; + libDir = with platformDetails; "${dataDir}/lib/${arch}"; + in with platformDetails; '' + runHook preInstall + + mkdir -p "$(dirname ${installDir})" + cp -R ${sourceDir} ${installDir} + + # Simplify launcher script + cat <${bin} + #!${runtimeShell} + exec \$RENPY_GDB ${libDir}/'Katawa Shoujo' \$RENPY_PYARGS -EO ${dataDir}/'Katawa Shoujo'.py "\$@" + EOF + + '' + lib.optionalString stdenv.hostPlatform.isDarwin '' + # No autoPatchelfHook on Darwin + wrapProgram ${bin} \ + --prefix DYLD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs} + '' + '' + + # Delete binaries for wrong arch, autoPatchelfHook gets confused by them & less to keep in the store + find "$(dirname ${libDir})" -mindepth 1 -maxdepth 1 \ + -not -name 'python*' -not -name ${arch} \ + -exec rm -r {} \; + + # Replace some bundled libs so Nixpkgs' versions are used + rm ${libDir}/libz* + rm ${libDir}/libfreetype* + rm ${libDir}/libSDL-1.2* + '' + lib.optionalString devendorImageLibs '' + rm ${libDir}/libjpeg* + rm ${libDir}/libpng12* + '' + '' + + mkdir -p $out/share/{doc,licenses}/katawa-shoujo + mv ${dataDir}/'Game Manual'.pdf $out/share/doc/katawa-shoujo/ + mv ${dataDir}/LICENSE.txt $out/share/licenses/katawa-shoujo/ + + mkdir -p $out/bin + ln -s ${bin} $out/bin/katawa-shoujo + + runHook postInstall + ''; + + meta = with lib; { + description = "Bishoujo-style visual novel by Four Leaf Studios, built in Ren'Py"; + longDescription = '' + Katawa Shoujo is a bishoujo-style visual novel set in the fictional Yamaku High School for disabled children, + located somewhere in modern Japan. Hisao Nakai, a normal boy living a normal life, has his life turned upside down + when a congenital heart defect forces him to move to a new school after a long hospitalization. Despite his difficulties, + Hisao is able to find friends—and perhaps love, if he plays his cards right. There are five main paths corresponding + to the 5 main female characters, each path following the storyline pertaining to that character. + + The story is told through the perspective of the main character, using a first person narrative. The game uses a + traditional text and sprite-based visual novel model with an ADV text box. + + Katawa Shoujo contains adult material, and was created using the Ren'Py scripting system. It is the product of an + international team of amateur developers, and is available free of charge under the Creative Commons BY-NC-ND License. + ''; + homepage = "https://www.katawa-shoujo.com/"; + # https://www.katawa-shoujo.com/about.php + # November 2022: Update, is it still ND? + # https://ks.renai.us/viewtopic.php?f=13&p=248149#p248149 + license = with licenses; [ cc-by-nc-nd-30 ]; + maintainers = with maintainers; [ OPNA2608 ]; + # Building Ren'Py6 from source would allow more, but too much of a hassle + platforms = platforms.x86; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + # Needs different srcDetails & installPhase + broken = stdenv.hostPlatform.isWindows; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e47674107bbd..4aa18716b6a6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -34763,6 +34763,8 @@ with pkgs; jumpnbump = callPackage ../games/jumpnbump { }; + katawa-shoujo = callPackage ../games/katawa-shoujo { }; + keeperrl = callPackage ../games/keeperrl { }; ### GAMES/LGAMES From 992b72241df579171f3d3a34c0338fda89c315aa Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Wed, 8 Mar 2023 00:25:30 +0100 Subject: [PATCH 3/3] katawa-shoujo: Add desktop file unrpa works again so we can extract the icon from the game assets for it. --- pkgs/games/katawa-shoujo/default.nix | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pkgs/games/katawa-shoujo/default.nix b/pkgs/games/katawa-shoujo/default.nix index aeee79c5c029..e549fbbcf963 100644 --- a/pkgs/games/katawa-shoujo/default.nix +++ b/pkgs/games/katawa-shoujo/default.nix @@ -2,7 +2,9 @@ , lib , fetchurl , autoPatchelfHook +, copyDesktopItems , freetype +, makeDesktopItem , makeWrapper , libGL , libGLU @@ -21,6 +23,7 @@ , SDL_image , SDL_ttf , undmg +, unrpa , zlib }: @@ -52,6 +55,8 @@ stdenv.mkDerivation rec { nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook + copyDesktopItems + unrpa ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ makeWrapper undmg @@ -73,6 +78,15 @@ stdenv.mkDerivation rec { libGLU ]; + desktopItems = [(makeDesktopItem rec { + name = "katawa-shoujo"; + desktopName = "Katawa Shoujo"; + comment = meta.description; + exec = name; + icon = name; + categories = [ "Game" ]; + })]; + dontConfigure = true; dontBuild = true; @@ -103,11 +117,15 @@ stdenv.mkDerivation rec { exec \$RENPY_GDB ${libDir}/'Katawa Shoujo' \$RENPY_PYARGS -EO ${dataDir}/'Katawa Shoujo'.py "\$@" EOF - '' + lib.optionalString stdenv.hostPlatform.isDarwin '' + '' + (if stdenv.hostPlatform.isDarwin then '' # No autoPatchelfHook on Darwin wrapProgram ${bin} \ --prefix DYLD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs} - '' + '' + '' else '' + # Extract icon for xdg desktop file + unrpa ${dataDir}/game/data.rpa + install -Dm644 ui/icon.png $out/share/icons/hicolor/512x512/apps/katawa-shoujo.png + '') + '' # Delete binaries for wrong arch, autoPatchelfHook gets confused by them & less to keep in the store find "$(dirname ${libDir})" -mindepth 1 -maxdepth 1 \