11 # Darwin cannot handle these when devendored:
12 # - DYLD_LIBRARY_PATH masks system libraries with similar, differently-cased names and cause missing symbol errors
13 # - symlinks cause unrelated BMP image loading to fail(?)
14 , devendorImageLibs ? !stdenvNoCC.hostPlatform.isDarwin
34 urlSuffix = "%5blinux-x86%5d%5b18161880%5d.tar.bz2";
35 hash = "sha256-7FoFz88dWYHs2/pxkEwnmiFeeb3+slayrWknEJoAB9o=";
37 i686-linux = x86_64-linux;
39 urlSuffix = "%5bmac%5d%5b1DFC84A6%5d.dmg";
40 hash = "sha256-Sc5BAlpJsffjcNrZ8+VU3n7G10DoqDKQn/leHDW32Y8=";
42 }.${stdenv.hostPlatform.system} or (throw "Don't know how to fetch source for ${stdenv.hostPlatform.system}!");
44 stdenv.mkDerivation rec {
45 pname = "katawa-shoujo";
49 url = "https://dl.katawa-shoujo.com/gold_${version}/%5b4ls%5d_katawa_shoujo_${version}-${srcDetails.urlSuffix}";
50 inherit (srcDetails) hash;
53 # fetchzip requires a custom unpackPhase to handle dmg, fetchurl cannot handle undmg producing >1 directory without this
56 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [
60 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
69 ] ++ lib.optionals devendorImageLibs [
72 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
81 desktopItems = [(makeDesktopItem rec {
82 name = "katawa-shoujo";
83 desktopName = "Katawa Shoujo";
84 comment = meta.description;
87 categories = [ "Game" ];
94 platformDetails = with stdenv.hostPlatform; if isDarwin then rec {
95 arch = "darwin-x86_64";
96 sourceDir = "'Katawa Shoujo'.app";
97 installDir = "$out/Applications/'Katawa Shoujo'.app";
98 dataDir = "${installDir}/Contents/Resources/autorun";
99 bin = "${installDir}/Contents/MacOS/'Katawa Shoujo'";
101 arch = "linux-${if isx86_64 then "x86_64" else "i686"}";
102 sourceDir = "'Katawa Shoujo'-${version}-linux";
103 installDir = "$out/share/katawa-shoujo";
104 dataDir = installDir;
105 bin = "${installDir}/'Katawa Shoujo'.sh";
107 libDir = with platformDetails; "${dataDir}/lib/${arch}";
108 in with platformDetails; ''
111 mkdir -p "$(dirname ${installDir})"
112 cp -R ${sourceDir} ${installDir}
114 # Simplify launcher script
117 exec \$RENPY_GDB ${libDir}/'Katawa Shoujo' \$RENPY_PYARGS -EO ${dataDir}/'Katawa Shoujo'.py "\$@"
120 '' + (if stdenv.hostPlatform.isDarwin then ''
121 # No autoPatchelfHook on Darwin
123 --prefix DYLD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
125 # Extract icon for xdg desktop file
126 unrpa ${dataDir}/game/data.rpa
127 install -Dm644 ui/icon.png $out/share/icons/hicolor/512x512/apps/katawa-shoujo.png
130 # Delete binaries for wrong arch, autoPatchelfHook gets confused by them & less to keep in the store
131 find "$(dirname ${libDir})" -mindepth 1 -maxdepth 1 \
132 -not -name 'python*' -not -name ${arch} \
135 # Replace some bundled libs so Nixpkgs' versions are used
137 rm ${libDir}/libfreetype*
138 rm ${libDir}/libSDL-1.2*
139 '' + lib.optionalString devendorImageLibs ''
140 rm ${libDir}/libjpeg*
141 rm ${libDir}/libpng12*
144 mkdir -p $out/share/{doc,licenses}/katawa-shoujo
145 mv ${dataDir}/'Game Manual'.pdf $out/share/doc/katawa-shoujo/
146 mv ${dataDir}/LICENSE.txt $out/share/licenses/katawa-shoujo/
149 ln -s ${bin} $out/bin/katawa-shoujo
155 description = "Bishoujo-style visual novel by Four Leaf Studios, built in Ren'Py";
157 Katawa Shoujo is a bishoujo-style visual novel set in the fictional Yamaku High School for disabled children,
158 located somewhere in modern Japan. Hisao Nakai, a normal boy living a normal life, has his life turned upside down
159 when a congenital heart defect forces him to move to a new school after a long hospitalization. Despite his difficulties,
160 Hisao is able to find friends—and perhaps love, if he plays his cards right. There are five main paths corresponding
161 to the 5 main female characters, each path following the storyline pertaining to that character.
163 The story is told through the perspective of the main character, using a first person narrative. The game uses a
164 traditional text and sprite-based visual novel model with an ADV text box.
166 Katawa Shoujo contains adult material, and was created using the Ren'Py scripting system. It is the product of an
167 international team of amateur developers, and is available free of charge under the Creative Commons BY-NC-ND License.
169 homepage = "https://www.katawa-shoujo.com/";
170 # https://www.katawa-shoujo.com/about.php
171 # November 2022: Update, is it still ND?
172 # https://ks.renai.us/viewtopic.php?f=13&p=248149#p248149
173 license = with licenses; [ cc-by-nc-nd-30 ];
174 maintainers = with maintainers; [ OPNA2608 ];
175 # Building Ren'Py6 from source would allow more, but too much of a hassle
176 platforms = platforms.x86;
177 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
178 # Needs different srcDetails & installPhase
179 broken = stdenv.hostPlatform.isWindows;