forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addresses NixOS#296939 (build from source). Continues the work started by @dotlambda in NixOS#288210. Co-authored-by: Robert Schütz <nix@dotlambda.de>
- Loading branch information
1 parent
feeff83
commit 1001a88
Showing
3 changed files
with
120 additions
and
129 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,130 @@ | ||
{ lib | ||
, stdenv | ||
, callPackage | ||
, ... | ||
}@args: | ||
|
||
{ | ||
lib, | ||
buildNpmPackage, | ||
fetchFromGitHub, | ||
electron_25, | ||
copyDesktopItems, | ||
makeDesktopItem, | ||
... | ||
}: | ||
let | ||
extraArgs = removeAttrs args [ "callPackage" ]; | ||
|
||
pname = "feishin"; | ||
version = "0.5.1"; | ||
appname = "Feishin"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "jeffvli"; | ||
repo = pname; | ||
rev = "v${version}"; | ||
hash = "sha256-7L1KufMiwqWgTvv7E1bDNL+epvNb5iLXI4Gee8w17qs="; | ||
}; | ||
|
||
electron = electron_25; | ||
in | ||
buildNpmPackage { | ||
pname = "feishin"; | ||
inherit version; | ||
|
||
inherit src; | ||
npmDepsHash = "sha256-TuNkVhNNOB23QnMXiGBWhDI0JXWnWdfI9MLvMq5xzJ8="; | ||
|
||
npmFlags = [ "--legacy-peer-deps" ]; | ||
makeCacheWritable = true; | ||
|
||
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; | ||
|
||
nativeBuildInputs = [ copyDesktopItems ]; | ||
|
||
postPatch = '' | ||
# release/app dependencies are installed on preConfigure | ||
substituteInPlace package.json \ | ||
--replace-fail "electron-builder install-app-deps &&" "" | ||
# https://github.com/electron/electron/issues/31121 | ||
substituteInPlace src/main/main.ts \ | ||
--replace-fail "process.resourcesPath" "'$out/share/feishin/resources'" | ||
''; | ||
|
||
preConfigure = | ||
let | ||
releaseAppDeps = buildNpmPackage { | ||
pname = "${pname}-release-app"; | ||
inherit version; | ||
|
||
src = "${src}/release/app"; | ||
npmDepsHash = "sha256-2tkds65buiT/p0fsuLk+vemvFYsmExanyJPiJOqlwP4="; | ||
|
||
npmFlags = [ "--ignore-scripts" ]; | ||
dontNpmBuild = true; | ||
|
||
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; | ||
}; | ||
releaseNodeModules = "${releaseAppDeps}/lib/node_modules/feishin/node_modules"; | ||
in | ||
'' | ||
for release_module_path in "${releaseNodeModules}"/*; do | ||
rm -rf node_modules/"$(basename "$release_module_path")" | ||
ln -s "$release_module_path" node_modules/ | ||
done | ||
''; | ||
|
||
postBuild = '' | ||
npm exec electron-builder -- \ | ||
--dir \ | ||
-c.electronDist=${electron}/libexec/electron \ | ||
-c.electronVersion=${electron.version} \ | ||
-c.npmRebuild=false | ||
''; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
mkdir -p $out/share/feishin | ||
pushd release/build/*/ | ||
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}}" \ | ||
--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/${pname}.png | ||
done | ||
runHook postInstall | ||
''; | ||
|
||
desktopItems = [ | ||
(makeDesktopItem { | ||
name = "feishin"; | ||
desktopName = "Feishin"; | ||
comment = "Full-featured Subsonic/Jellyfin compatible desktop music player"; | ||
icon = pname; | ||
exec = "feishin %u"; | ||
categories = [ | ||
"Audio" | ||
"AudioVideo" | ||
]; | ||
mimeTypes = [ "x-scheme-handler/feishin" ]; | ||
}) | ||
]; | ||
|
||
meta = with lib; { | ||
description = "Full-featured Subsonic/Jellyfin compatible desktop music player"; | ||
homepage = "https://github.com/jeffvli/feishin"; | ||
changelog = "https://github.com/jeffvli/feishin/releases/tag/v${version}"; | ||
sourceProvenance = with sourceTypes; [ binaryNativeCode ]; | ||
license = licenses.mit; | ||
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; | ||
sourceProvenance = with sourceTypes; [ fromSource ]; | ||
license = licenses.gpl3Plus; | ||
platforms = platforms.unix; | ||
mainProgram = "feishin"; | ||
maintainers = with maintainers; [ onny ]; | ||
}; | ||
|
||
in | ||
if stdenv.isDarwin | ||
then callPackage ./darwin.nix (extraArgs // { inherit pname appname version meta; }) | ||
else callPackage ./linux.nix (extraArgs // { inherit pname appname version meta; }) | ||
} |
This file was deleted.
Oops, something went wrong.