setup aws profile for s3 auth
This commit is contained in:
parent
e38ed0e6f1
commit
4f1bd26064
2 changed files with 39 additions and 46 deletions
84
.github/workflows/build-machines-and-homes.yml
vendored
84
.github/workflows/build-machines-and-homes.yml
vendored
|
@ -24,17 +24,17 @@ jobs:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# - name: Maximize build disk space
|
- name: Maximize build disk space
|
||||||
# uses: easimon/maximize-build-space@v10
|
uses: easimon/maximize-build-space@v10
|
||||||
# with:
|
with:
|
||||||
# overprovision-lvm: true
|
overprovision-lvm: true
|
||||||
# swap-size-mb: 1024
|
swap-size-mb: 1024
|
||||||
# remove-dotnet: 'true'
|
remove-dotnet: 'true'
|
||||||
# remove-android: 'true'
|
remove-android: 'true'
|
||||||
# remove-haskell: 'true'
|
remove-haskell: 'true'
|
||||||
# remove-codeql: 'true'
|
remove-codeql: 'true'
|
||||||
# remove-docker-images: 'true'
|
remove-docker-images: 'true'
|
||||||
# build-mount-path: /nix
|
build-mount-path: /nix
|
||||||
|
|
||||||
- name: setup binary cache key
|
- name: setup binary cache key
|
||||||
run: echo -n "${{ secrets.NIX_CACHE_SECRET_KEY }}" | xxd -p -r > ${{ runner.temp }}/cache-priv-key.pem
|
run: echo -n "${{ secrets.NIX_CACHE_SECRET_KEY }}" | xxd -p -r > ${{ runner.temp }}/cache-priv-key.pem
|
||||||
|
@ -50,6 +50,14 @@ jobs:
|
||||||
sudo cp ci/upload-to-cache.sh /etc/nix/
|
sudo cp ci/upload-to-cache.sh /etc/nix/
|
||||||
sudo chmod +x /etc/nix/upload-to-cache.sh
|
sudo chmod +x /etc/nix/upload-to-cache.sh
|
||||||
|
|
||||||
|
- name: setup s3 credentials
|
||||||
|
run: |
|
||||||
|
sudo mkdir /root/.aws
|
||||||
|
echo "[default]" |sudo tee /root/.aws/config |sudo tee /root/.aws/credentials
|
||||||
|
echo "aws_access_key_id=$AWS_ACCESS_KEY_ID" |sudo tee -a /root/.aws/credentials
|
||||||
|
echo "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" |sudo tee -a /root/.aws/credentials
|
||||||
|
echo "endpoint_url=$AWS_ENDPOINT_URL" |sudo tee -a /root/.aws/config
|
||||||
|
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: cachix/install-nix-action@v30
|
uses: cachix/install-nix-action@v30
|
||||||
with:
|
with:
|
||||||
|
@ -64,27 +72,10 @@ jobs:
|
||||||
extra-trusted-public-keys = nixcache.cy7.sh:DN3d1dt0wnXfTH03oVmTee4KgmdNdB0NY3SuzA8Fwx8=
|
extra-trusted-public-keys = nixcache.cy7.sh:DN3d1dt0wnXfTH03oVmTee4KgmdNdB0NY3SuzA8Fwx8=
|
||||||
post-build-hook = /etc/nix/upload-to-cache.sh
|
post-build-hook = /etc/nix/upload-to-cache.sh
|
||||||
|
|
||||||
- name: debug
|
|
||||||
run: echo "$(which nix)"
|
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
run: |
|
run: |
|
||||||
# package=".#nixosConfigurations."${{ matrix.machine }}".config.system.build.toplevel"
|
|
||||||
# nix build -L "$package"
|
|
||||||
nix run nixpkgs#nixos-rebuild build -- -L --flake ".#${{ matrix.machine }}"
|
nix run nixpkgs#nixos-rebuild build -- -L --flake ".#${{ matrix.machine }}"
|
||||||
|
|
||||||
- name: cache
|
|
||||||
# https://stackoverflow.com/a/58859404
|
|
||||||
if: '!cancelled()'
|
|
||||||
run: |
|
|
||||||
package=".#nixosConfigurations."${{ matrix.machine }}".config.system.build.toplevel"
|
|
||||||
nix run github:cything/nixcp -- \
|
|
||||||
push \
|
|
||||||
--bucket nixcache \
|
|
||||||
--signing-key ${{ runner.temp }}/cache-priv-key.pem \
|
|
||||||
-u https://nix-community.cachix.org \
|
|
||||||
$package
|
|
||||||
|
|
||||||
build-homes:
|
build-homes:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
@ -113,6 +104,25 @@ jobs:
|
||||||
- name: setup binary cache key
|
- name: setup binary cache key
|
||||||
run: echo -n "${{ secrets.NIX_CACHE_SECRET_KEY }}" | xxd -p -r > ${{ runner.temp }}/cache-priv-key.pem
|
run: echo -n "${{ secrets.NIX_CACHE_SECRET_KEY }}" | xxd -p -r > ${{ runner.temp }}/cache-priv-key.pem
|
||||||
|
|
||||||
|
- name: Sync repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
|
- name: post-build-hook
|
||||||
|
run: |
|
||||||
|
sudo mkdir -p /etc/nix
|
||||||
|
sudo cp ci/upload-to-cache.sh /etc/nix/
|
||||||
|
sudo chmod +x /etc/nix/upload-to-cache.sh
|
||||||
|
|
||||||
|
- name: setup s3 credentials
|
||||||
|
run: |
|
||||||
|
sudo mkdir /root/.aws
|
||||||
|
echo "[default]" |sudo tee /root/.aws/config |sudo tee /root/.aws/credentials
|
||||||
|
echo "aws_access_key_id=$AWS_ACCESS_KEY_ID" |sudo tee -a /root/.aws/credentials
|
||||||
|
echo "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" |sudo tee -a /root/.aws/credentials
|
||||||
|
echo "endpoint_url=$AWS_ENDPOINT_URL" |sudo tee -a /root/.aws/config
|
||||||
|
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: cachix/install-nix-action@v30
|
uses: cachix/install-nix-action@v30
|
||||||
with:
|
with:
|
||||||
|
@ -125,25 +135,9 @@ jobs:
|
||||||
secret-key-files = ${{ runner.temp }}/cache-priv-key.pem
|
secret-key-files = ${{ runner.temp }}/cache-priv-key.pem
|
||||||
extra-substituters = https://nixcache.cy7.sh
|
extra-substituters = https://nixcache.cy7.sh
|
||||||
extra-trusted-public-keys = nixcache.cy7.sh:DN3d1dt0wnXfTH03oVmTee4KgmdNdB0NY3SuzA8Fwx8=
|
extra-trusted-public-keys = nixcache.cy7.sh:DN3d1dt0wnXfTH03oVmTee4KgmdNdB0NY3SuzA8Fwx8=
|
||||||
|
post-build-hook = /etc/nix/upload-to-cache.sh
|
||||||
- name: Sync repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
run: |
|
run: |
|
||||||
package=".#homeConfigurations."${{ matrix.home }}".activationPackage"
|
package=".#homeConfigurations."${{ matrix.home }}".activationPackage"
|
||||||
nix build -L "$package"
|
nix build -L "$package"
|
||||||
|
|
||||||
- name: cache
|
|
||||||
# https://stackoverflow.com/a/58859404
|
|
||||||
if: '!cancelled()'
|
|
||||||
run: |
|
|
||||||
package=".#homeConfigurations."${{ matrix.home }}".activationPackage"
|
|
||||||
nix run github:cything/nixcp -- \
|
|
||||||
push \
|
|
||||||
--bucket nixcache \
|
|
||||||
--signing-key ${{ runner.temp }}/cache-priv-key.pem \
|
|
||||||
-u https://nix-community.cachix.org \
|
|
||||||
$package
|
|
||||||
|
|
|
@ -5,5 +5,4 @@ set -eu
|
||||||
set -f # disable globbing
|
set -f # disable globbing
|
||||||
export IFS=' '
|
export IFS=' '
|
||||||
echo "Uploading paths" $OUT_PATHS
|
echo "Uploading paths" $OUT_PATHS
|
||||||
# this is where the cachix installer installs nix
|
|
||||||
exec /nix/var/nix/profiles/default/bin/nix copy --to "s3://nixcache?endpoint=s3.cy7.sh" $OUT_PATHS
|
exec /nix/var/nix/profiles/default/bin/nix copy --to "s3://nixcache?endpoint=s3.cy7.sh" $OUT_PATHS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue