Skip to content

Commit 1096e01

Browse files
authored
chore: fix nix build on macos and address space on gh runner (#1543)
* chore: fix nix build on macos and address space on gh runner * chore: special handling for oriole * chore: permissions * chore: make sure permission to run is granted
1 parent d0655d2 commit 1096e01

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

.github/workflows/testinfra-nix.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ jobs:
1919

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

22+
- name: Clean Nix store before build
23+
run: |
24+
sudo nix-collect-garbage -d || true
25+
sudo nix-store --optimize || true
26+
df -h / # Display available space
27+
2228
- name: Set PostgreSQL versions
2329
id: set-versions
2430
run: |
@@ -80,13 +86,27 @@ jobs:
8086
packer init amazon-arm64-nix.pkr.hcl
8187
GIT_SHA=${{github.sha}}
8288
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
83-
89+
90+
- name: Clean up after AMI stage 1
91+
if: always() # Run even if previous steps fail
92+
run: |
93+
sudo nix-collect-garbage -d # Delete old generations of all profiles
94+
sudo rm -rf /tmp/* # Clean temporary files
95+
df -h / # Display available space
96+
8497
- name: Build AMI stage 2
8598
run: |
8699
packer init stage2-nix-psql.pkr.hcl
87100
GIT_SHA=${{github.sha}}
88101
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
89102
103+
- name: Clean up after AMI stage 2
104+
if: always() # Run even if previous steps fail
105+
run: |
106+
sudo nix-collect-garbage -d # Delete old generations of all profiles
107+
sudo rm -rf /tmp/* # Clean temporary files
108+
df -h / # Display available space
109+
90110
- name: Run tests
91111
timeout-minutes: 10
92112
env:

nix/ext/wrappers/default.nix

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,21 @@ buildPgrxExtension_0_12_9 rec {
3838

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

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

4858
OPENSSL_NO_VENDOR = 1;

0 commit comments

Comments
 (0)