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 archiveDate = "20240825224413";
35 urlSuffix = "%5blinux-x86%5d%5b18161880%5d.tar.bz2";
36 hash = "sha256-7FoFz88dWYHs2/pxkEwnmiFeeb3+slayrWknEJoAB9o=";
38 i686-linux = x86_64-linux;
40 archiveDate = "20240825224411";
41 urlSuffix = "%5bmac%5d%5b1DFC84A6%5d.dmg";
42 hash = "sha256-Sc5BAlpJsffjcNrZ8+VU3n7G10DoqDKQn/leHDW32Y8=";
44 }.${stdenv.hostPlatform.system} or (throw "Don't know how to fetch source for ${stdenv.hostPlatform.system}!");
46 stdenv.mkDerivation rec {
47 pname = "katawa-shoujo";
51 url = "https://web.archive.org/web/${srcDetails.archiveDate}/https://cdn.fhs.sh/ks/bin/gold_${version}/%5b4ls%5d_katawa_shoujo_${version}-${srcDetails.urlSuffix}";
52 inherit (srcDetails) hash;
55 # fetchzip requires a custom unpackPhase to handle dmg, fetchurl cannot handle undmg producing >1 directory without this
58 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [
62 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
71 ] ++ lib.optionals devendorImageLibs [
74 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
83 desktopItems = [(makeDesktopItem rec {
84 name = "katawa-shoujo";
85 desktopName = "Katawa Shoujo";
86 comment = meta.description;
89 categories = [ "Game" ];
96 platformDetails = with stdenv.hostPlatform; if isDarwin then rec {
97 arch = "darwin-x86_64";
98 sourceDir = "'Katawa Shoujo'.app";
99 installDir = "$out/Applications/'Katawa Shoujo'.app";
100 dataDir = "${installDir}/Contents/Resources/autorun";
101 bin = "${installDir}/Contents/MacOS/'Katawa Shoujo'";
103 arch = "linux-${if isx86_64 then "x86_64" else "i686"}";
104 sourceDir = "'Katawa Shoujo'-${version}-linux";
105 installDir = "$out/share/katawa-shoujo";
106 dataDir = installDir;
107 bin = "${installDir}/'Katawa Shoujo'.sh";
109 libDir = with platformDetails; "${dataDir}/lib/${arch}";
110 in with platformDetails; ''
113 mkdir -p "$(dirname ${installDir})"
114 cp -R ${sourceDir} ${installDir}
116 # Simplify launcher script
119 exec \$RENPY_GDB ${libDir}/'Katawa Shoujo' \$RENPY_PYARGS -EO ${dataDir}/'Katawa Shoujo'.py "\$@"
122 '' + (if stdenv.hostPlatform.isDarwin then ''
123 # No autoPatchelfHook on Darwin
125 --prefix DYLD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
127 # Extract icon for xdg desktop file
128 unrpa ${dataDir}/game/data.rpa
129 install -Dm644 ui/icon.png $out/share/icons/hicolor/512x512/apps/katawa-shoujo.png
132 # Delete binaries for wrong arch, autoPatchelfHook gets confused by them & less to keep in the store
133 find "$(dirname ${libDir})" -mindepth 1 -maxdepth 1 \
134 -not -name 'python*' -not -name ${arch} \
137 # Replace some bundled libs so Nixpkgs' versions are used
139 rm ${libDir}/libfreetype*
140 rm ${libDir}/libSDL-1.2*
141 '' + lib.optionalString devendorImageLibs ''
142 rm ${libDir}/libjpeg*
143 rm ${libDir}/libpng12*
146 mkdir -p $out/share/{doc,licenses}/katawa-shoujo
147 mv ${dataDir}/'Game Manual'.pdf $out/share/doc/katawa-shoujo/
148 mv ${dataDir}/LICENSE.txt $out/share/licenses/katawa-shoujo/
151 ln -s ${bin} $out/bin/katawa-shoujo
157 description = "Bishoujo-style visual novel by Four Leaf Studios, built in Ren'Py";
159 Katawa Shoujo is a bishoujo-style visual novel set in the fictional Yamaku High School for disabled children,
160 located somewhere in modern Japan. Hisao Nakai, a normal boy living a normal life, has his life turned upside down
161 when a congenital heart defect forces him to move to a new school after a long hospitalization. Despite his difficulties,
162 Hisao is able to find friends—and perhaps love, if he plays his cards right. There are five main paths corresponding
163 to the 5 main female characters, each path following the storyline pertaining to that character.
165 The story is told through the perspective of the main character, using a first person narrative. The game uses a
166 traditional text and sprite-based visual novel model with an ADV text box.
168 Katawa Shoujo contains adult material, and was created using the Ren'Py scripting system. It is the product of an
169 international team of amateur developers, and is available free of charge under the Creative Commons BY-NC-ND License.
171 homepage = "https://www.katawa-shoujo.com/";
172 # https://www.katawa-shoujo.com/about.php
173 # November 2022: Update, is it still ND?
174 # https://ks.renai.us/viewtopic.php?f=13&p=248149#p248149
175 license = with licenses; [ cc-by-nc-nd-30 ];
176 maintainers = with maintainers; [ OPNA2608 ];
177 # Building Ren'Py6 from source would allow more, but too much of a hassle
178 platforms = platforms.x86;
179 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
180 # Needs different srcDetails & installPhase
181 broken = stdenv.hostPlatform.isWindows;