From 01d5cdc435c212f7b7d2d1c87ee212f464461280 Mon Sep 17 00:00:00 2001 From: hazre Date: Sat, 14 Mar 2026 13:40:34 +0100 Subject: [PATCH] chore: add nix devshell flake (android not tested) --- flake.lock | 187 +++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 136 +++++++++++++++++++++++++++++++++++ vite.config.ts | 36 +++++----- 3 files changed, 343 insertions(+), 16 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..a70fe3c7a --- /dev/null +++ b/flake.lock @@ -0,0 +1,187 @@ +{ + "nodes": { + "android-nixpkgs": { + "inputs": { + "devshell": "devshell", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1773434018, + "narHash": "sha256-g/OmqUpsyUg3lw6QNkJudtsE2XVydkCKq724KIrr4no=", + "owner": "tadfisher", + "repo": "android-nixpkgs", + "rev": "b12e333a75f25fde82adad28acf47f57eb1b3dc4", + "type": "github" + }, + "original": { + "owner": "tadfisher", + "repo": "android-nixpkgs", + "type": "github" + } + }, + "devshell": { + "inputs": { + "nixpkgs": [ + "android-nixpkgs", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1768818222, + "narHash": "sha256-460jc0+CZfyaO8+w8JNtlClB2n4ui1RbHfPTLkpwhU8=", + "owner": "numtide", + "repo": "devshell", + "rev": "255a2b1725a20d060f566e4755dbf571bbbb5f76", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1773282481, + "narHash": "sha256-b/GV2ysM8mKHhinse2wz+uP37epUrSE+sAKXy/xvBY4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fe416aaedd397cacb33a610b33d60ff2b431b127", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1773282481, + "narHash": "sha256-b/GV2ysM8mKHhinse2wz+uP37epUrSE+sAKXy/xvBY4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fe416aaedd397cacb33a610b33d60ff2b431b127", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "android-nixpkgs": "android-nixpkgs", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1773371126, + "narHash": "sha256-SGnZQO8hnynR90Lo/1MVrTScsOPx9i26XjqSqoFOZ4E=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "475826b105eb52f39bd3281f60c052299e64d085", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "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 000000000..84c7fd536 --- /dev/null +++ b/flake.nix @@ -0,0 +1,136 @@ +# https://github.com/PleahMaCaka/svelte-tauri-template/blob/a598c33a34489b07680e14bb0d82ac01b0a9a4be/flake.nix +{ + description = "sable dev environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay.url = "github:oxalica/rust-overlay"; + android-nixpkgs.url = "github:tadfisher/android-nixpkgs"; + }; + + nixConfig = { + bash-prompt = "\\[\\e[1;35m\\]sable\\[\\e[0m\\]"; # bold magenta + bash-prompt-suffix = " \\[\\e[0;36m\\]>\\[\\e[0m\\] "; # cyan > + }; + + outputs = + { + nixpkgs, + flake-utils, + rust-overlay, + android-nixpkgs, + ... + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ rust-overlay.overlays.default ]; + config = { + android_sdk.accept_license = true; + allowUnfree = true; + }; + }; + + rust = pkgs.rust-bin.stable.latest.default.override { + targets = [ + "aarch64-linux-android" + "armv7-linux-androideabi" + "i686-linux-android" + "x86_64-linux-android" + ]; + }; + + androidSdk = android-nixpkgs.sdk.${system} ( + sdkPkgs: with sdkPkgs; [ + build-tools-34-0-0 + platforms-android-34 + ndk-26-1-10909125 + cmdline-tools-latest + platform-tools + emulator + ] + ); + + baseShell = { + nativeBuildInputs = with pkgs; [ + pkg-config + gobject-introspection + cargo + cargo-tauri + nodejs + xdg-utils + desktop-file-utils + ]; + + buildInputs = with pkgs; [ + at-spi2-atk + atkmm + cairo + gdk-pixbuf + glib + glib-networking + gtk3 + gsettings-desktop-schemas + harfbuzz + librsvg + libsoup_3 + pango + webkitgtk_4_1 + openssl + libayatana-appindicator + gst_all_1.gstreamer + gst_all_1.gst-plugins-base + gst_all_1.gst-plugins-good + gst_all_1.gst-plugins-bad + gst_all_1.gst-plugins-ugly + gst_all_1.gst-libav + ]; + + packages = with pkgs; [ + coreutils + nix + pnpm + rust + ]; + + shellHook = '' + export XDG_DATA_DIRS="$GSETTINGS_SCHEMAS_PATH:$XDG_DATA_DIRS" + export GIO_EXTRA_MODULES="${pkgs.glib-networking}/lib/gio/modules" + export GST_PLUGIN_SYSTEM_PATH="${pkgs.gst_all_1.gst-plugins-base}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-good}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-bad}/lib/gstreamer-1.0" + alias tauri="pnpm exec tauri" + echo "Done! Now make sable stable :3"; + ''; + }; + in + { + devShells = { + default = pkgs.mkShell { + name = "sable dev environment"; + inherit (baseShell) nativeBuildInputs buildInputs packages shellHook; + + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ + pkgs.libayatana-appindicator + ]; + }; + + android = pkgs.mkShell { + name = "sable dev environment (android)"; + inherit (baseShell) nativeBuildInputs buildInputs; # <-- shellHook removed here + + packages = baseShell.packages ++ (with pkgs; [ + jdk + androidSdk + ]); + + shellHook = baseShell.shellHook + '' + export NDK_HOME=${androidSdk}/share/android-sdk/ndk/26.1.10909125 + echo "Android SDK ready!"; + ''; + }; + }; + } + ); +} diff --git a/vite.config.ts b/vite.config.ts index 883def3a7..d8d3fc425 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -202,22 +202,26 @@ export default defineConfig({ ], }, }), - cloudflare({ - config: { - compatibility_date: '2026-03-03', - assets: { - not_found_handling: 'single-page-application', - }, - }, - }), - compression({ - algorithms: [ - defineAlgorithm('brotliCompress', { - params: { [zlibConstants.BROTLI_PARAM_QUALITY]: zlibConstants.BROTLI_MAX_QUALITY }, - }), - ], - include: /\.(html|xml|css|json|js|mjs|svg|yaml|yml|toml|wasm|txt|map)$/, - }), + ...(!isTauriBuild + ? [ + cloudflare({ + config: { + compatibility_date: '2026-03-03', + assets: { + not_found_handling: 'single-page-application', + }, + }, + }), + compression({ + algorithms: [ + defineAlgorithm('brotliCompress', { + params: { [zlibConstants.BROTLI_PARAM_QUALITY]: zlibConstants.BROTLI_MAX_QUALITY }, + }), + ], + include: /\.(html|xml|css|json|js|mjs|svg|yaml|yml|toml|wasm|txt|map)$/, + }), + ] + : []), ], optimizeDeps: { // Include service worker entry so worker-only imports are discovered during startup.