Add support for building statically-linked executable #181
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request_target: | |
workflow_dispatch: | |
jobs: | |
extract-ghc-version: | |
name: Extract GHC version | |
runs-on: ubuntu-latest | |
outputs: | |
ghc-version: ${{ steps.get-ghc-version.outputs.ghc_version }} | |
steps: | |
- name: Checkout PR | |
uses: actions/checkout@v4 | |
if: ${{ github.event_name == 'pull_request_target' }} | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
if: ${{ github.event_name != 'pull_request_target' }} | |
- name: Download yq-go | |
run: | | |
curl -L "https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64" -o /usr/local/bin/yq | |
chmod +x /usr/local/bin/yq | |
- name: Extract GHC version from nixkell.toml | |
id: get-ghc-version | |
run: | | |
echo "ghc_version=$(yq -eoy '.ghc.version' nixkell.toml)" | tee -a $GITHUB_OUTPUT | |
nix: | |
name: Build with GHC ${{ needs.extract-ghc-version.outputs.ghc-version }} on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
needs: extract-ghc-version | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- macOS-latest | |
env: | |
GHC_VERSION: ${{ needs.extract-ghc-version.outputs.ghc-version }} | |
steps: | |
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-799466911 | |
- name: Checkout PR | |
uses: actions/checkout@v4 | |
if: ${{ github.event_name == 'pull_request_target' }} | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
if: ${{ github.event_name != 'pull_request_target' }} | |
- name: Free disk space (Linux only) | |
if: ${{ runner.os == 'Linux' }} | |
uses: jlumbroso/free-disk-space@main | |
- name: Set nixpkgs url | |
id: nix-path | |
run: | | |
echo "nixpkgs=$(jq -r .nixpkgs.url ./nix/sources.json)" | tee -a $GITHUB_OUTPUT | |
- name: Install Nix | |
uses: cachix/install-nix-action@v30 | |
with: | |
nix_path: nixpkgs=${{ steps.nix-path.outputs.nixpkgs }} | |
extra_nix_config: | | |
log-lines = 1000 | |
- name: Install and authorise Cachix | |
uses: cachix/cachix-action@v15 | |
with: | |
name: nixkell | |
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" | |
- name: Nix Shell | |
run: | | |
nix-shell --run "echo OK" | |
- name: Treefmt (Linux only) | |
if: ${{ runner.os == 'Linux' }} | |
run: | | |
nix-shell --run "treefmt --ci --on-unmatched=debug --config-file treefmt-ci.toml --tree-root ." | |
- name: GHC version | |
run: | | |
echo "Using GHC version $GHC_VERSION" | |
- name: Build | |
run: | | |
nix-build ./nix/release.nix --argstr compiler "$GHC_VERSION" | |
- name: Run | |
run: | | |
result/bin/nixkell |