Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 33 additions & 34 deletions pkgs/by-name/fe/feishin/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,45 @@
stdenv,
buildNpmPackage,
fetchFromGitHub,
electron_36,
electron_38,
dart-sass,
pnpm_10,
darwin,
copyDesktopItems,
makeDesktopItem,
...
}:
let
pname = "feishin";
version = "0.12.6";
version = "0.21.2";

src = fetchFromGitHub {
owner = "jeffvli";
repo = "feishin";
rev = "v${version}";
hash = "sha256-cnlPks/sJdcxHdIppHn8Q8d2tkwVlPMofQxjdAlBreg=";
tag = "v${version}";
hash = "sha256-F5m0hsN1BLfiUcl2Go54bpFnN8ktn6Rqa/df1xxoCA4=";
};

electron = electron_36;
electron = electron_38;
pnpm = pnpm_10;
in
buildNpmPackage {
inherit pname version;

inherit src;
npmDepsHash = "sha256-lThh29prT/cHRrp2mEtUW4eeVfCtkk+54EPNUyGHyq8=";

npmFlags = [ "--legacy-peer-deps" ];
makeCacheWritable = true;
npmConfigHook = pnpm.configHook;

npmDeps = null;
pnpmDeps = pnpm.fetchDeps {
inherit
pname
version
src
;
fetcherVersion = 2;
hash = "sha256-5jEXdQMZ6a0JuhjPS1eZOIGsIGQHd6nKPI02eeR35pg=";
};

env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";

Expand All @@ -40,40 +52,26 @@ buildNpmPackage {
postPatch = ''
# release/app dependencies are installed on preConfigure
substituteInPlace package.json \
--replace-fail "electron-builder install-app-deps &&" ""
--replace-fail '"postinstall": "electron-builder install-app-deps",' ""

# Don't check for updates.
substituteInPlace src/main/main.ts \
substituteInPlace src/main/index.ts \
--replace-fail "autoUpdater.checkForUpdatesAndNotify();" ""
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
# https://github.com/electron/electron/issues/31121
substituteInPlace src/main/main.ts \
substituteInPlace src/main/index.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-kEe5HH/oslH8vtAcJuWTOLc0ZQPxlDVMS4U0RpD8enE=";
preBuild = ''
rm -r node_modules/.pnpm/sass-embedded-*

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
'';
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 =
lib.optionalString stdenv.hostPlatform.isDarwin ''
Expand All @@ -99,12 +97,13 @@ buildNpmPackage {
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p $out/{Applications,bin}
cp -r release/build/**/Feishin.app $out/Applications/
cp -r dist/**/Feishin.app $out/Applications/
makeWrapper $out/Applications/Feishin.app/Contents/MacOS/Feishin $out/bin/feishin
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
mkdir -p $out/share/feishin
pushd release/build/*/

pushd dist/*-unpacked/
cp -r locales resources{,.pak} $out/share/feishin
popd

Expand Down
Loading