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