feat(nix): mkSystem, mkHome and dotswitch #103
Workflow file for this run
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: Comment diff in PR | |
permissions: | |
pull-requests: write | |
on: | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- .github/workflows/** | |
- "**.nix" | |
- "flake.lock" | |
jobs: | |
build: | |
if: github.head_ref == 'update_flake_lock_action' | |
name: "Build ${{ matrix.target }}" | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-latest | |
target: william | |
- os: ubuntu-latest | |
target: nixos-local | |
- os: macos-latest | |
target: william-alt | |
- os: macos-latest | |
target: macos-local | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install nix | |
uses: cachix/install-nix-action@V27 | |
with: | |
install_url: https://releases.nixos.org/nix/nix-2.18.2/install | |
extra_nix_config: | | |
experimental-features = nix-command flakes | |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
accept-flake-config = true | |
- uses: cachix/cachix-action@v15 | |
with: | |
name: williamhsieh | |
extraPullNames: nix-community | |
skipPush: true | |
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
- name: Garbage collect build dependencies | |
run: nix-collect-garbage | |
- name: Fetch old system profile | |
run: nix build github:WilliamHsieh/dotfiles#top.${{ matrix.target }} -v --log-format raw --profile ./old-profile | |
- name: Add new system to profile | |
run: | | |
set -o pipefail | |
nix build .#top.${{ matrix.target }} --profile ./new-profile --show-trace --fallback -v --log-format raw > >(tee stdout.log) 2> >(tee /tmp/nix-build-err.log >&2) | |
- name: Output build failure | |
if: failure() | |
run: | | |
drv=$(grep "For full logs, run" /tmp/nix-build-err.log | grep -oE "/nix/store/.*.drv") | |
if [ -n $drv ]; then | |
nix log $drv | |
echo $drv | |
fi | |
exit 1 | |
- name: Diff profile | |
id: diff | |
run: | | |
echo "diff<<EOF" >> "${GITHUB_OUTPUT}" | |
nix run nixpkgs#nvd diff ./old-profile ./new-profile >> "${GITHUB_OUTPUT}" | |
echo "EOF" >> "${GITHUB_OUTPUT}" | |
- name: Comment report in pr | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
hide_and_recreate: true | |
hide_classify: "OUTDATED" | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
header: ".#top.${{ matrix.target }}" | |
message: | | |
### Report for `${{ matrix.target }}` | |
<details> | |
<summary> Version changes </summary> <br> | |
<pre> ${{ steps.diff.outputs.diff }} </pre> | |
</details> |