mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 09:01:17 -08:00
this nix flake is heavily based off of prior work i have done in one of my repos. it comes with the following features: - building sable: `nix build .#sable` or just `nix build`. creates a `result/` dir with the built application. - devshell: nix users now no longer need to do download and install all the dependencies for sable by themselves. the devshell comes with all the dependencies needed to develop sable - checks: `nix flake check` is configured to perform all checks listed in `CONTRIBUTING.md` (fmt:check, lint, typecheck, knip, test:run) - formatting: `nix fmt` runs all the formatters pnpm would also call, but provides a more familiar interface for nix users. - pre-commit checks: nix users can benefit from having their changes checked for before the commit goes through. yay :3 `.vscode/settings.json` was updated to include hints for VS Code users using the "nix env selector" extension to auto-detect the nix dev environment, if you have nix installed. I had to change `oxfmt.config.ts` just a tiny bit to make it work with the nix stuff, because `node_modules` does not exist inside the nix build sandbox. `pnpm fmt` successfully runs, so nothing should have broken. `flake-lock-fix.yml` is a small workflow heavily based on <https://docs.determinate.systems/guides/fix-hashes/>, which triggers on pushes to `dev` which change `pnpm-lock.yaml`. The workflow uses `determinate-nixd` to fix hashes in the `flake.nix`, then pushes the changes to `dev` automatically.
47 lines
1.3 KiB
YAML
47 lines
1.3 KiB
YAML
name: Fix flake hashes
|
|
|
|
on:
|
|
push:
|
|
branches: [dev]
|
|
paths: ['pnpm-lock.yaml']
|
|
|
|
jobs:
|
|
fix:
|
|
name: Fix flake hashes
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
id-token: write
|
|
contents: write
|
|
steps:
|
|
- name: Checkout dev
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
ref: dev
|
|
persist-credentials: true
|
|
|
|
- name: Install Determinate Nix
|
|
uses: DeterminateSystems/determinate-nix-action@bafaa638b9d5ec0e7e3ac1a7fc80453ef1fd265f # v3.20.0
|
|
|
|
- id: check
|
|
run: nix flake check -L
|
|
continue-on-error: true
|
|
|
|
- name: Fix hash mismatches
|
|
if: steps.check.outcome == 'failure'
|
|
run: determinate-nixd fix hashes --auto-apply
|
|
|
|
- name: Commit and push if changed
|
|
if: steps.check.outcome == 'failure'
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
if git diff --quiet; then
|
|
echo "No changes after fix hashes; nothing to commit."
|
|
exit 0
|
|
fi
|
|
git config user.name "sable-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add --update --ignore-removal .
|
|
git commit -m "chore(nix): auto-fix nix hashes"
|
|
git push origin HEAD:dev --force-with-lease
|