Skip to content

Installer

Installer #801

Workflow file for this run

name: Installer
on:
workflow_run:
workflows:
- Nix
branches:
- main
types:
- completed
workflow_dispatch:
concurrency: installer
jobs:
populate:
name: Populate Build Matrix
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
outputs:
hosts: ${{ steps.identify.outputs.hosts }}
filenames: ${{ steps.identify.outputs.filenames }}
start: ${{ steps.identify.outputs.start }}
steps:
- uses: cachix/install-nix-action@v25
with:
extra_nix_config: |
system-features = benchmark big-parallel kvm nixos-test
- uses: cachix/cachix-action@v14
with:
name: foosteros
- uses: actions/checkout@v4
- id: identify
name: Identify hosts capable of being built into an installer
run: |
hosts="$(nix -vL eval .#nixosConfigurations --apply builtins.attrNames --json | jq -r '.[]')"
buildHosts=""
buildFilenames=""
for host in $hosts; do
if nix -vL eval .#nixosConfigurations."$host".config.system.build.installer.outPath &>/dev/null \
&& [ "$(nix -vL eval --raw .#nixosConfigurations."$host".pkgs.stdenv.hostPlatform.uname.processor)" = "$(uname -m)" ]; then
buildHosts="$(printf '%s\n%s\n' "$buildHosts" "$host")"
filename="$(nix -vL --show-trace eval --raw .#nixosConfigurations."$host".config.system.build.installer.name)"
buildFilenames="$(printf '%s\n%s\n' "$buildFilenames" "$filename")"
fi
done
echo "hosts=$(echo "$buildHosts" | jq --null-input --raw-input --compact-output '[inputs | select(length>0)]')" >> $GITHUB_OUTPUT
echo "filenames=$(echo "$buildFilenames" | jq --null-input --raw-input --compact-output '[inputs | select(length>0)]')" >> $GITHUB_OUTPUT
echo "start=$(date +%s)" >> $GITHUB_OUTPUT
build:
name: 'Build Installer: ${{ matrix.host }}'
needs: [populate]
runs-on: ubuntu-latest
outputs:
filename: ${{ steps.build.outputs.filename }}
strategy:
matrix:
host: ${{ fromJSON(needs.populate.outputs.hosts) }}
steps:
# TODO: re-eval once easimon/maximize-build-space#20 is fixed and merged
- uses: easimon/maximize-build-space@v10
#- uses: thiagokokada/maximize-build-space@remove-large-packages
with:
build-mount-path: '/nix'
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
#remove-large-packages: 'true'
- uses: cachix/install-nix-action@v25
with:
extra_nix_config: |
system-features = benchmark big-parallel kvm nixos-test
- uses: cachix/cachix-action@v14
with:
name: foosteros
- uses: actions/checkout@v4
- id: build
name: Build ISO
env:
HOST: ${{ matrix.host }}
run: |
nix -vL --show-trace build ".#nixosConfigurations.$HOST.config.system.build.installer"
echo "filename=$(nix -vL --show-trace eval --raw ".#nixosConfigurations.$HOST.config.system.build.installer.name")" >> $GITHUB_OUTPUT
- name: Deploy ISO to website
env:
SFTP_HOST: ${{ secrets.SFTP_HOST }}
SFTP_USER: ${{ secrets.SFTP_USER }}
SFTP_KEY: ${{ secrets.REPO_KEY }}
SFTP_PATH: ${{ secrets.SFTP_PATH }}
FILENAME: ${{ steps.build.outputs.filename }}
run: |
sftp_key="$(mktemp)"
printenv SFTP_KEY >"$sftp_key"
nix run nixpkgs#rclone -- copyto --sftp-host "$SFTP_HOST" --sftp-user "$SFTP_USER" --sftp-key-file "$sftp_key" --sftp-set-modtime=false --copy-links ./result :sftp:"$SFTP_PATH"/"$FILENAME"
sync:
name: 'Sync Deployment'
needs: [populate, build]
runs-on: ubuntu-latest
steps:
- uses: cachix/install-nix-action@v25
with:
extra_nix_config: |
system-features = benchmark big-parallel kvm nixos-test
- uses: cachix/cachix-action@v14
with:
name: foosteros
- uses: actions/checkout@v4
- name: Remove old files
env:
SFTP_HOST: ${{ secrets.SFTP_HOST }}
SFTP_USER: ${{ secrets.SFTP_USER }}
SFTP_KEY: ${{ secrets.REPO_KEY }}
SFTP_PATH: ${{ secrets.SFTP_PATH }}
START_TIME: ${{ needs.populate.outputs.start }}
run: |
sftp_key="$(mktemp)"
printenv SFTP_KEY >"$sftp_key"
nix run nixpkgs#rclone -- delete --sftp-host "$SFTP_HOST" --sftp-user "$SFTP_USER" --sftp-key-file "$sftp_key" --min-age "$(expr "$(date +%s)" - "$START_TIME")s" :sftp:"$SFTP_PATH/"