Skip to content

Commit 18bf547

Browse files
authored
chore: introduce a darwin builder just for the nix build (#1180)
* chore: introduce a darwin builder just for the nix build * fix: feed int he right dir * fix: sed syntax for macos * fix: perms * fix: macos shebang * chore: install nix * fix: get nix on PATH * fix: dealing with docker vs non-docker * fix: limit cpu usage --------- Co-authored-by: Sam Rose <[email protected]>
1 parent f5543cd commit 18bf547

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

.github/workflows/nix-build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
arch: amd64
2323
- runner: arm-runner
2424
arch: arm64
25+
- runner: macos-latest
26+
arch: arm64
2527
runs-on: ${{ matrix.runner }}
2628

2729
steps:
@@ -45,17 +47,36 @@ jobs:
4547
env:
4648
NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }}
4749
- name: Log in to Docker Hub
50+
if: matrix.runner != 'macos-latest'
4851
uses: docker/login-action@v2
4952
with:
5053
username: ${{ secrets.DOCKER_USERNAME }}
5154
password: ${{ secrets.DOCKER_PASSWORD }}
5255
- name: Build psql bundle with nix
56+
if: matrix.runner != 'macos-latest'
5357
run: docker build -t base_nix -f docker/nix/Dockerfile .
5458
- name: Run build psql bundle
59+
if: matrix.runner != 'macos-latest'
5560
run: |
5661
docker run -e AWS_ACCESS_KEY_ID=${{ env.AWS_ACCESS_KEY_ID }} \
5762
-e AWS_SECRET_ACCESS_KEY=${{ env.AWS_SECRET_ACCESS_KEY }} \
5863
-e AWS_SESSION_TOKEN=${{ env.AWS_SESSION_TOKEN }} \
5964
base_nix bash -c "./workspace/docker/nix/build_nix.sh"
65+
- name: Build psql bundle on macos
66+
if: matrix.runner == 'macos-latest'
67+
run: |
68+
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm \
69+
--extra-conf "substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com" \
70+
--extra-conf "trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
71+
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
72+
cp ./docker/nix/build_nix.sh ./build_nix.sh
73+
sed -i '' '1s|^#!/bin/env bash|#!/usr/bin/env bash|' ./build_nix.sh
74+
chmod +x ./build_nix.sh
75+
./build_nix.sh
76+
env:
77+
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
78+
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
79+
AWS_SESSION_TOKEN: ${{ env.AWS_SESSION_TOKEN }}
80+
6081
name: build psql bundle on ${{ matrix.arch }}
6182

docker/nix/build_nix.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
set -eou pipefail
33

44
nix --version
5-
cd /workspace
5+
if [ -d "/workspace" ]; then
6+
cd /workspace
7+
fi
68
nix build .#psql_15/bin -o psql_15
79
nix flake check -L
810
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_15

nix/ext/wrappers/default.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ buildPgrxExtension_0_11_3 rec {
3030
darwin.apple_sdk.frameworks.SystemConfiguration
3131
];
3232
OPENSSL_NO_VENDOR = 1;
33-
33+
#need to set this to 2 to avoid cpu starvation
34+
CARGO_BUILD_JOBS = "2";
3435
CARGO="${cargo}/bin/cargo";
3536
cargoLock = {
3637
lockFile = "${src}/Cargo.lock";

0 commit comments

Comments
 (0)