Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/update-crush-settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Update Crush Settings

on:
schedule:
# Run daily at 3:00 UTC
- cron: "0 3 * * *"
workflow_dispatch: # Allow manual triggering

jobs:
update-schema:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Install nix
uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.21"

- name: Generate options from schema
run: |
cd scripts && go generate

- name: Format with alejandra
run: |
nix-shell -p alejandra --run "alejandra modules/crush/options/settings.nix"

- name: Check for changes
id: check_changes
run: |
if git diff --quiet modules/crush/options.nix; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi

- name: Open pull request
if: steps.check_changes.outputs.changed == 'true'
uses: peter-evans/create-pull-request@v7
with:
commit-message: "chore: update crush schema options"
title: "Update Crush schema options"
body: |
This PR updates the Crush module options from the latest schema.

Generated automatically by the daily schema update workflow.
branch: "update-crush-schema"
base: "master"
delete-branch: true
23 changes: 23 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Scripts

## Crush module options generator

Generates Nix module options from the Crush JSON schema.

### Usage

```bash
cd scripts && go generate
```

The generator automatically fetches the version from `pkgs/crush/default.nix` and downloads the corresponding schema from GitHub.

You can also run it manually:

```bash
go run scripts/generate-crush-settings.go -output modules/crush/options/settings.nix
```

### Automatic updates

A GitHub Actions workflow runs daily at 3:00 UTC to check for schema updates and automatically opens a PR if changes are detected.
4 changes: 4 additions & 0 deletions scripts/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Package main generates Nix module options from Crush schema.
//
//go:generate sh -c "cd .. && go run scripts/generate-crush-settings.go -output modules/crush/options/settings.nix"
package main
Loading