Installer #1066
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
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: DeterminateSystems/nix-installer-action@v16 | |
with: | |
diagnostic-endpoint: '' | |
source-url: 'https://install.lix.systems/lix/lix-installer-x86_64-linux' | |
- uses: cachix/cachix-action@v15 | |
with: | |
name: foosteros | |
extraPullNames: cosmic | |
- 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: | |
- name: Free up runner space | |
run: | | |
# large docker images | |
sudo docker image prune --all --force | |
# large packages | |
sudo apt-get purge -y '^llvm-.*' 'php.*' '^mongodb-.*' '^mysql-.*' azure-cli google-cloud-cli google-chrome-stable firefox powershell microsoft-edge-stable | |
sudo apt-get autoremove -y | |
sudo apt-get clean | |
# large folders | |
sudo rm -rf /var/lib/apt/lists/* /opt/hostedtoolcache /usr/local/games /usr/local/sqlpackage /usr/local/.ghcup /usr/local/share/powershell /usr/local/share/edge_driver /usr/local/share/gecko_driver /usr/local/share/chromium /usr/local/share/chromedriver-linux64 /usr/local/share/vcpkg /usr/local/lib/python* /usr/local/lib/node_modules /usr/local/julia* /opt/mssql-tools /etc/skel /usr/share/vim /usr/share/postgresql /usr/share/man /usr/share/apache-maven-* /usr/share/R /usr/share/alsa /usr/share/miniconda /usr/share/grub /usr/share/gradle-* /usr/share/locale /usr/share/texinfo /usr/share/kotlinc /usr/share/swift /usr/share/doc /usr/share/az_9.3.0 /usr/share/sbt /usr/share/ri /usr/share/icons /usr/share/java /usr/share/fonts /usr/lib/google-cloud-sdk /usr/lib/jvm /usr/lib/mono /usr/lib/R /usr/lib/postgresql /usr/lib/heroku /usr/lib/gcc | |
- uses: easimon/maximize-build-space@v10 | |
with: | |
build-mount-path: '/nix' | |
build-mount-path-ownership: 'root:root' | |
root-reserve-mb: '10240' | |
swap-size-mb: '5120' | |
- uses: DeterminateSystems/nix-installer-action@v16 | |
with: | |
diagnostic-endpoint: '' | |
source-url: 'https://install.lix.systems/lix/lix-installer-x86_64-linux' | |
- uses: cachix/cachix-action@v15 | |
with: | |
name: foosteros | |
extraPullNames: cosmic | |
- 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: DeterminateSystems/nix-installer-action@v16 | |
with: | |
diagnostic-endpoint: '' | |
source-url: 'https://install.lix.systems/lix/lix-installer-x86_64-linux' | |
- uses: cachix/cachix-action@v15 | |
with: | |
name: foosteros | |
extraPullNames: cosmic | |
- 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/" |