-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Publish Docker Image | ||
|
||
on: | ||
push: | ||
tags: | ||
- '**[0-9]+.[0-9]+.[0-9]+*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-24.04 | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
env: | ||
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: DeterminateSystems/nix-installer-action@main | ||
- uses: DeterminateSystems/magic-nix-cache-action@main | ||
|
||
- name: Deploy Docker Image | ||
run: nix run .#deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{ | ||
pkgs, | ||
cargo-pgrx, | ||
postgresql, | ||
}: | ||
|
||
let | ||
postgresMajor = pkgs.lib.versions.major postgresql.version; | ||
|
||
preBuildAndTest = '' | ||
export PGRX_HOME=$(mktemp -d) | ||
mkdir -p $PGRX_HOME/${postgresMajor} | ||
cp -r -L ${postgresql}/. $PGRX_HOME/${postgresMajor}/ | ||
chmod -R ugo+w $PGRX_HOME/${postgresMajor} | ||
cp -r -L ${postgresql.lib}/lib/. $PGRX_HOME/${postgresMajor}/lib/ | ||
${cargo-pgrx}/bin/cargo-pgrx pgrx init \ | ||
--pg${postgresMajor} $PGRX_HOME/${postgresMajor}/bin/pg_config | ||
''; | ||
|
||
filterCargoSources = | ||
orig_path: type: | ||
let | ||
path = (toString orig_path); | ||
base = baseNameOf path; | ||
parentDir = baseNameOf (dirOf path); | ||
|
||
matchesSuffix = pkgs.lib.any (suffix: pkgs.lib.hasSuffix suffix base) [ | ||
".rs" | ||
".toml" | ||
".control" | ||
]; | ||
|
||
# Cargo.toml already captured above | ||
isCargoFile = base == "Cargo.lock"; | ||
|
||
# .cargo/config.toml already captured above | ||
isCargoConfig = parentDir == ".cargo" && base == "config"; | ||
in | ||
(type == "directory") || matchesSuffix || isCargoFile || isCargoConfig; | ||
in | ||
pkgs.rustPlatform.buildRustPackage { | ||
pname = "pglite-fusion"; | ||
version = "0.0.0"; | ||
|
||
src = pkgs.lib.cleanSourceWith { | ||
src = pkgs.lib.cleanSource ../.; | ||
filter = filterCargoSources; | ||
}; | ||
cargoLock.lockFile = ../Cargo.lock; | ||
|
||
doCheck = false; | ||
buildNoDefaultFeatures = true; | ||
buildFeatures = [ "pg${postgresMajor}" ]; | ||
|
||
preBuild = preBuildAndTest; | ||
preCheck = preBuildAndTest; | ||
postPatch = "patchShebangs ."; | ||
|
||
postBuild = '' | ||
if [ -f "pglite_fusion.control" ]; then | ||
export NIX_PGLIBDIR=${postgresql.out}/share/postgresql/extension/ | ||
${cargo-pgrx}/bin/cargo-pgrx pgrx package --pg-config ${postgresql}/bin/pg_config --out-dir the-thing | ||
export NIX_PGLIBDIR=$PGRX_HOME/${postgresMajor}/lib | ||
fi | ||
''; | ||
|
||
preFixup = '' | ||
if [ -f "pglite_fusion.control" ]; then | ||
${cargo-pgrx}/bin/cargo-pgrx pgrx stop all | ||
rm -rfv $out/target* | ||
fi | ||
''; | ||
|
||
installPhase = '' | ||
cp -rp the-thing $out | ||
''; | ||
|
||
nativeBuildInputs = [ | ||
postgresql | ||
pkgs.rustfmt | ||
postgresql.lib | ||
pkgs.pkg-config | ||
pkgs.rustPlatform.bindgenHook | ||
]; | ||
|
||
PGRX_PG_SYS_SKIP_BINDING_REWRITE = "1"; | ||
} |