Skip to content

chore: fix nix build on macos and address space on gh runner #1543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 13, 2025
Merged
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
22 changes: 21 additions & 1 deletion .github/workflows/testinfra-nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ jobs:

- uses: DeterminateSystems/nix-installer-action@main

- name: Clean Nix store before build
run: |
sudo nix-collect-garbage -d || true
sudo nix-store --optimize || true
df -h / # Display available space

- name: Set PostgreSQL versions
id: set-versions
run: |
Expand Down Expand Up @@ -80,13 +86,27 @@ jobs:
packer init amazon-arm64-nix.pkr.hcl
GIT_SHA=${{github.sha}}
packer build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" -var "ansible_arguments=" -var "postgres-version=${{ steps.random.outputs.random_string }}" -var "region=ap-southeast-1" -var 'ami_regions=["ap-southeast-1"]' -var "force-deregister=true" -var "ansible_arguments=-e postgresql_major=${POSTGRES_MAJOR_VERSION}" amazon-arm64-nix.pkr.hcl


- name: Clean up after AMI stage 1
if: always() # Run even if previous steps fail
run: |
sudo nix-collect-garbage -d # Delete old generations of all profiles
sudo rm -rf /tmp/* # Clean temporary files
df -h / # Display available space

- name: Build AMI stage 2
run: |
packer init stage2-nix-psql.pkr.hcl
GIT_SHA=${{github.sha}}
packer build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var "postgres_major_version=${POSTGRES_MAJOR_VERSION}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" -var "postgres-version=${{ steps.random.outputs.random_string }}" -var "region=ap-southeast-1" -var 'ami_regions=["ap-southeast-1"]' -var "force-deregister=true" -var "git_sha=${GITHUB_SHA}" stage2-nix-psql.pkr.hcl

- name: Clean up after AMI stage 2
if: always() # Run even if previous steps fail
run: |
sudo nix-collect-garbage -d # Delete old generations of all profiles
sudo rm -rf /tmp/* # Clean temporary files
df -h / # Display available space

- name: Run tests
timeout-minutes: 10
env:
Expand Down
14 changes: 12 additions & 2 deletions nix/ext/wrappers/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,21 @@ buildPgrxExtension_0_12_9 rec {

NIX_LDFLAGS = "-L${postgresql}/lib -lpq";

# Set necessary environment variables for pgrx
# Set necessary environment variables for pgrx in darwin only
env = lib.optionalAttrs stdenv.isDarwin {
POSTGRES_LIB = "${postgresql}/lib";
RUSTFLAGS = "-C link-arg=-undefined -C link-arg=dynamic_lookup";
PGPORT = "5435";
# Calculate unique port for each PostgreSQL version:
# - Check if version contains underscore (indicating OrioleDB)
# - Add 1 to port if it's OrioleDB
# - Add 2 for each major version above 15
# Examples:
# - PostgreSQL 15.8 → 5435 + 0 + (15-15)*2 = 5435
# - PostgreSQL 17_0 (OrioleDB) → 5435 + 1 + (17-15)*2 = 5440
# - PostgreSQL 17.4 → 5435 + 0 + (17-15)*2 = 5439
PGPORT = toString (5435 +
(if builtins.match ".*_.*" postgresql.version != null then 1 else 0) + # +1 for OrioleDB
((builtins.fromJSON (builtins.substring 0 2 postgresql.version)) - 15) * 2); # +2 for each major version
};

OPENSSL_NO_VENDOR = 1;
Expand Down