From 89a39fdd63a1fe315fd2893aebea3580ae09ed7e Mon Sep 17 00:00:00 2001 From: EthanShoeDev <13422990+EthanShoeDev@users.noreply.github.com> Date: Wed, 24 Sep 2025 04:04:13 -0400 Subject: [PATCH] flake --- .dockerignore | 322 +++++++++++++++++++++++++++++++ .github/actions/setup/action.yml | 21 -- .github/workflows/check.yml | 29 ++- Dockerfile | 20 ++ flake.lock | 12 +- flake.nix | 91 ++++++--- justfile | 10 + package.json | 2 + turbo.jsonc | 10 +- 9 files changed, 455 insertions(+), 62 deletions(-) create mode 100644 .dockerignore delete mode 100644 .github/actions/setup/action.yml create mode 100644 Dockerfile create mode 100644 justfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b77c5f9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,322 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# Dependencies +**/node_modules +**/.pnp +**/.pnp.js + +# Testing +**/coverage + +# Turbo +**/.turbo + +# Vercel +**/.vercel + +# Build Outputs +**/.next/ +**/out/ +**/dist + + +# Debug +**/npm-debug.log* +**/yarn-debug.log* +**/yarn-error.log* + +# Misc +**/.DS_Store +**/*.pem + +**/tmp/ +**/**/tsconfig.tsbuildinfo + +**/dep-log.json + +**/mnt/* +**/*.log +**/.turbo/ +# From apps/mobile/.gitignore +# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files + +# dependencies +apps/mobile/**/node_modules/ + +# Expo +apps/mobile/**/.expo/ +apps/mobile/**/dist/ +apps/mobile/**/web-build/ +apps/mobile/**/expo-env.d.ts + +# Native +apps/mobile/**/.kotlin/ +apps/mobile/**/*.orig.* +apps/mobile/**/*.jks +apps/mobile/**/*.p8 +apps/mobile/**/*.p12 +apps/mobile/**/*.key +apps/mobile/**/*.mobileprovision + +# Metro +apps/mobile/**/.metro-health-check* + +# debug +apps/mobile/**/npm-debug.* +apps/mobile/**/yarn-debug.* +apps/mobile/**/yarn-error.* + +# macOS +apps/mobile/**/.DS_Store +apps/mobile/**/*.pem + +# local env files +apps/mobile/**/.env*.local + +# typescript +apps/mobile/**/*.tsbuildinfo + +# https://docs.expo.dev/workflow/continuous-native-generation/ +apps/mobile/**/android/ +apps/mobile/**/ios/ + +# From apps/web/.gitignore +# build output +apps/web/**/dist/ + +# generated types +apps/web/**/.astro/ + +# dependencies +apps/web/**/node_modules/ + +# logs +apps/web/**/npm-debug.log* +apps/web/**/yarn-debug.log* +apps/web/**/yarn-error.log* +apps/web/**/pnpm-debug.log* + +# environment variables +apps/web/**/.env +apps/web/**/.env.production + +# macOS-specific files +apps/web/**/.DS_Store + +# jetbrains setting folder +apps/web/**/.idea/ + +# From packages/react-native-uniffi-russh/.gitignore +# OSX +# +packages/react-native-uniffi-russh/**/.DS_Store + +# XDE +packages/react-native-uniffi-russh/**/.expo/ + +# VSCode +packages/react-native-uniffi-russh/**/.vscode/ +packages/react-native-uniffi-russh/**/jsconfig.json + +# Xcode +# +packages/react-native-uniffi-russh/**/build/ +packages/react-native-uniffi-russh/**/*.pbxuser +!packages/react-native-uniffi-russh/**/default.pbxuser +packages/react-native-uniffi-russh/**/*.mode1v3 +!packages/react-native-uniffi-russh/**/default.mode1v3 +packages/react-native-uniffi-russh/**/*.mode2v3 +!packages/react-native-uniffi-russh/**/default.mode2v3 +packages/react-native-uniffi-russh/**/*.perspectivev3 +!packages/react-native-uniffi-russh/**/default.perspectivev3 +packages/react-native-uniffi-russh/**/xcuserdata +packages/react-native-uniffi-russh/**/*.xccheckout +packages/react-native-uniffi-russh/**/*.moved-aside +packages/react-native-uniffi-russh/**/DerivedData +packages/react-native-uniffi-russh/**/*.hmap +packages/react-native-uniffi-russh/**/*.ipa +packages/react-native-uniffi-russh/**/*.xcuserstate +packages/react-native-uniffi-russh/**/project.xcworkspace +packages/react-native-uniffi-russh/**/**/.xcode.env.local + +# Android/IJ +# +packages/react-native-uniffi-russh/**/.classpath +packages/react-native-uniffi-russh/**/.cxx +packages/react-native-uniffi-russh/**/.gradle +packages/react-native-uniffi-russh/**/.idea +packages/react-native-uniffi-russh/**/.project +packages/react-native-uniffi-russh/**/.settings +packages/react-native-uniffi-russh/**/local.properties +packages/react-native-uniffi-russh/**/android.iml + +# Cocoapods +# +packages/react-native-uniffi-russh/**/example/ios/Pods + +# Ruby +packages/react-native-uniffi-russh/**/example/vendor/ + +# node.js +# +packages/react-native-uniffi-russh/**/node_modules/ +packages/react-native-uniffi-russh/**/npm-debug.log +packages/react-native-uniffi-russh/**/yarn-debug.log +packages/react-native-uniffi-russh/**/yarn-error.log + +# BUCK +packages/react-native-uniffi-russh/**/buck-out/ +packages/react-native-uniffi-russh/**/\.buckd/ +packages/react-native-uniffi-russh/**/android/app/libs +packages/react-native-uniffi-russh/**/android/keystores/debug.keystore + +# Yarn +packages/react-native-uniffi-russh/**/.yarn/* +!packages/react-native-uniffi-russh/**/.yarn/patches +!packages/react-native-uniffi-russh/**/.yarn/plugins +!packages/react-native-uniffi-russh/**/.yarn/releases +!packages/react-native-uniffi-russh/**/.yarn/sdks +!packages/react-native-uniffi-russh/**/.yarn/versions + +# Expo +packages/react-native-uniffi-russh/**/.expo/ + +# Turborepo +packages/react-native-uniffi-russh/**/.turbo/ + +# generated by bob +packages/react-native-uniffi-russh/lib + +# React Native Codegen +packages/react-native-uniffi-russh/**/ios/generated +packages/react-native-uniffi-russh/**/android/generated + +# React Native Nitro Modules +packages/react-native-uniffi-russh/**/nitrogen/ + +# From uniffi-bindgen-react-native +# rust_modules/ +packages/react-native-uniffi-russh/**/*.a +packages/react-native-uniffi-russh/android +packages/react-native-uniffi-russh/ios +packages/react-native-uniffi-russh/cpp +packages/react-native-uniffi-russh/src/* +packages/react-native-uniffi-russh/**/*.xcframework +packages/react-native-uniffi-russh/**/*.podspec + +!packages/react-native-uniffi-russh/**/src/api.ts +# From packages/react-native-uniffi-russh/rust/.gitignore +# Created by https://www.toptal.com/developers/gitignore/api/rust,xcode,android +# Edit at https://www.toptal.com/developers/gitignore?templates=rust,xcode,android + +### Android ### +# Gradle files +packages/react-native-uniffi-russh/rust/**/.gradle/ +packages/react-native-uniffi-russh/rust/**/build/ + +# Local configuration file (sdk path, etc) +packages/react-native-uniffi-russh/rust/**/local.properties + +# Log/OS Files +packages/react-native-uniffi-russh/rust/**/*.log + +# Android Studio generated files and folders +packages/react-native-uniffi-russh/rust/**/captures/ +packages/react-native-uniffi-russh/rust/**/.externalNativeBuild/ +packages/react-native-uniffi-russh/rust/**/.cxx/ +packages/react-native-uniffi-russh/rust/**/*.apk +packages/react-native-uniffi-russh/rust/**/output.json + +# IntelliJ +packages/react-native-uniffi-russh/rust/**/*.iml +packages/react-native-uniffi-russh/rust/**/.idea/ +packages/react-native-uniffi-russh/rust/**/misc.xml +packages/react-native-uniffi-russh/rust/**/deploymentTargetDropDown.xml +packages/react-native-uniffi-russh/rust/**/render.experimental.xml + +# Keystore files +packages/react-native-uniffi-russh/rust/**/*.jks +packages/react-native-uniffi-russh/rust/**/*.keystore + +# Google Services (e.g. APIs or Firebase) +packages/react-native-uniffi-russh/rust/**/google-services.json + +# Android Profiling +packages/react-native-uniffi-russh/rust/**/*.hprof + +### Android Patch ### +packages/react-native-uniffi-russh/rust/**/gen-external-apklibs + +# Replacement of .externalNativeBuild directories introduced +# with Android Studio 3.5. + +### Rust ### +# Generated by Cargo +# will have compiled files and executables +packages/react-native-uniffi-russh/rust/**/debug/ +packages/react-native-uniffi-russh/rust/**/target/ + +# These are backup files generated by rustfmt +packages/react-native-uniffi-russh/rust/**/**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +packages/react-native-uniffi-russh/rust/**/*.pdb + +### Xcode ### +## User settings +packages/react-native-uniffi-russh/rust/**/xcuserdata/ + +## Xcode 8 and earlier +packages/react-native-uniffi-russh/rust/**/*.xcscmblueprint +packages/react-native-uniffi-russh/rust/**/*.xccheckout + +### Xcode Patch ### +packages/react-native-uniffi-russh/rust/**/*.xcodeproj/* +!packages/react-native-uniffi-russh/rust/**/*.xcodeproj/project.pbxproj +!packages/react-native-uniffi-russh/rust/**/*.xcodeproj/xcshareddata/ +!packages/react-native-uniffi-russh/rust/**/*.xcodeproj/project.xcworkspace/ +!packages/react-native-uniffi-russh/rust/**/*.xcworkspace/contents.xcworkspacedata +packages/react-native-uniffi-russh/rust/*.gcno +packages/react-native-uniffi-russh/rust/**/**/xcshareddata/WorkspaceSettings.xcsettings + +# End of https://www.toptal.com/developers/gitignore/api/rust,xcode,android + +# Swift Package Manager +packages/react-native-uniffi-russh/rust/**/.build/ + +# macOS Ignores +packages/react-native-uniffi-russh/rust/**/.DS_Store + +# Android (cargo-ndk outputs; they end up in the Android source tree) +packages/react-native-uniffi-russh/rust/**/*.so + +# From packages/react-native-uniffi-russh/rust/uniffi-russh/.gitignore +!packages/react-native-uniffi-russh/rust/uniffi-russh/**/.vscode +packages/react-native-uniffi-russh/rust/uniffi-russh/**/mnt/ +# From packages/react-native-xtermjs-webview/.gitignore +# Logs +packages/react-native-xtermjs-webview/**/logs +packages/react-native-xtermjs-webview/**/*.log +packages/react-native-xtermjs-webview/**/npm-debug.log* +packages/react-native-xtermjs-webview/**/yarn-debug.log* +packages/react-native-xtermjs-webview/**/yarn-error.log* +packages/react-native-xtermjs-webview/**/pnpm-debug.log* +packages/react-native-xtermjs-webview/**/lerna-debug.log* + +packages/react-native-xtermjs-webview/**/node_modules +packages/react-native-xtermjs-webview/**/dist +packages/react-native-xtermjs-webview/**/dist-internal +packages/react-native-xtermjs-webview/**/dist-ssr +packages/react-native-xtermjs-webview/**/*.local + +# Editor directories and files +packages/react-native-xtermjs-webview/**/.vscode/* +!packages/react-native-xtermjs-webview/**/.vscode/extensions.json +packages/react-native-xtermjs-webview/**/.idea +packages/react-native-xtermjs-webview/**/.DS_Store +packages/react-native-xtermjs-webview/**/*.suo +packages/react-native-xtermjs-webview/**/*.ntvs* +packages/react-native-xtermjs-webview/**/*.njsproj +packages/react-native-xtermjs-webview/**/*.sln +packages/react-native-xtermjs-webview/**/*.sw? + diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml deleted file mode 100644 index beb57d4..0000000 --- a/.github/actions/setup/action.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Setup -description: Perform standard setup and install dependencies using pnpm. -inputs: - node-version: - description: The version of Node.js to install - required: true - default: 24.5.0 - -runs: - using: composite - steps: - - name: Install pnpm - uses: pnpm/action-setup@v3 - - name: Install node - uses: actions/setup-node@v4 - with: - cache: pnpm - node-version: ${{ inputs.node-version }} - - name: Install dependencies - shell: bash - run: pnpm install diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index e294184..3cfb1bf 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -20,8 +20,35 @@ jobs: timeout-minutes: 10 steps: - uses: actions/checkout@v4 + + - name: Cache Nix Store + uses: nix-community/cache-nix-action@main + with: + primary-key: ${{ runner.os }}-nix-${{ hashFiles('flake.lock') }} + + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@main + + - name: Load devShell environment + uses: nicknovitski/nix-develop@main + with: + arguments: .#android-remote + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + - name: Install dependencies - uses: ./.github/actions/setup + run: pnpm install - run: pnpm exec turbo lint:check # test: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f7f1759 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM nixos/nix:latest + +# Enable flakes and nix-command +RUN mkdir -p /etc/nix && \ + echo 'experimental-features = nix-command flakes' > /etc/nix/nix.conf && \ + echo 'accept-flake-config = true' >> /etc/nix/nix.conf + +WORKDIR /workspace + +COPY flake.nix flake.lock . +RUN nix develop .#android-remote + +# Pre-populate pnpm store from lockfile only (fast, cacheable) +COPY pnpm-lock.yaml ./ +COPY patches/* ./patches/ +RUN nix develop .#android-remote -c pnpm fetch + +# Now copy full source and link from the store (no network) +COPY . . +RUN nix develop .#android-remote -c pnpm install --offline --frozen-lockfile \ No newline at end of file diff --git a/flake.lock b/flake.lock index c6050b5..f5617e6 100644 --- a/flake.lock +++ b/flake.lock @@ -9,11 +9,11 @@ ] }, "locked": { - "lastModified": 1757621816, - "narHash": "sha256-r1cZQcvqcF7YUsw70Gxb2eGzuHl/hQHs01WNNeWklIc=", + "lastModified": 1758658832, + "narHash": "sha256-CWJUlYTqdCuWl6a7IYbrEficoz7gKouD7zzuHnko3sI=", "owner": "tadfisher", "repo": "android-nixpkgs", - "rev": "feba9bc6e12243ba9ee9bdb236866e1209c55a78", + "rev": "ee542f7fee389dca5c04622a8fb33459d825cd08", "type": "github" }, "original": { @@ -63,11 +63,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1757487488, - "narHash": "sha256-zwE/e7CuPJUWKdvvTCB7iunV4E/+G0lKfv4kk/5Izdg=", + "lastModified": 1758427187, + "narHash": "sha256-pHpxZ/IyCwoTQPtFIAG2QaxuSm8jWzrzBGjwQZIttJc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ab0f3607a6c7486ea22229b92ed2d355f1482ee0", + "rev": "554be6495561ff07b6c724047bdd7e0716aa7b46", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index c81591d..88fcd76 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ +# nix flake update { - # nix run nixpkgs#alejandra -- format ./flake.nix description = "Expo RN devshells (local emulator / remote AVD)"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; @@ -10,6 +10,15 @@ }; }; + nixConfig = { + extra-substituters = [ + "https://android-nixpkgs.cachix.org" + ]; + extra-trusted-public-keys = [ + "android-nixpkgs.cachix.org-1:2lZoPmwoyTVGaNDHqa6A32tdn8Gc0aMWBRrfXN1H3dQ=" + ]; + }; + outputs = { self, nixpkgs, @@ -30,28 +39,56 @@ ); in { devShells = forAllSystems ({pkgs}: let + defaultPkgs = with pkgs; [ + # System + bash + git + pkg-config + jq + # JS + nodejs_22 + turbo + nodePackages.pnpm + yarn + watchman + # Rust + rustc + clippy + rustfmt + cargo + cargo-ndk + # Android + jdk17 + gradle_8 + # Misc + cmake + ninja + just + alejandra + ]; + + defaultAndroidPkgs = sdk: + with sdk; [ + cmdline-tools-latest + platform-tools # adb/fastboot + platforms-android-36 + build-tools-36-0-0 + ndk-27-1-12297006 + ]; + makeAndroidSdk = mode: let androidSdk = pkgs.androidSdk ( sdk: if mode == "full" then - (with sdk; [ - cmdline-tools-latest - platform-tools - emulator - build-tools-36-0-0 - platforms-android-36 - system-images-android-36-0-Baklava-google-apis-playstore-x86-64 - # Add NDK + CMake for native builds - ndk-26-1-10909125 - cmake-3-22-1 - ]) + (with sdk; + [ + emulator + system-images-android-36-0-Baklava-google-apis-playstore-x86-64 + ] + ++ (defaultAndroidPkgs sdk)) else if mode == "remote" - then - (with sdk; [ - cmdline-tools-latest # ← required for a valid SDK - platform-tools # adb/fastboot - ]) + then (with sdk; (defaultAndroidPkgs sdk)) else throw "makeAndroidSdk: unknown mode '${mode}'. Use \"full\" or \"remote\"." ); @@ -64,20 +101,6 @@ fullAndroidSdk = makeAndroidSdk "full"; remoteAndroidSdk = makeAndroidSdk "remote"; - - defaultPkgs = with pkgs; [ - nodejs_22 - nodePackages.pnpm - git - just - jq - watchman - jdk17 - gradle_8 - cmake - ninja - pkg-config - ]; in { # Minimal: only universal dev tools you always want default = pkgs.mkShell { @@ -112,6 +135,9 @@ hash -r echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" + export ANDROID_NDK_ROOT="$ANDROID_SDK_ROOT/ndk/27.1.12297006" + export ANDROID_NDK_HOME="$ANDROID_NDK_ROOT" + export ANDROID_NDK="$ANDROID_NDK_ROOT" which -a adb || true which -a emulator || true which -a avdmanager || true @@ -128,7 +154,7 @@ packages = defaultPkgs ++ [ - remoteAndroidSdk.androidSdk # provides adb/fastboot only + (pkgs.androidSdk (sdk: (defaultAndroidPkgs sdk))) pkgs.scrcpy ]; shellHook = '' @@ -143,5 +169,6 @@ ''; }; }); + formatter = forAllSystems ({pkgs}: pkgs.alejandra); }; } diff --git a/justfile b/justfile new file mode 100644 index 0000000..f290690 --- /dev/null +++ b/justfile @@ -0,0 +1,10 @@ + + +default: + @just --list + +docker-build: + docker build -t fressh . + +docker-run: + docker run -it --rm fressh \ No newline at end of file diff --git a/package.json b/package.json index 60504de..bc453f5 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,8 @@ "scripts": { "fmt:root": "prettier --cache --write .", "fmt:check:root": "prettier --check .", + "fmt:root:nix": "nix fmt flake.nix", + "fmt:check:root:nix": "nix fmt flake.nix -- --c", "syncpack:fix": "syncpack list-mismatches || (syncpack fix-mismatches && pnpm i)", "syncpack:check": "syncpack list-mismatches", "jscpd:check": "cross-env NODE_OPTIONS=--max-old-space-size=8192 jscpd --config .jscpd.json", diff --git a/turbo.jsonc b/turbo.jsonc index e86a534..6cafa32 100644 --- a/turbo.jsonc +++ b/turbo.jsonc @@ -30,8 +30,14 @@ }, "clean": { "cache": false, "dependsOn": ["^clean"] }, // Root tasks overrides - "//#fmt:root": {}, - "//#fmt:check:root": {}, + "//#fmt:root": { + "with": ["fmt:root:nix"], + }, + "//#fmt:root:nix": {}, + "//#fmt:check:root:nix": {}, + "//#fmt:check:root": { + "with": ["fmt:check:root:nix"], + }, "//#lint:root": { "dependsOn": ["fmt:root"], "with": [