Update flake

This commit is contained in:
Sicheng Pan 2025-10-24 10:24:57 -07:00
parent 97e696e37d
commit 5bd27a07da
Signed by: macronova
GPG key ID: CE969670FB4B4A56
2 changed files with 11 additions and 123 deletions

View file

@ -1,112 +0,0 @@
{
name,
pkgs,
...
}: let
version = "0.21.2";
src = pkgs.fetchFromGitHub {
owner = "jeffvli";
repo = "feishin";
tag = "v${version}";
hash = "sha256-F5m0hsN1BLfiUcl2Go54bpFnN8ktn6Rqa/df1xxoCA4=";
};
in
with pkgs;
buildNpmPackage {
inherit src version;
pname = name;
npmConfigHook = pnpm.configHook;
npmDeps = null;
pnpmDeps = pnpm.fetchDeps {
inherit src version;
pname = name;
fetcherVersion = 2;
hash = "sha256-5jEXdQMZ6a0JuhjPS1eZOIGsIGQHd6nKPI02eeR35pg=";
};
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
nativeBuildInputs = [copyDesktopItems];
postPatch = ''
# release/app dependencies are installed on preConfigure
substituteInPlace package.json \
--replace-fail '"postinstall": "electron-builder install-app-deps",' ""
# Don't check for updates.
substituteInPlace src/main/index.ts \
--replace-fail "autoUpdater.checkForUpdatesAndNotify();" ""
# https://github.com/electron/electron/issues/31121
substituteInPlace src/main/index.ts \
--replace-fail "process.resourcesPath" "'$out/share/feishin/resources'"
'';
preBuild = ''
rm -r node_modules/.pnpm/sass-embedded-*
test -d node_modules/.pnpm/sass-embedded@*
dir="$(echo node_modules/.pnpm/sass-embedded@*)/node_modules/sass-embedded/dist/lib/src/vendor/dart-sass"
mkdir -p "$dir"
ln -s ${dart-sass}/bin/dart-sass "$dir"/sass
'';
postBuild = ''
npm exec electron-builder -- \
--dir \
-c.electronDist=${
if stdenv.hostPlatform.isDarwin
then "./"
else electron.dist
} \
-c.electronVersion=${electron.version} \
-c.npmRebuild=false
'';
installPhase =
''
runHook preInstall
mkdir -p $out/share/feishin
pushd dist/*-unpacked/
cp -r locales resources{,.pak} $out/share/feishin
popd
# Code relies on checking app.isPackaged, which returns false if the executable is electron.
# Set ELECTRON_FORCE_IS_PACKAGED=1.
# https://github.com/electron/electron/issues/35153#issuecomment-1202718531
makeWrapper ${lib.getExe electron} $out/bin/feishin \
--add-flags $out/share/feishin/resources/app.asar \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
--set ELECTRON_FORCE_IS_PACKAGED=1 \
--inherit-argv0
for size in 32 64 128 256 512 1024; do
mkdir -p $out/share/icons/hicolor/"$size"x"$size"/apps
ln -s \
$out/share/feishin/resources/assets/icons/"$size"x"$size".png \
$out/share/icons/hicolor/"$size"x"$size"/apps/feishin.png
done
''
+ ''
runHook postInstall
'';
desktopItems = [
(makeDesktopItem {
name = "feishin";
desktopName = "Feishin";
comment = "Full-featured Subsonic/Jellyfin compatible desktop music player";
icon = "feishin";
exec = "feishin %u";
categories = [
"Audio"
"AudioVideo"
];
mimeTypes = ["x-scheme-handler/feishin"];
})
];
}