@@ -3,8 +3,105 @@ description: "This action sets up a nix devshell environment"
33runs :
44 using : " composite"
55 steps :
6+ # Adapted from: https://github.com/reitermarkus/dotfiles/blob/349cf6c0aff2ab8666247904779b788a14b99fa0/.github/workflows/ci.yml#L39-L190
7+ - name : Clean environment
8+ shell : bash
9+ run : |
10+ set -euo pipefail
11+
12+ # Uninstall Homebrew Casks
13+ if which brew &>/dev/null; then
14+ eval "$(brew list --cask | xargs -I% echo '{ brew uninstall --cask --force "%"; brew uninstall --cask --zap --force "%"; } &')"
15+ wait
16+ fi
17+
18+ sudo rm -rf /usr/local/miniconda &
19+ rm -rf /usr/local/lib/node_modules &
20+ rm -f /usr/local/bin/terminal-notifier
21+ rm -f /usr/local/bin/change_hostname.sh
22+ rm -f /usr/local/bin/azcopy
23+ wait
24+
25+ # Clean environment.
26+ for trash in ~/.DS_Store \
27+ ~/.Trash/* \
28+ ~/.aliyun \
29+ ~/.android \
30+ ~/.azcopy \
31+ ~/.azure \
32+ ~/.bash_history \
33+ ~/.bash_profile \
34+ ~/.bash_sessions \
35+ ~/.bashrc \
36+ ~/.cabal \
37+ ~/.cache \
38+ ~/.cargo \
39+ ~/.cocoapods \
40+ ~/.composer \
41+ ~/.conda \
42+ ~/.config \
43+ ~/.dotnet \
44+ ~/.fastlane \
45+ ~/.gem \
46+ ~/.ghcup \
47+ ~/.gitconfig \
48+ ~/.gradle \
49+ ~/.local \
50+ ~/.m2 \
51+ ~/.mono \
52+ ~/.npm \
53+ ~/.npmrc \
54+ ~/.nvm \
55+ ~/.oracle_jre_usage \
56+ ~/.packer.d \
57+ ~/.rustup \
58+ ~/.sh_history \
59+ ~/.ssh \
60+ ~/.subversion \
61+ ~/.sqlite_history \
62+ ~/.vcpkg \
63+ ~/.viminfo \
64+ ~/.wget-hsts \
65+ ~/.yarn \
66+ ~/Library/Caches/Homebrew \
67+ ~/Microsoft \
68+ ~/hostedtoolcache \
69+ ~/*.txt; do
70+ if [[ -e "$trash" ]]; then
71+ rm -rf "$trash"
72+ fi
73+ done
74+
75+ # Delete broken symlinks.
76+ for exe in /usr/local/bin/*; do
77+ if [[ -L "$exe" ]] && ! [[ -e "$exe" ]]; then
78+ rm "$exe"
79+ fi
80+ done
81+
682 - name : Setup Nix
7- uses : DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d # v16
83+ uses : nixbuild/nix-quick-install-action@5bb6a3b3abe66fd09bbf250dce8ada94f856a703 # v30
84+
85+ - uses : nix-community/cache-nix-action@92aaf15ec4f2857ffed00023aecb6504bb4a5d3d # v6
86+ with :
87+ # restore and save a cache using this key
88+ primary-key : nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
89+ # if there's no cache hit, restore a cache by this prefix
90+ restore-prefixes-first-match : nix-${{ runner.os }}-
91+ # collect garbage until Nix store size (in bytes) is at most this number
92+ # before trying to save a new cache
93+ # 1 GB = 1073741824 B
94+ gc-max-store-size-linux : 1073741824
95+ # do purge caches
96+ purge : true
97+ # purge all versions of the cache
98+ purge-prefixes : nix-${{ runner.os }}-
99+ # created more than this number of seconds ago relative to the start of the `Post Restore` phase
100+ purge-created : 0
101+ # except the version with the `primary-key`, if it exists
102+ purge-primary-key : never
8103
9104 - name : Enter devshell
10105 uses : nicknovitski/nix-develop@9be7cfb4b10451d3390a75dc18ad0465bed4932a # v1.2.1
106+ with :
107+ arguments : " .#ci"
0 commit comments