Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
rustflags = ["-C", "target-feature=-crt-static"]
# Native Linux builds: use mold for faster linking
[target.'cfg(target_os = "linux")']
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
Comment on lines +1 to +3

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid forcing mold for Linux builds without providing it

All Linux targets now inherit -fuse-ld=mold, but the Nix cross/musl packages only add pkg-config to nativeBuildInputs (see mkCrossPackage/mkMuslPackage in flake.nix) and Nix builds run in a pure environment. That means nix build .#x86_64_unknown_linux_musl or .#aarch64_unknown_linux_musl will fail at link time because mold is not in PATH. Either scope the mold flag to builds that include mold, or add mold to the cross/musl build inputs.

Useful? React with 👍 / 👎.


# Cross-compilation settings for CI (yarn build)
# These are used by GitHub Actions, not by Nix builds
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
rustflags = ["-C", "target-feature=+crt-static"]
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use flake

176 changes: 176 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
name: Nix

on:
push:
branches:
- main
paths-ignore:
- "**/*.md"
- LICENSE
- .editorconfig
- docs/**
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
name: Flake Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

- name: Enable Nix cache
uses: DeterminateSystems/magic-nix-cache-action@main

- name: Check flake
uses: DeterminateSystems/flake-checker-action@main

- name: Verify all packages evaluate
run: nix flake check --all-systems --no-build

- name: Run checks (clippy, rustfmt, build)
run: nix flake check

build-linux:
name: Build - ${{ matrix.target }}
runs-on: ubuntu-latest
needs: check
strategy:
fail-fast: false
max-parallel: 1
matrix:
target:
- x86_64_unknown_linux_gnu
- aarch64_unknown_linux_gnu
- x86_64_unknown_linux_musl
- aarch64_unknown_linux_musl
- aarch64_linux_android
include:
# x86_64 glibc uses 'default' - the native build on ubuntu runners
- target: x86_64_unknown_linux_gnu
package: default
steps:
- uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

- name: Enable Nix cache
uses: DeterminateSystems/magic-nix-cache-action@main

- name: Build ${{ matrix.target }}
run: nix build .#${{ matrix.package || matrix.target }} --print-out-paths

- name: List output
run: |
ls -la result/lib/
file result/lib/*.node

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.target }}
path: result/lib/*.node
if-no-files-found: error

build-macos:
name: Build - ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
needs: check
strategy:
fail-fast: false
matrix:
include:
- target: darwin-arm64
runner: macos-latest
steps:
- uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

- name: Enable Nix cache
uses: DeterminateSystems/magic-nix-cache-action@main

- name: Build
run: nix build --print-out-paths

- name: List output
run: |
ls -la result/lib/
file result/lib/*.node

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.target }}
path: result/lib/*.node
if-no-files-found: error

# Disable publish for now
publish:
if: false
name: Publish
runs-on: ubuntu-latest
needs:
- check
- build-linux
- build-macos
steps:
- uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22
cache: yarn

- name: Install dependencies
run: yarn install

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: List downloaded artifacts
run: ls -R artifacts/

- name: Move artifacts to npm directories
run: |
# Copy all .node files from artifacts to current directory
# Nix outputs match NAPI-RS naming: lightning-js.{platform}.node
find artifacts -name "*.node" -exec cp {} . \;

# List what we have
ls -la lightning-js.*.node

# Run NAPI-RS artifacts command to move files to npm/ subdirectories
yarn artifacts

- name: List packages
run: ls -R ./npm

- name: Publish
run: |
npm config set provenance true
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --tag next --access public
else
echo "Not a release, skipping publish"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ dist
#Added by cargo

/target
Cargo.lock

*.node
.pnp.*
Expand Down
Loading
Loading