From 915d568257b00f66efe6815b00fc8bc93ec9ce3e Mon Sep 17 00:00:00 2001 From: Remo Rechkemmer <59358383+monacoremo@users.noreply.github.com> Date: Sat, 17 Apr 2021 16:25:28 +0200 Subject: [PATCH] ci: Use cachix authtoken in CI (#1821) --- .circleci/config.yml | 9 ++++++++- nix/devtools.nix | 9 ++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 31939c597..b13af72af 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -140,9 +140,16 @@ jobs: command: | # Only push to the cache when CircleCI makes the CACHIX_SIGNING_KEY # available (e.g. not for pull requests). - if [ -n "${CACHIX_SIGNING_KEY:-""}" ]; then + if [ -n "${CACHIX_AUTH_TOKEN:-""}" ]; then echo "Building and caching all derivations..." + cachix authtoken "$CACHIX_AUTH_TOKEN" + + # Push new builds as we go nix-build | cachix push postgrest + + # Make sure that everything, including .drv files, is pushed + nix-env -f default.nix -iA devtools + postgrest-push-cachix else echo "Building all derivations (caching skipped for outside pull requests)..." nix-build diff --git a/nix/devtools.nix b/nix/devtools.nix index 9b1e820c8..786ca0866 100644 --- a/nix/devtools.nix +++ b/nix/devtools.nix @@ -39,13 +39,16 @@ let docs = '' Push all build artifacts to cachix. - Requires that the CACHIX_SIGNING_KEY for postgrest is set as an - environment variable. + Requires authentication with `cachix authtoken ...`. ''; inRootDir = true; } '' - nix-store -qR --include-outputs "$(nix-instantiate)" | cachix push postgrest + nix-instantiate \ + | while read -r drv; do + nix-store -qR --include-outputs "$drv" + done \ + | cachix push postgrest ''; build =