Skip to content

Commit ba5db1c

Browse files
committed
feat(pg_upgrade): use self-hosted nix installer if available
1 parent ab7f879 commit ba5db1c

File tree

1 file changed

+14
-3
lines changed
  • ansible/files/admin_api_scripts/pg_upgrade_scripts

1 file changed

+14
-3
lines changed

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ PGBINOLD="/usr/lib/postgresql/bin"
4949
PGLIBOLD="/usr/lib/postgresql/lib"
5050

5151
PG_UPGRADE_BIN_DIR="/tmp/pg_upgrade_bin/$PGVERSION"
52+
NIX_INSTALLER_PATH="/tmp/persistent/nix-installer"
53+
NIX_INSTALLER_PACKAGE_PATH="$NIX_INSTALLER_PATH.tar.gz"
5254

5355
if [ -L "$PGBINOLD/pg_upgrade" ]; then
5456
BINARY_PATH=$(readlink -f "$PGBINOLD/pg_upgrade")
@@ -283,9 +285,18 @@ function initiate_upgrade {
283285
if ! command -v nix > /dev/null; then
284286
echo "1.1. Nix is not installed; installing."
285287

286-
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm \
287-
--extra-conf "substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com" \
288-
--extra-conf "trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
288+
if [ -f "$NIX_INSTALLER_PACKAGE_PATH" ]; then
289+
echo "1.1.1. Installing Nix using the provided installer"
290+
tar -xzf "$NIX_INSTALLER_PACKAGE_PATH" -C /tmp/persistent/
291+
chmod +x "$NIX_INSTALLER_PATH"
292+
"$NIX_INSTALLER_PATH" install --no-confirm
293+
else
294+
echo "1.1.1. Installing Nix using the official installer"
295+
296+
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm \
297+
--extra-conf "substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com" \
298+
--extra-conf "trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
299+
fi
289300
else
290301
echo "1.1. Nix is installed; moving on."
291302
fi

0 commit comments

Comments
 (0)