From a981d90c680a6b1d8abf4b2038c45d73538465c2 Mon Sep 17 00:00:00 2001 From: Xaiya Schumin Date: Sun, 11 May 2025 21:44:54 +0200 Subject: [PATCH 1/8] =?UTF-8?q?=E2=9C=A8=F0=9F=9A=A7=20-=20Added=20nix=20p?= =?UTF-8?q?ackages=20with=20some=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xaiya Schumin --- .gitignore | 5 +++- flake.lock | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 21 +++++++++++++++ package.nix | 38 +++++++++++++++++++++++++++ 4 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 package.nix diff --git a/.gitignore b/.gitignore index 04c01ba..eb50cd0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ node_modules/ -dist/ \ No newline at end of file +dist/ + +# Jetbrains IDE +.idea/ \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..35433bb --- /dev/null +++ b/flake.lock @@ -0,0 +1,76 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1746978854, + "narHash": "sha256-FRqTP344StS/H3IDO33S221GC1gmsdKYfn4/VrAfSrc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "53b8217da3ef7b76d52b56aefed5de7f713c1072", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1743296961, + "narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b21e83d --- /dev/null +++ b/flake.nix @@ -0,0 +1,21 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/release-24.11"; + systems.url = "github:nix-systems/default"; + }; + + outputs = inputs@{ self, systems, flake-parts, nixpkgs, ... }: flake-parts.lib.mkFlake { inherit inputs; } { + systems = import systems; + + imports = [ ./package.nix ]; + + perSystem = { config, pkgs, system, ... }: { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ self.overlays.default ]; + }; + + packages.default = pkgs.tidaLuna; + }; + }; +} \ No newline at end of file diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..4216a3b --- /dev/null +++ b/package.nix @@ -0,0 +1,38 @@ +{ withSystem, ... }: { + flake.overlays.default = final: prev: + withSystem prev.stdenv.hostPlatform.system ( + { config, ... }: + let + injection = prev.fetchzip { + url = "https://github.com/Inrixia/TidaLuna/releases/download/1.1.0-alpha/luna.zip"; + sha256 = "bOjA+slsjYmG+kmjTgN8yYKJCciwsnGHZ7kjozC4ZiA="; + stripRoot = false; + }; + in + { + tidaLuna = prev.tidal-hifi.overrideAttrs (old: { + installPhase = '' + runHook preInstall + + # Default installation from tidal-hifi + mkdir -p "$out/bin" + cp -R "opt" "$out" + cp -R "usr/share" "$out/share" + + # Rename app.asar to original.asar + mv $out/opt/tidal-hifi/resources/app.asar $out/opt/tidal-hifi/resources/original.asar + + # Move injection into app folder + mkdir -p "$out/opt/tidal-hifi/resources/app/" + cp -R ${injection}/* $out/opt/tidal-hifi/resources/app/ + + chmod -R g-w "$out" + + runHook postInstall + ''; + + tidaLuna = final.tidal-hifi; + }); + } + ); +} \ No newline at end of file From 902ae5dbe980a051471d269a3b030574ee31ac3b Mon Sep 17 00:00:00 2001 From: Xaiya Schumin Date: Tue, 20 May 2025 13:32:39 +0200 Subject: [PATCH 2/8] =?UTF-8?q?=E2=9C=A8=20-=20Software=20is=20now=20build?= =?UTF-8?q?ed=20in=20git=20-=20Version=20will=20now=20be=20updated=20in=20?= =?UTF-8?q?workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xaiya Schumin --- .github/workflows/releaseDev.yml | 8 ++++++ .github/workflows/releaseMaster.yml | 9 +++++++ flake.nix | 6 +++-- package.nix => nix/default.nix | 10 +++---- nix/package.nix | 41 +++++++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 9 deletions(-) rename package.nix => nix/default.nix (76%) create mode 100644 nix/package.nix diff --git a/.github/workflows/releaseDev.yml b/.github/workflows/releaseDev.yml index 0af21bb..72a2a1a 100644 --- a/.github/workflows/releaseDev.yml +++ b/.github/workflows/releaseDev.yml @@ -37,3 +37,11 @@ jobs: prerelease: true title: Release ${{ env.VERSION }} files: ./dist/luna.zip + + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v18 + - uses: workflow/nix-shell-action@v3 + with: + packages: nix-update + script: | + nix-update --flake --version=unstable --subpackage pnpmDeps injection diff --git a/.github/workflows/releaseMaster.yml b/.github/workflows/releaseMaster.yml index d715a27..39a43ee 100644 --- a/.github/workflows/releaseMaster.yml +++ b/.github/workflows/releaseMaster.yml @@ -37,3 +37,12 @@ jobs: prerelease: false title: Release ${{ env.VERSION }} files: ./dist/luna.zip + + + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v18 + - uses: workflow/nix-shell-action@v3 + with: + packages: nix-update + script: | + nix-update --flake --version=unstable --subpackage pnpmDeps injection diff --git a/flake.nix b/flake.nix index b21e83d..f0e0032 100644 --- a/flake.nix +++ b/flake.nix @@ -1,13 +1,13 @@ { inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/release-24.11"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; systems.url = "github:nix-systems/default"; }; outputs = inputs@{ self, systems, flake-parts, nixpkgs, ... }: flake-parts.lib.mkFlake { inherit inputs; } { systems = import systems; - imports = [ ./package.nix ]; + imports = [ ./nix ]; perSystem = { config, pkgs, system, ... }: { _module.args.pkgs = import inputs.nixpkgs { @@ -15,6 +15,8 @@ overlays = [ self.overlays.default ]; }; + packages.injection = + pkgs.callPackage ./nix/package.nix { inherit (pkgs) nodejs fetchFromGitHub; pnpm = pkgs.pnpm_9; }; packages.default = pkgs.tidaLuna; }; }; diff --git a/package.nix b/nix/default.nix similarity index 76% rename from package.nix rename to nix/default.nix index 4216a3b..025e17b 100644 --- a/package.nix +++ b/nix/default.nix @@ -3,11 +3,7 @@ withSystem prev.stdenv.hostPlatform.system ( { config, ... }: let - injection = prev.fetchzip { - url = "https://github.com/Inrixia/TidaLuna/releases/download/1.1.0-alpha/luna.zip"; - sha256 = "bOjA+slsjYmG+kmjTgN8yYKJCciwsnGHZ7kjozC4ZiA="; - stripRoot = false; - }; + injection = prev.callPackage ./package.nix { nodejs = prev.nodejs; pnpm = prev.pnpm_9; }; in { tidaLuna = prev.tidal-hifi.overrideAttrs (old: { @@ -26,7 +22,6 @@ mkdir -p "$out/opt/tidal-hifi/resources/app/" cp -R ${injection}/* $out/opt/tidal-hifi/resources/app/ - chmod -R g-w "$out" runHook postInstall ''; @@ -35,4 +30,5 @@ }); } ); -} \ No newline at end of file +} + diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 0000000..51d3535 --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,41 @@ +{ stdenv, nodejs, pnpm, fetchFromGitHub, ... }: +stdenv.mkDerivation (finalAttrs: rec { + name = "TidaLuna"; + pname = "${name}"; + version = "1.1.0-alpha"; + src = fetchFromGitHub { + owner = "Inrixia"; + repo = "${name}"; + rev = "${version}"; + hash = "sha256-T6J6mI3oxQ7tD8b76M15ajka1S8G9QW8Am3rqj0MaTo="; + }; + + nativeBuildInputs = [ + nodejs + pnpm.configHook + ]; + + pnpmDeps = pnpm.fetchDeps { + inherit (finalAttrs) pname src version; + hash = "sha256-pnuDLjUAOxQUFlf+2FXeX2mpZcahzzVPMRpWZpbyDE4="; + }; + + buildPhase = '' + runHook preBuild + + pnpm install + pnpm run build + + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + cp -R "dist" "$out" + + runHook postInstall + ''; + +}) From a4f0f06c2b3540a5bdf4835521632fd8d1e1bb09 Mon Sep 17 00:00:00 2001 From: Xaiya Schumin Date: Mon, 26 May 2025 18:35:41 +0200 Subject: [PATCH 3/8] =?UTF-8?q?=F0=9F=90=9B=F0=9F=9A=80=20Fixed=20install?= =?UTF-8?q?=20hook,=20now=20using=20postInstall=20which=20will=20not=20bre?= =?UTF-8?q?ak=20things?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xaiya Schumin --- flake.lock | 8 ++++---- flake.nix | 2 +- nix/default.nix | 18 ++++-------------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/flake.lock b/flake.lock index 35433bb..078da89 100644 --- a/flake.lock +++ b/flake.lock @@ -19,16 +19,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1746978854, - "narHash": "sha256-FRqTP344StS/H3IDO33S221GC1gmsdKYfn4/VrAfSrc=", + "lastModified": 1748186667, + "narHash": "sha256-UQubDNIQ/Z42R8tPCIpY+BOhlxO8t8ZojwC9o2FW3c8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "53b8217da3ef7b76d52b56aefed5de7f713c1072", + "rev": "bdac72d387dca7f836f6ef1fe547755fb0e9df61", "type": "github" }, "original": { "owner": "NixOS", - "ref": "release-24.11", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index f0e0032..66c930d 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; systems.url = "github:nix-systems/default"; }; diff --git a/nix/default.nix b/nix/default.nix index 025e17b..543d0e6 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -7,23 +7,13 @@ in { tidaLuna = prev.tidal-hifi.overrideAttrs (old: { - installPhase = '' - runHook preInstall - - # Default installation from tidal-hifi - mkdir -p "$out/bin" - cp -R "opt" "$out" - cp -R "usr/share" "$out/share" - + postInstall = '' # Rename app.asar to original.asar - mv $out/opt/tidal-hifi/resources/app.asar $out/opt/tidal-hifi/resources/original.asar + mv $out/share/tidal-hifi/resources/app.asar $out/share/tidal-hifi/resources/original.asar # Move injection into app folder - mkdir -p "$out/opt/tidal-hifi/resources/app/" - cp -R ${injection}/* $out/opt/tidal-hifi/resources/app/ - - - runHook postInstall + mkdir -p "$out/share/tidal-hifi/resources/app/" + cp -R ${injection}/* $out/share/tidal-hifi/resources/app/ ''; tidaLuna = final.tidal-hifi; From 74ebdd90ea80a231e24bdf0d77e2c7a446e986da Mon Sep 17 00:00:00 2001 From: Xaiya Schumin Date: Mon, 26 May 2025 20:03:40 +0200 Subject: [PATCH 4/8] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB?= =?UTF-8?q?=F0=9F=94=A8=20-=20Changed=20injection=20version=20for=20develo?= =?UTF-8?q?ping=20-=20Added=20devenv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xaiya Schumin --- .envrc | 7 ++ .gitignore | 17 ++- .vscode/settings.json | 10 -- devenv.lock | 103 ++++++++++++++++++ devenv.nix | 13 +++ devenv.yaml | 5 + flake.lock | 245 ++++++++++++++++++++++++++++++++++++++++-- flake.nix | 7 +- native/injector.ts | 4 + nix/package.nix | 9 +- result | 1 + 11 files changed, 395 insertions(+), 26 deletions(-) create mode 100644 .envrc delete mode 100644 .vscode/settings.json create mode 100644 devenv.lock create mode 100644 devenv.nix create mode 100644 devenv.yaml create mode 120000 result diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..e3c2943 --- /dev/null +++ b/.envrc @@ -0,0 +1,7 @@ +export DIRENV_WARN_TIMEOUT=20s + +eval "$(devenv direnvrc)" + +# The use_devenv function supports passing flags to the devenv command +# For example: use devenv --impure --option services.postgres.enable:bool true +use devenv diff --git a/.gitignore b/.gitignore index eb50cd0..d8dec56 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,18 @@ node_modules/ dist/ +result/ -# Jetbrains IDE -.idea/ \ No newline at end of file +# IDEs +.idea/ +.vscode/ + +# Devenv +.devenv* +devenv.local.nix + + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index a1a7bdf..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "exportall.config.folderListener": [ - "/plugins/ui/src/components", - "/plugins/ui/src/components/settings", - "/plugins/ui/src/helpers", - "/plugins/lib/src/helpers", - "/plugins/lib/src/classes", - "/plugins/lib/src/redux" - ] -} diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..c4b1cb2 --- /dev/null +++ b/devenv.lock @@ -0,0 +1,103 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1748273445, + "owner": "cachix", + "repo": "devenv", + "rev": "668a50d8b7bdb19a0131f53c9f6c25c9071e1ffb", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1747046372, + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1747372754, + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "80479b6ec16fefd9c1db3ea13aeb038c60530f46", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1746807397, + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "c5208b594838ea8e6cca5997fbf784b7cca1ca90", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "git-hooks": "git-hooks", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": [ + "git-hooks" + ] + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..6dbfa9f --- /dev/null +++ b/devenv.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: + +{ + languages.javascript = { + enable = true; + corepack.enable = true; + pnpm = { + enable = true; + install.enable = true; + }; + + }; +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..c8da167 --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,5 @@ +inputs: + nixpkgs: + url: github:cachix/devenv-nixpkgs/rolling + +allowUnfree: true diff --git a/flake.lock b/flake.lock index 078da89..d93bf7c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,6 +1,94 @@ { "nodes": { + "cachix": { + "inputs": { + "devenv": [ + "devenv" + ], + "flake-compat": [ + "devenv" + ], + "git-hooks": [ + "devenv" + ], + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1744206633, + "narHash": "sha256-pb5aYkE8FOoa4n123slgHiOf1UbNSnKe5pEZC+xXD5g=", + "owner": "cachix", + "repo": "cachix", + "rev": "8a60090640b96f9df95d1ab99e5763a586be1404", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "latest", + "repo": "cachix", + "type": "github" + } + }, + "devenv": { + "inputs": { + "cachix": "cachix", + "flake-compat": "flake-compat", + "git-hooks": "git-hooks", + "nix": "nix", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1748273445, + "narHash": "sha256-5V0dzpNgQM0CHDsMzh+ludYeu1S+Y+IMjbaskSSdFh0=", + "owner": "cachix", + "repo": "devenv", + "rev": "668a50d8b7bdb19a0131f53c9f6c25c9071e1ffb", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "devenv", + "nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1712014858, + "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" }, @@ -17,18 +105,114 @@ "type": "indirect" } }, + "git-hooks": { + "inputs": { + "flake-compat": [ + "devenv" + ], + "gitignore": "gitignore", + "nixpkgs": [ + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1746537231, + "narHash": "sha256-Wb2xeSyOsCoTCTj7LOoD6cdKLEROyFAArnYoS+noCWo=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "fa466640195d38ec97cf0493d6d6882bc4d14969", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "devenv", + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "libgit2": { + "flake": false, + "locked": { + "lastModified": 1697646580, + "narHash": "sha256-oX4Z3S9WtJlwvj0uH9HlYcWv+x1hqp8mhXl7HsLu2f0=", + "owner": "libgit2", + "repo": "libgit2", + "rev": "45fd9ed7ae1a9b74b957ef4f337bc3c8b3df01b5", + "type": "github" + }, + "original": { + "owner": "libgit2", + "repo": "libgit2", + "type": "github" + } + }, + "nix": { + "inputs": { + "flake-compat": [ + "devenv" + ], + "flake-parts": "flake-parts", + "libgit2": "libgit2", + "nixpkgs": "nixpkgs_2", + "nixpkgs-23-11": [ + "devenv" + ], + "nixpkgs-regression": [ + "devenv" + ], + "pre-commit-hooks": [ + "devenv" + ] + }, + "locked": { + "lastModified": 1745930071, + "narHash": "sha256-bYyjarS3qSNqxfgc89IoVz8cAFDkF9yPE63EJr+h50s=", + "owner": "domenkozar", + "repo": "nix", + "rev": "b455edf3505f1bf0172b39a735caef94687d0d9c", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "devenv-2.24", + "repo": "nix", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1748186667, - "narHash": "sha256-UQubDNIQ/Z42R8tPCIpY+BOhlxO8t8ZojwC9o2FW3c8=", + "lastModified": 1733212471, + "narHash": "sha256-M1+uCoV5igihRfcUKrr1riygbe73/dzNnzPsmaLCmpo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "bdac72d387dca7f836f6ef1fe547755fb0e9df61", + "rev": "55d15ad12a74eb7d4646254e13638ad0c4128776", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } @@ -48,10 +232,59 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1717432640, + "narHash": "sha256-+f9c4/ZX5MWDOuB1rKoWj+lBNm0z0rs4CK47HBLxy1o=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "88269ab3044128b7c2f4c7d68448b2fb50456870", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1746807397, + "narHash": "sha256-zU2z0jlkJGWLhdNr/8AJSxqK8XD0IlQgHp3VZcP56Aw=", + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "c5208b594838ea8e6cca5997fbf784b7cca1ca90", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1748186667, + "narHash": "sha256-UQubDNIQ/Z42R8tPCIpY+BOhlxO8t8ZojwC9o2FW3c8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "bdac72d387dca7f836f6ef1fe547755fb0e9df61", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { - "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs", + "devenv": "devenv", + "flake-parts": "flake-parts_2", + "nixpkgs": "nixpkgs_4", "systems": "systems" } }, diff --git a/flake.nix b/flake.nix index 66c930d..66805f5 100644 --- a/flake.nix +++ b/flake.nix @@ -2,12 +2,16 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; systems.url = "github:nix-systems/default"; + devenv.url = "github:cachix/devenv"; }; outputs = inputs@{ self, systems, flake-parts, nixpkgs, ... }: flake-parts.lib.mkFlake { inherit inputs; } { systems = import systems; - imports = [ ./nix ]; + imports = [ + ./nix + inputs.devenv.flakeModule + ]; perSystem = { config, pkgs, system, ... }: { _module.args.pkgs = import inputs.nixpkgs { @@ -17,6 +21,7 @@ packages.injection = pkgs.callPackage ./nix/package.nix { inherit (pkgs) nodejs fetchFromGitHub; pnpm = pkgs.pnpm_9; }; + packages.default = pkgs.tidaLuna; }; }; diff --git a/native/injector.ts b/native/injector.ts index bc62111..a500256 100644 --- a/native/injector.ts +++ b/native/injector.ts @@ -1,4 +1,5 @@ import electron from "electron"; +import os from "os"; import { readFile, rm, writeFile } from "fs/promises"; import mime from "mime"; @@ -25,6 +26,7 @@ declare global { tidalWindow?: Electron.BrowserWindow; }; } + globalThis.luna = { modules: {}, }; @@ -211,7 +213,9 @@ const requirePrefix = `import { createRequire } from 'module';const require = cr ipcHandle("__Luna.registerNative", async (_, name: string, code: string) => { const tempPath = path.join(bundleDir, Math.random().toString() + ".mjs"); try { + console.error('AAARG') await writeFile(tempPath, requirePrefix + code, "utf8"); + // Load module const exports = (globalThis.luna.modules[name] = await import(pathToFileURL(tempPath).href)); const channel = `__LunaNative.${name}`; diff --git a/nix/package.nix b/nix/package.nix index 51d3535..8612e2f 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -3,12 +3,7 @@ stdenv.mkDerivation (finalAttrs: rec { name = "TidaLuna"; pname = "${name}"; version = "1.1.0-alpha"; - src = fetchFromGitHub { - owner = "Inrixia"; - repo = "${name}"; - rev = "${version}"; - hash = "sha256-T6J6mI3oxQ7tD8b76M15ajka1S8G9QW8Am3rqj0MaTo="; - }; + src = ./..; # TODO: dont forget to change! nativeBuildInputs = [ nodejs @@ -17,7 +12,7 @@ stdenv.mkDerivation (finalAttrs: rec { pnpmDeps = pnpm.fetchDeps { inherit (finalAttrs) pname src version; - hash = "sha256-pnuDLjUAOxQUFlf+2FXeX2mpZcahzzVPMRpWZpbyDE4="; + hash = "sha256-2Nf7kzmiJT7P9jNCPI16VHTPREjKR1l2yoxdtNReCx0="; }; buildPhase = '' diff --git a/result b/result new file mode 120000 index 0000000..710bbed --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/7p4zs2g89m1l498vszvb5hnfq0n0yk45-tidal-hifi-5.19.0 \ No newline at end of file From cdd77bc50f330be32c2cfe7f6d7b3ff362c9f40b Mon Sep 17 00:00:00 2001 From: Xaiya Schumin Date: Mon, 26 May 2025 20:05:19 +0200 Subject: [PATCH 5/8] =?UTF-8?q?=F0=9F=99=88=20Update=20ignore=20for=20resu?= =?UTF-8?q?lt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xaiya Schumin --- .gitignore | 4 ++-- result | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 120000 result diff --git a/.gitignore b/.gitignore index d8dec56..7892c4a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ node_modules/ dist/ -result/ +result # IDEs .idea/ @@ -15,4 +15,4 @@ devenv.local.nix .direnv # pre-commit -.pre-commit-config.yaml \ No newline at end of file +.pre-commit-config.yaml diff --git a/result b/result deleted file mode 120000 index 710bbed..0000000 --- a/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/7p4zs2g89m1l498vszvb5hnfq0n0yk45-tidal-hifi-5.19.0 \ No newline at end of file From 588e55ce75d34c205227cddb8c59a5dc6ed02057 Mon Sep 17 00:00:00 2001 From: Xaiya Schumin Date: Tue, 27 May 2025 10:47:21 +0200 Subject: [PATCH 6/8] =?UTF-8?q?=E2=9C=A8=20tempPath=20now=20in=20tempDir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xaiya Schumin --- .gitignore | 1 + native/injector.ts | 21 +++++++++++++++------ nix/package.nix | 1 - 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 7892c4a..9949668 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ node_modules/ dist/ result +result-original # IDEs .idea/ diff --git a/native/injector.ts b/native/injector.ts index a500256..534ef98 100644 --- a/native/injector.ts +++ b/native/injector.ts @@ -64,6 +64,7 @@ ipcHandle("__Luna.renderJs", () => lunaBundle); // Ensure app is ready electron.app.whenReady().then(async () => { electron.protocol.handle("https", async (req) => { + if (req.url.startsWith("https://luna/")) { try { return new Response(...(await bundleFile(req.url))); @@ -71,6 +72,7 @@ electron.app.whenReady().then(async () => { return new Response(err.message, { status: err.message.startsWith("ENOENT") ? 404 : 500, statusText: err.message }); } } + // Bypass CSP & Mark meta scripts for quartz injection if (req.url === "https://desktop.tidal.com/" || req.url === "https://listen.tidal.com/") { const res = await electron.net.fetch(req, { bypassCustomProtocolHandlers: true }); @@ -85,6 +87,7 @@ electron.app.whenReady().then(async () => { // Mark module scripts for quartz injection return `