16 src = fetchFromGitHub {
20 hash = "sha256-fHaNluLes25P/mSTSYFt97pC6uKYuBI/3PUHc84zoWg=";
23 electron = electron_31;
26 inherit pname version;
29 npmDepsHash = "sha256-8xFB47PJpa+3U+Xy+DEdWoW3/f+naFKtLQsDDVgUccA=";
31 npmFlags = [ "--legacy-peer-deps" ];
32 makeCacheWritable = true;
34 env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
37 lib.optionals (stdenv.hostPlatform.isLinux) [ copyDesktopItems ]
38 ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.autoSignDarwinBinariesHook ];
42 # release/app dependencies are installed on preConfigure
43 substituteInPlace package.json \
44 --replace-fail "electron-builder install-app-deps &&" ""
46 # Don't check for updates.
47 substituteInPlace src/main/main.ts \
48 --replace-fail "autoUpdater.checkForUpdatesAndNotify();" ""
50 + lib.optionalString stdenv.hostPlatform.isLinux ''
51 # https://github.com/electron/electron/issues/31121
52 substituteInPlace src/main/main.ts \
53 --replace-fail "process.resourcesPath" "'$out/share/feishin/resources'"
58 releaseAppDeps = buildNpmPackage {
59 pname = "${pname}-release-app";
62 src = "${src}/release/app";
63 npmDepsHash = "sha256-gufOUBfHTDkIqRTdPqXuuk1ZT0y80y/GyI7ssvHnBYo=";
65 npmFlags = [ "--ignore-scripts" ];
68 env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
70 releaseNodeModules = "${releaseAppDeps}/lib/node_modules/feishin/node_modules";
73 for release_module_path in "${releaseNodeModules}"/*; do
74 rm -rf node_modules/"$(basename "$release_module_path")"
75 ln -s "$release_module_path" node_modules/
80 lib.optionalString stdenv.hostPlatform.isDarwin ''
81 # electron-builder appears to build directly on top of Electron.app, by overwriting the files in the bundle.
82 cp -r ${electron.dist}/Electron.app ./
83 find ./Electron.app -name 'Info.plist' | xargs -d '\n' chmod +rw
85 # Disable code signing during build on macOS.
86 # https://github.com/electron-userland/electron-builder/blob/fa6fc16/docs/code-signing.md#how-to-disable-code-signing-during-the-build-process-on-macos
87 export CSC_IDENTITY_AUTO_DISCOVERY=false
88 sed -i "/afterSign/d" package.json
91 npm exec electron-builder -- \
93 -c.electronDist=${if stdenv.hostPlatform.isDarwin then "./" else electron.dist} \
94 -c.electronVersion=${electron.version} \
102 + lib.optionalString stdenv.hostPlatform.isDarwin ''
103 mkdir -p $out/{Applications,bin}
104 cp -r release/build/**/Feishin.app $out/Applications/
105 makeWrapper $out/Applications/Feishin.app/Contents/MacOS/Feishin $out/bin/feishin
107 + lib.optionalString stdenv.hostPlatform.isLinux ''
108 mkdir -p $out/share/feishin
109 pushd release/build/*/
110 cp -r locales resources{,.pak} $out/share/feishin
113 # Code relies on checking app.isPackaged, which returns false if the executable is electron.
114 # Set ELECTRON_FORCE_IS_PACKAGED=1.
115 # https://github.com/electron/electron/issues/35153#issuecomment-1202718531
116 makeWrapper ${lib.getExe electron} $out/bin/feishin \
117 --add-flags $out/share/feishin/resources/app.asar \
118 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
119 --set ELECTRON_FORCE_IS_PACKAGED=1 \
122 for size in 32 64 128 256 512 1024; do
123 mkdir -p $out/share/icons/hicolor/"$size"x"$size"/apps
125 $out/share/feishin/resources/assets/icons/"$size"x"$size".png \
126 $out/share/icons/hicolor/"$size"x"$size"/apps/feishin.png
136 desktopName = "Feishin";
137 comment = "Full-featured Subsonic/Jellyfin compatible desktop music player";
144 mimeTypes = [ "x-scheme-handler/feishin" ];
149 description = "Full-featured Subsonic/Jellyfin compatible desktop music player";
150 homepage = "https://github.com/jeffvli/feishin";
151 changelog = "https://github.com/jeffvli/feishin/releases/tag/v${version}";
152 sourceProvenance = with sourceTypes; [ fromSource ];
153 license = licenses.gpl3Plus;
154 platforms = platforms.unix;
155 mainProgram = "feishin";
156 maintainers = with maintainers; [