diff --git a/README.md b/README.md index 0f548cf..5016f91 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,18 @@ # better-xcloud-nix +A Nix flake providing a standalone Chromium wrapper for Better xCloud. + +## Current State +Functional. The flake builds a shell script wrapper that deploys a pre-configured Chromium profile and launches the browser with required extensions. + +## Versions +* **Nixpkgs**: nixos-unstable +* **Violentmonkey**: v2.49.0 (Manifest V3) +* **Better xCloud**: v6.7.12 (State saved within `preferences.tar.gz`) + +## How It Works +1. The flake uses `fetchzip` to download the Violentmonkey extension release. +2. `writeShellScriptBin` generates the executable wrapper script. +3. Upon execution, the script checks for the existence of `$HOME/.config/better-xcloud-wrapper`. +4. If the profile directory is missing, it extracts the local `preferences.tar.gz` archive into this path. This archive contains the required browser settings, Violentmonkey configuration, and the installed Better xCloud userscript. +5. The script executes Chromium, passing the downloaded extension via `--load-extension` and the extracted profile via `--user-data-dir`. This isolates the application from your primary browser state. diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0ad6b89 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1790463110, + "narHash": "sha256-hKlVl12B1dF0Q5vd9dY3lIJM5mFGWYSlXwSLAqHZ1+s=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e158d9ed9b51c98974c5e66e1ba1c9e0255fecaa", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1e30799 --- /dev/null +++ b/flake.nix @@ -0,0 +1,43 @@ +{ + description = "A chromium wrapper for Better xCloud"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; + + outputs = inputs: { + packages = builtins.mapAttrs ( + system: pkgs: + let + tamper-monkey-ext = pkgs.fetchzip { + url = "https://github.com/violentmonkey/violentmonkey/releases/download/v2.49.0/Violentmonkey-mv3-v2.49.0.zip"; + hash = "sha256-jeIaytwDzN0Q+Lg+K19HWKZlTzEzBPiUjJy6M+H1kZc="; + stripRoot = false; + }; + # better-xcloud-script = pkgs.fetchurl { + # url = "https://github.com/redphx/better-xcloud/releases/download/v6.7.12/better-xcloud.user.js"; + # hash = "sha256-u3iTG07JTWjLGNqX+krh+I5rMQO8FZkFkxsiOKUbUX4="; + # }; + better-xcloud = pkgs.writeShellScriptBin "better-xcloud-wrapper" '' + CONF_DIR=$HOME/.config/better-xcloud-wrapper + PROF_DIR=$CONF_DIR/better-xcloud-wrapper + + if [[ ! -d $CONF_DIR ]]; then + mkdir -p $CONF_DIR + fi + + if [[ ! -d $PROF_DIR ]]; then + tar -xzf ${./preferences.tar.gz} -C $CONF_DIR + fi + + ${pkgs.chromium}/bin/chromium --load-extension=${tamper-monkey-ext} --user-data-dir=$HOME/.config/better-xcloud-wrapper --app=https://www.xbox.com/play/ + ''; + in + { + better-xcloud-wrapper = better-xcloud; + + default = inputs.self.packages.${system}.better-xcloud-wrapper; + } + ) inputs.nixpkgs.legacyPackages; + }; +} diff --git a/preferences.tar.gz b/preferences.tar.gz new file mode 100644 index 0000000..9de211f Binary files /dev/null and b/preferences.tar.gz differ