Skip to content
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

Static macos #157

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 1 addition & 5 deletions .github/actions/setup-nix/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ inputs:
runs:
using: composite
steps:
- uses: nixbuild/nix-quick-install-action@60e9c39264d4714139af3cdf15f691b19eec3530 # v28
with:
nix_conf: |-
always-allow-substitutes = true
max-jobs = auto
- uses: cachix/install-nix-action@v25
- uses: cachix/cachix-action@ad2ddac53f961de1989924296a1f236fcfbaa4fc # v15
with:
name: postgrest
Expand Down
49 changes: 20 additions & 29 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-22.04
strategy:
fail-fast: false
matrix:
include:
- name: Linux
runs-on: ubuntu-22.04
artifact: postgrest-linux-static-x64
docker: postgrest-linux-docker-x64

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

name: Nix - ${{ matrix.name }} static
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Setup Nix Environment
Expand All @@ -40,11 +54,12 @@ jobs:
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Build static executable
run: nix-build -A postgrestStatic
run: |
nix-build -j6 -A postgrestStatic --keep-going 2>&1 | grep '^error: builder' -B50
- name: Save built executable as artifact
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: postgrest-linux-static-x64
name: ${{ matrix.artifact }}
path: result/bin/postgrest
if-no-files-found: error

Expand All @@ -53,35 +68,11 @@ jobs:
- name: Save built Docker image as artifact
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
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-12
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- 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@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
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 @@ -149,7 +149,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
8 changes: 4 additions & 4 deletions nix/nixpkgs-version.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Pinned version of Nixpkgs, generated with postgrest-nixpkgs-upgrade.
{
owner = "NixOS";
owner = "reckenrode";
repo = "nixpkgs";
date = "2024-04-20";
rev = "92d295f588631b0db2da509f381b4fb1e74173c5";
tarballHash = "162w28y4i5c8g5qhjvs827qxphf2a8n4c8fwhcywzl1j1a35h2im";
date = "2024-05-30";
rev = "d03d15d54445c2c8ffe78e418ac68bb8fbf285a3";
tarballHash = "sha256:0m7c7zdpw6574b8832i8pd5ssvaf5k0sbqiwwyzajgzs0ckpnb9l";
}
5 changes: 2 additions & 3 deletions nix/static.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ let
# pkgsStatic is based on musl, so is a kind of cross-compilation.
# We still make this explicit here via pkgsCross, because we need
# to get postgresql/libpq for musl, too.
pkgsCross = pkgs.pkgsCross.musl64;
inherit (pkgsCross) pkgsStatic;
inherit (pkgs) pkgsStatic;
inherit (pkgsStatic.haskell) lib;

packagesStatic =
Expand All @@ -31,7 +30,7 @@ let
configureFlags = [ "-fuse-pkg-config" ];
# postgresql doesn't build in the fully static overlay - but the default
# derivation is built with static libraries anyway.
libraryPkgconfigDepends = [ pkgsCross.libpq ];
libraryPkgconfigDepends = [ pkgs.libpq ];
librarySystemDepends = [ ];
}).overrideAttrs (_: prevAttrs: {
buildInputs = prevAttrs.buildInputs ++ [
Expand Down
Loading