-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (125 loc) · 5.94 KB
/
installer.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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/"