diff --git a/.envrc b/.envrc index 3550a30..979cc3e 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,4 @@ +if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" +fi use flake diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e623fd6..9f662c7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -27,10 +27,12 @@ jobs: fail-fast: false matrix: settings: - - host: macos-latest + - host: macos-14-large target: x86_64-apple-darwin - build: | - bun run build + architecture: x64 + build: |- + set -e && + bun run build --target x86_64-apple-darwin && strip -x *.node - host: ubuntu-latest target: x86_64-unknown-linux-gnu @@ -46,6 +48,8 @@ jobs: - uses: actions/checkout@v4 - name: Setup Bun uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.0.26 - name: Setup node uses: actions/setup-node@v4 if: ${{ !matrix.settings.docker }} @@ -58,7 +62,7 @@ jobs: toolchain: stable targets: ${{ matrix.settings.target }} - name: Cache cargo - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.cargo/registry/index/ @@ -89,7 +93,7 @@ jobs: if: ${{ !matrix.settings.docker }} shell: bash - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: bindings-${{ matrix.settings.target }} path: ${{ env.APP_NAME }}.*.node @@ -102,21 +106,25 @@ jobs: strategy: matrix: settings: - - host: macos-latest + - host: macos-14-large target: x86_64-apple-darwin + architecture: x64 runs-on: ${{ matrix.settings.host }} steps: - uses: actions/checkout@v4 - name: Setup Bun uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.0.26 - name: Setup node uses: actions/setup-node@v4 with: node-version: 20 + architecture: ${{ matrix.settings.architecture }} - name: Install dependencies run: bun install - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: bindings-${{ matrix.settings.target }} path: . @@ -140,6 +148,8 @@ jobs: - uses: actions/checkout@v4 - name: Setup Bun uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.0.26 - name: Setup node uses: actions/setup-node@v4 with: @@ -147,7 +157,7 @@ jobs: - name: Install dependencies run: bun install - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: bindings-${{ matrix.settings.target }} path: . @@ -155,7 +165,7 @@ jobs: run: ls -R . shell: bash - name: Test bindings - run: docker run --rm -v $(pwd):/build -w /build oven/bun:1 bun test + run: docker run --rm -v $(pwd):/build -w /build oven/bun:1.0.26 bun test publish: name: Publish @@ -167,6 +177,8 @@ jobs: - uses: actions/checkout@v4 - name: Setup Bun uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.0.26 - name: Setup node uses: actions/setup-node@v4 with: @@ -174,7 +186,7 @@ jobs: - name: Install dependencies run: bun install - name: Download all artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: path: artifacts - name: Move artifacts diff --git a/.gitignore b/.gitignore index 00ed0f8..bed3986 100644 --- a/.gitignore +++ b/.gitignore @@ -196,3 +196,4 @@ Cargo.lock !.yarn/versions *.node +/.direnv diff --git a/bun.lockb b/bun.lockb index 50a1bf2..941803e 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/flake.nix b/flake.nix index b04fca6..298d5ed 100644 --- a/flake.nix +++ b/flake.nix @@ -20,5 +20,7 @@ { devShells.aarch64-darwin.default = mkDevShell "aarch64-darwin"; devShells.x86_64-darwin.default = mkDevShell "x86_64-darwin"; + devShells.aarch64-linux.default = mkDevShell "aarch64-linux"; + devShells.x86_64-linux.default = mkDevShell "x86_64-linux"; }; } diff --git a/index.js b/index.js index 1481fc1..1a2a909 100644 --- a/index.js +++ b/index.js @@ -224,17 +224,32 @@ switch (platform) { } break case 'arm': - localFileExisted = existsSync( - join(__dirname, 'ruspty.linux-arm-gnueabihf.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./ruspty.linux-arm-gnueabihf.node') - } else { - nativeBinding = require('@replit/ruspty-linux-arm-gnueabihf') + if (isMusl()) { + localFileExisted = existsSync( + join(__dirname, 'ruspty.linux-arm-musleabihf.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./ruspty.linux-arm-musleabihf.node') + } else { + nativeBinding = require('@replit/ruspty-linux-arm-musleabihf') + } + } catch (e) { + loadError = e + } + } else { + localFileExisted = existsSync( + join(__dirname, 'ruspty.linux-arm-gnueabihf.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./ruspty.linux-arm-gnueabihf.node') + } else { + nativeBinding = require('@replit/ruspty-linux-arm-gnueabihf') + } + } catch (e) { + loadError = e } - } catch (e) { - loadError = e } break case 'riscv64': diff --git a/package.json b/package.json index 3fb0923..8bfb8cb 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ }, "license": "MIT", "devDependencies": { - "@napi-rs/cli": "^2.17.0", + "@napi-rs/cli": "^2.18.2", "@types/node": "^20.4.1", "@types/jest": "^29.5.11", "prettier": "^3.2.4"