diff --git a/flake.lock b/flake.lock index 731f0e3..88fd8e5 100644 --- a/flake.lock +++ b/flake.lock @@ -19,11 +19,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1707451808, - "narHash": "sha256-UwDBUNHNRsYKFJzyTMVMTF5qS4xeJlWoeyJf+6vvamU=", + "lastModified": 1707347730, + "narHash": "sha256-0etC/exQIaqC9vliKhc3eZE2Mm2wgLa0tj93ZF/egvM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "442d407992384ed9c0e6d352de75b69079904e4e", + "rev": "6832d0d99649db3d65a0e15fa51471537b2c56a6", "type": "github" }, "original": { diff --git a/nix/default.nix b/nix/default.nix index 953e4cc..4e3c29b 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -29,6 +29,8 @@ stdenvNoCC.mkDerivation ]; repack = ./../repack.sh; + patches = ./../patches; + utility = ./../utility; desktopItem = ../templates/desktop; src = if ymExe != null @@ -40,8 +42,12 @@ stdenvNoCC.mkDerivation }; unpackPhase = '' - bash "$repack" ${if !fixQuit then "-q" else ""} -o "./app" "$src" + cp -r $repack ./repack.sh + cp -r $patches ./patches + cp -r $utility ./utility + bash "./repack.sh" ${if !fixQuit then "-q" else ""} -o "./app" "$src" ''; + dontPatch = true; installPhase = '' mkdir -p "$out/share/nodejs" diff --git a/patches/0001-Add-package-licence.patch b/patches/0001-Add-package-licence.patch new file mode 100644 index 0000000..e57352e --- /dev/null +++ b/patches/0001-Add-package-licence.patch @@ -0,0 +1,15 @@ +diff --git a/package.json b/package.json +index 5844bdb..c1bab0e 100644 +--- a/package.json ++++ b/package.json +@@ -39,5 +39,6 @@ + "COPYRIGHT": "Яндекс Музыка", + "TRADEMARK": "Яндекс Музыка", + "DEEPLINK_PROTOCOL": "yandexmusic" +- } ++ }, ++ "license": "UNLICENSED" + } +-- +2.42.0 + diff --git a/patches/0002-Add-package-icon.patch b/patches/0002-Add-package-icon.patch new file mode 100644 index 0000000..1d30795 --- /dev/null +++ b/patches/0002-Add-package-icon.patch @@ -0,0 +1,18 @@ +diff --git a/package.json b/package.json +index c1bab0e..d66268b 100644 +--- a/package.json ++++ b/package.json +@@ -40,5 +40,9 @@ + "TRADEMARK": "Яндекс Музыка", + "DEEPLINK_PROTOCOL": "yandexmusic" + }, +- "license": "UNLICENSED" ++ "license": "UNLICENSED", ++ "icon": { ++ "48x48": "build/next-desktop/favicon.png", ++ "scalable": "build/next-desktop/favicon.svg" ++ } + } +-- +2.42.0 + diff --git a/patches/0003-Optional-fix-quit.patch b/patches/0003-Optional-fix-quit.patch new file mode 100644 index 0000000..6163797 --- /dev/null +++ b/patches/0003-Optional-fix-quit.patch @@ -0,0 +1,15 @@ +diff --git a/main/lib/handlers/handleWindowLifecycleEvents.js b/main/lib/handlers/handleWindowLifecycleEvents.js +index 269d1f6..ff744b4 100644 +--- a/main/lib/handlers/handleWindowLifecycleEvents.js ++++ b/main/lib/handlers/handleWindowLifecycleEvents.js +@@ -36,6 +36,7 @@ const handleWindowLifecycleEvents = (window) => { + checkAndUpdateApplicationData(window); + }); + window.on('close', (event) => { ++ electron_1.app.quit(); + if (!state_js_1.state.willQuit) { + event.preventDefault(); + if (window.isFullScreen()) { +-- +2.42.0 + diff --git a/patches/0004-Fix-window-resize.patch b/patches/0004-Fix-window-resize.patch new file mode 100644 index 0000000..494becc --- /dev/null +++ b/patches/0004-Fix-window-resize.patch @@ -0,0 +1,13 @@ +diff --git a/main/lib/createWindow.js b/main/lib/createWindow.js +index 771e24c..e3794a7 100644 +--- a/main/lib/createWindow.js ++++ b/main/lib/createWindow.js +@@ -16,8 +16,6 @@ const createWindow = async () => { + x: 16, + y: 10 + }, +- minWidth: 1024, +- minHeight: 800, + width: 1280, + height: 800, + webPreferences: { diff --git a/repack.sh b/repack.sh index b73fc7d..91252cc 100755 --- a/repack.sh +++ b/repack.sh @@ -15,12 +15,12 @@ usage() { exe_location= dst="$PWD/app" SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -fix_quit=1 +patch_fix_quit=1 while getopts :xo:qh name; do case $name in x) extract_only=1 ;; o) dst="$OPTARG" ;; - q) fix_quit=0 ;; + q) patch_fix_quit=0 ;; h) usage exit 0 @@ -66,6 +66,7 @@ rm "$TEMPDIR/app.asar" curdir="$PWD" cd "$TEMPDIR/app" + # fixing secretKey issue echo "Fixing SecretKey" find "./" -type f \( -name "*.js" -o -name "*.js.map" \) -print0 | while IFS= read -r -d $'\0' file; do @@ -74,40 +75,47 @@ find "./" -type f \( -name "*.js" -o -name "*.js.map" \) -print0 | while IFS= re done echo "SecretKey replaced" - +# fixing titile echo "Fixing Title" -#fixing title find "./" -type f -name "*.html" -print0 | while IFS= read -r -d $'\0' file; do # Use 'sed' to perform the replacement in-place sed -i "s/Яндекс Музыка — собираем музыку для вас/Яндекс Музыка/g" "$file" done echo "Title Fixed" -if [ "$fix_quit" == "1" ]; then - echo "Fixing App Quiting" - sed -i "s/window.on('close', (event) => {/window.on('close', (event) => {electron_1.app.quit();/g" \ - "./main/lib/handlers/handleWindowLifecycleEvents.js" -fi +# applying patches +apply_patch() +{ + local patchfile patchname -if ! command -v jq &>/dev/null; then - echo "Error: jq is not installed. Please install jq to proceed." >&2 - exit 1 -fi + patchfile="$(realpath "$1")" + patchname="$(basename "$patchfile")" + patchname="${patchname,,}" -jq --arg license "UNLICENSED" '. + {license: $license}' package.json > tmp_package.json -mv tmp_package.json package.json -echo "Updated license field in package.json" + if [[ $patchname =~ [[:digit:]]+\-optional\-(.+).patch ]]; then + patchname="${BASH_REMATCH[1]}" + patchname="${patchname//[- ]/_}" + if eval [ \"\$"patch_$patchname"\" != 1 ]; then + echo "Shipping patch '$patchfile'" + return 0 + fi + fi + echo "Applying patch '$patchfile'" + (cd "$TEMPDIR/app" && patch -p1 < "$patchfile") +} -jq '. + {icon: {"48x48": "build/next-desktop/favicon.png", "scalable": "build/next-desktop/favicon.svg"}}' package.json > tmp_package.json -mv tmp_package.json package.json -echo "Updated icon field in package.json" +for f in $(eval echo "$SCRIPT_DIR"/patches/*); do + apply_patch "$f" +done if [ -n "$extract_only" ]; then - mkdir -p "$(dirname "$dst")" - mv "$TEMPDIR/app" "$dst" + mkdir -p "$dst" + eval cp -r "$TEMPDIR/app/*" "$dst" exit 0 fi + + mkdir -p "$dst" echo "Packing"