Skip to content

Commit

Permalink
nix: Build static executable on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgangwalther committed Dec 23, 2024
1 parent 637d3ff commit dfdcd48
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
46 changes: 18 additions & 28 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,22 @@ concurrency:

jobs:
static:
name: Nix - Linux static
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- name: Linux
runs-on: ubuntu-24.04
artifact: postgrest-linux-static-x64
docker: postgrest-linux-docker-x64

- name: MacOS
runs-on: macos-14
artifact: postgrest-macos-static-x64
docker: postgrest-macos-docker-x64

name: Nix - ${{ matrix.name }} static
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Nix Environment
Expand All @@ -44,7 +58,7 @@ jobs:
- name: Save built executable as artifact
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: postgrest-linux-static-x64
name: ${{ matrix.artifact }}
path: result/bin/postgrest
if-no-files-found: error

Expand All @@ -53,35 +67,11 @@ jobs:
- name: Save built Docker image as artifact
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: postgrest-docker-x64
name: ${{ matrix.docker }}
path: postgrest-docker.tar.gz
if-no-files-found: error


macos:
name: Nix - MacOS
runs-on: macos-14
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Nix Environment
uses: ./.github/actions/setup-nix
with:
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Install gnu sed
run: brew install gnu-sed

- name: Build everything
run: |
# The --dry-run will give us a list of derivations to download from cachix and
# derivations to build. We only take those that would have to be built and then build
# those explicitly. This has the advantage that pure verification will not include
# a download anymore, making it much faster. If something needs to be built, only
# the dependencies required to do so will be downloaded, but not everything.
nix-build --dry-run 2>&1 \
| gsed -e '1,/derivations will be built:$/d' -e '/paths will be fetched/Q' \
| xargs nix-build
stack:
strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ jobs:
- name: Download Docker image
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: postgrest-docker-x64
name: postgrest-linux-docker-x64
- name: Publish images on Docker Hub
run: |
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ rec {
inherit (pkgs.haskell.packages."${compiler}") hpc-codecov;
inherit (pkgs.haskell.packages."${compiler}") weeder;
};
} // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux rec {

# Static executable.
inherit (staticHaskellPackage) postgrestStatic;
inherit (staticHaskellPackage) packagesStatic;
Expand Down

0 comments on commit dfdcd48

Please sign in to comment.