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/.github/workflows/releaseDev.yml b/.github/workflows/releaseDev.yml index 0af21bb..84ff2cb 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 injection --version=unstable diff --git a/.github/workflows/releaseMaster.yml b/.github/workflows/releaseMaster.yml index d715a27..c741303 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 injection --version=unstable diff --git a/.gitignore b/.gitignore index 04c01ba..9949668 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,19 @@ node_modules/ -dist/ \ No newline at end of file +dist/ +result +result-original + +# IDEs +.idea/ +.vscode/ + +# Devenv +.devenv* +devenv.local.nix + + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml 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/README.md b/README.md index 9bfcd6f..4313fc1 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,10 @@ Use one of the following projects: - Ensure that Tidal is closed when installing or installation may fail. - You shouldnt need to run as Admin for installing. +### Nix install +1. Add this flake in your inputs: `inputs.tidaLuna.url = github:Inrixia/TidaLuna` +2. then install the package from the input: `inputs'.tidaLuna.packages.default` (with flake-parts) + ### Manual Install 1. Download the **luna.zip** release you want to install from https://github.com/Inrixia/TidaLuna/releases 2. Go to your Tidal install resources folder, typically found in: 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 new file mode 100644 index 0000000..d93bf7c --- /dev/null +++ b/flake.lock @@ -0,0 +1,309 @@ +{ + "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" + }, + "locked": { + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "type": "github" + }, + "original": { + "id": "flake-parts", + "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": 1733212471, + "narHash": "sha256-M1+uCoV5igihRfcUKrr1riygbe73/dzNnzPsmaLCmpo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "55d15ad12a74eb7d4646254e13638ad0c4128776", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "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" + } + }, + "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": { + "devenv": "devenv", + "flake-parts": "flake-parts_2", + "nixpkgs": "nixpkgs_4", + "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..8a8dbc8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,29 @@ +{ + 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 + inputs.devenv.flakeModule + ]; + + perSystem = { config, pkgs, system, ... }: { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + config.allowUnfree = true; + overlays = [ self.overlays.default ]; + }; + + packages.injection = + pkgs.callPackage ./nix/package.nix { inherit (pkgs) nodejs fetchFromGitHub; pnpm = pkgs.pnpm_9; }; + + packages.default = pkgs.tidaLuna; + }; + }; +} \ No newline at end of file diff --git a/native/injector.ts b/native/injector.ts index bc62111..534ef98 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: {}, }; @@ -62,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))); @@ -69,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 }); @@ -83,6 +87,7 @@ electron.app.whenReady().then(async () => { // Mark module scripts for quartz injection return `