mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-05 23:37:35 +00:00
204 lines
8.3 KiB
YAML
204 lines
8.3 KiB
YAML
name: Nix Haskell builds
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches: [master, stable, build/stable-ghc-9.14]
|
|
paths:
|
|
- 'flake.*'
|
|
- '*.cabal'
|
|
- 'cabal.project*'
|
|
- 'src/**'
|
|
- 'apps/simplex-*/**'
|
|
- 'bots/**'
|
|
- 'scripts/nix/**'
|
|
- 'Makefile'
|
|
- '.github/workflows/nix.yml'
|
|
pull_request:
|
|
paths:
|
|
- 'flake.*'
|
|
- '*.cabal'
|
|
- 'cabal.project*'
|
|
- 'src/**'
|
|
- 'apps/simplex-*/**'
|
|
- 'bots/**'
|
|
- 'scripts/nix/**'
|
|
- 'Makefile'
|
|
- '.github/workflows/nix.yml'
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: nix-${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
name: ${{ matrix.system }} / ${{ matrix.target }} / pinned Haskell compiler
|
|
runs-on: ${{ matrix.runner }}
|
|
timeout-minutes: 360
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- system: x86_64-linux
|
|
runner: ubuntu-24.04
|
|
target: native
|
|
- system: x86_64-linux
|
|
runner: ubuntu-24.04
|
|
target: android
|
|
- system: x86_64-linux
|
|
runner: ubuntu-24.04
|
|
target: windows
|
|
- system: x86_64-linux
|
|
runner: ubuntu-24.04
|
|
target: linux-static
|
|
- system: aarch64-linux
|
|
runner: ubuntu-24.04-arm
|
|
target: native
|
|
- system: aarch64-darwin
|
|
runner: macos-15
|
|
target: all
|
|
- system: x86_64-darwin
|
|
runner: macos-15-intel
|
|
target: all
|
|
env:
|
|
NIX_SYSTEM: ${{ matrix.system }}
|
|
NIX_TARGET: ${{ matrix.target }}
|
|
NIX_BUILD_TIMEOUT: 7200
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
|
|
- uses: cachix/install-nix-action@v31
|
|
with:
|
|
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
|
extra_nix_config: |
|
|
extra-substituters = https://cache.iog.io https://cache.zw3rk.com
|
|
extra-trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk=
|
|
# The pinned haskell.nix uses this scheduling marker for cross
|
|
# slices that need a real x86_64 host. This runner is native x86_64.
|
|
# The installer skips its defaults when this setting is present.
|
|
# Keep the CLI/flakes features and enable the marker's Nix feature.
|
|
experimental-features = nix-command flakes ${{ matrix.system == 'x86_64-linux' && 'recursive-nix' || '' }}
|
|
extra-system-features = ${{ matrix.system == 'x86_64-linux' && 'recursive-nix' || '' }}
|
|
|
|
- name: Show outputs from this checkout
|
|
run: make nix-list
|
|
|
|
# Use the compiler fork in flake.lock, including both Android ABIs.
|
|
# Stock GHC installed by ghcup is not interchangeable with this compiler.
|
|
- name: Build existing Haskell outputs
|
|
id: haskell_build
|
|
shell: bash
|
|
run: make nix-build 2>&1 | tee nix-build.log
|
|
|
|
# Diagnose the same native library after failure. Keep the canonical
|
|
# failure and its flags intact; this is a separate diagnostic derivation.
|
|
- name: Trace native Linux GHC and capture faults after failure
|
|
id: ghc_phase_trace
|
|
if: ${{ failure() && matrix.system == 'x86_64-linux' && matrix.target == 'native' && steps.haskell_build.outcome == 'failure' }}
|
|
shell: bash
|
|
run: |
|
|
if [ -d "result-nix/$NIX_SYSTEM/lib:simplex-chat" ]; then
|
|
echo 'Native library already built; skipping its diagnostic trace.'
|
|
exit 0
|
|
fi
|
|
echo 'attempted=true' >> "$GITHUB_OUTPUT"
|
|
flake_ref="git+file://$GITHUB_WORKSPACE?rev=$(git rev-parse HEAD)"
|
|
original="(builtins.getFlake \"$flake_ref\").hydraJobs.x86_64-linux.\"lib:simplex-chat\""
|
|
export flake_ref original
|
|
timeout --kill-after=30s 7200s nice -n 10 bash -euo pipefail \
|
|
2>&1 <<'TRACE' | tee native-linux-ghc-phase-trace.log
|
|
debugger="(import ((builtins.getFlake \"$flake_ref\").inputs.nixpkgs) { system = \"x86_64-linux\"; }).gdb"
|
|
# Fetch the pinned debugger only from caches. Never compile it locally
|
|
# or remotely while diagnosing the already-failed application build.
|
|
nix build --expr "$debugger" --no-link --max-jobs 0 --builders '' \
|
|
--option external-builders '[]'
|
|
exec nix build \
|
|
--file scripts/nix/trace-native-ghc.nix --arg original "$original" \
|
|
--arg debugger "$debugger" \
|
|
--no-link -L --keep-failed --max-jobs 1 --timeout 7200
|
|
TRACE
|
|
|
|
- name: Upload native Linux GHC phase log
|
|
if: ${{ always() && steps.ghc_phase_trace.outputs.attempted == 'true' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: nix-ghc-phase-trace-${{ matrix.system }}-${{ matrix.target }}-${{ github.sha }}
|
|
path: native-linux-ghc-phase-trace.log
|
|
if-no-files-found: warn
|
|
|
|
- name: Capture Intel Darwin ghc-boot Setup failure
|
|
id: intel_setup_trace
|
|
if: ${{ failure() && matrix.system == 'x86_64-darwin' && matrix.target == 'all' && steps.haskell_build.outcome == 'failure' }}
|
|
timeout-minutes: 120
|
|
shell: bash
|
|
run: |
|
|
expected_drv=/nix/store/vghjgkr64qjigddh3gnf3c103wbvpxmz-ghc-boot-lib-ghc-boot-9.14.drv
|
|
if ! grep -F "error: Cannot build '$expected_drv'" nix-build.log >/dev/null &&
|
|
! grep -F "builder for '$expected_drv' failed" nix-build.log >/dev/null; then
|
|
echo 'Skipping Intel Setup diagnostic: the pinned ghc-boot component did not fail.'
|
|
exit 0
|
|
fi
|
|
echo 'attempted=true' >> "$GITHUB_OUTPUT"
|
|
export expected_drv
|
|
bash -euo pipefail 2>&1 <<'TRACE' | tee intel-setup-lldb-trace.log
|
|
lldb_path=$(xcrun --find lldb)
|
|
printf 'Intel Setup host debugger: %s\n' "$lldb_path"
|
|
"$lldb_path" --version
|
|
flake_ref="git+file://$GITHUB_WORKSPACE?rev=$(git rev-parse HEAD)"
|
|
original=$(cat <<NIX
|
|
let
|
|
flake = builtins.getFlake "$flake_ref";
|
|
inherit (flake.inputs) haskellNix;
|
|
nativePackages = import (flake.outPath + "/scripts/nix/native-packages.nix") { inherit haskellNix; };
|
|
nativeCompilers = ((nativePackages "x86_64-darwin").appendOverlays [
|
|
(import (haskellNix + "/test/overlay.nix"))
|
|
]).haskell-nix.compiler;
|
|
in nativeCompilers.ghc914-sh.stage2Project.hsPkgs.ghc-boot.components.library
|
|
NIX
|
|
)
|
|
# The failed canonical build already produced this component's inputs.
|
|
# Only this diagnostic permits host LLDB access outside the Nix sandbox.
|
|
exec nix build --file scripts/nix/trace-intel-setup.nix \
|
|
--arg original "$original" --argstr expectedDrv "$expected_drv" \
|
|
--argstr lldbPath "$lldb_path" --option sandbox false \
|
|
--no-link -L --keep-failed --max-jobs 1 --timeout 7200
|
|
TRACE
|
|
|
|
- name: Upload Intel Darwin Setup diagnostic
|
|
if: ${{ always() && steps.intel_setup_trace.outputs.attempted == 'true' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: nix-intel-setup-trace-${{ matrix.system }}-${{ matrix.target }}-${{ github.sha }}
|
|
path: intel-setup-lldb-trace.log
|
|
if-no-files-found: warn
|
|
|
|
- name: Check native CLI encryption and profile passwords
|
|
if: ${{ matrix.target == 'native' || matrix.target == 'all' }}
|
|
run: python3 scripts/nix/smoke-cli.py "result-nix/$NIX_SYSTEM/exe:simplex-chat/bin/simplex-chat"
|
|
|
|
- name: Collect library ZIPs and CLIs
|
|
shell: bash
|
|
run: |
|
|
mkdir -p artifacts
|
|
for output in result-nix/"$NIX_SYSTEM"/*; do
|
|
[ -d "$output" ] || continue
|
|
package_name=$(basename "$output")
|
|
destination="artifacts/${package_name//:/-}"
|
|
mkdir -p "$destination"
|
|
find -L "$output" -maxdepth 1 -type f -name '*.zip' -exec cp {} "$destination/" \;
|
|
if [ -f "$output/bin/simplex-chat" ]; then
|
|
cp "$output/bin/simplex-chat" "$destination/"
|
|
fi
|
|
done
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: nix-${{ matrix.system }}-${{ matrix.target }}-${{ github.sha }}
|
|
path: artifacts/
|
|
if-no-files-found: error
|