Skip to content

Commit

Permalink
Use Nix
Browse files Browse the repository at this point in the history
  • Loading branch information
jwillikers committed Sep 27, 2024
1 parent 67cec11 commit 66ff6b5
Show file tree
Hide file tree
Showing 24 changed files with 684 additions and 28 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
47 changes: 47 additions & 0 deletions .github/workflows/build-attiny85.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build ATtiny85

"on":
pull_request:
branches: ["main"]
paths:
- .github/workflows/build-attiny85.yaml
- boards/attiny85/flake.lock
- boards/attiny85/flake.nix
- boards/attiny85/.cargo/**
- boards/attiny85/.justfile
- boards/attiny85/src/**
- boards/attiny85/avr-unknown-none-attiny85.json
- boards/attiny85/Cargo.lock
- boards/attiny85/Cargo.toml
- boards/attiny85/rust-toolchain.toml
push:
branches: ["main"]
paths:
- .github/workflows/build-attiny85.yaml
- boards/attiny85/flake.lock
- boards/attiny85/flake.nix
- boards/attiny85/.cargo/**
- boards/attiny85/.justfile
- boards/attiny85/src/**
- boards/attiny85/avr-unknown-none-attiny85.json
- boards/attiny85/Cargo.lock
- boards/attiny85/Cargo.toml
- boards/attiny85/rust-toolchain.toml
workflow_dispatch:

jobs:
build-attiny85:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Build
run: cd boards/attiny85; nix develop --command just build release
- name: Upload firmware
uses: actions/upload-artifact@v4
with:
name: attiny85-pwm-fan-controller
path: |
target/avr-unknown-none-attiny85/release/attiny85-pwm-fan-controller.elf
attiny85-pwm-fan-controller.hex
30 changes: 30 additions & 0 deletions .github/workflows/cargo-lock-updater.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Cargo Lock Updater

"on":
schedule:
# Once a month on the 5th
- cron: "0 0 5 * *"
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
cargo-lock-updater:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Update ATtiny85 Cargo lock file
run: cd boards/attiny85; nix develop --command cargo update
- name: Update Pico Cargo lock file
run: cd boards/pico; nix develop --command cargo update
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
assignees: ${{ github.repository_owner }}
branch: "update/cargo-lock"
commit-message: "chore(deps): Update Cargo lock files"
title: "chore(deps): Update Cargo lock files"
18 changes: 18 additions & 0 deletions .github/workflows/clippy-attiny85.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lint Rust code with Clippy
"on":
pull_request:
branches: ["main"]
paths:
- .github/workflows/clippy-attiny85.yaml
- boards/attiny85/flake.lock
- boards/attiny85/**.rs

jobs:
clippy-attiny85:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Lint Rust code with Clippy
run: cd boards/attiny85; nix develop --command cargo clippy
14 changes: 14 additions & 0 deletions .github/workflows/flake-checker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Check Nix Flake
"on":
pull_request:
branches: ["main"]
paths:
- .github/workflows/flake-checker.yaml
- '**/flake.lock'

jobs:
flake-checker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/flake-checker-action@v9
25 changes: 25 additions & 0 deletions .github/workflows/flake-lock-updater.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Flake ❄️ Lock 🔒️ Updater ✨

"on":
schedule:
# Pi o'clock
- cron: '3 14 * * 1,5'
workflow_dispatch:

jobs:
lock-updater:
name: Flake Lock Updater
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- uses: DeterminateSystems/update-flake-lock@v24
with:
pr-title: "chore: update flake.lock"
# Labels to be set on the PR
pr-labels: |
dependencies
automated
19 changes: 19 additions & 0 deletions .github/workflows/format-just.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Format justfiles
"on":
pull_request:
branches: ["main"]
paths:
- .github/workflows/format-just.yaml
- '**/flake.lock'
- '**/.justfile'
- '**/justfile'

jobs:
format-just:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Format justfile
run: cd boards/attiny85; nix develop --command just --check --fmt --unstable ../..
30 changes: 30 additions & 0 deletions .github/workflows/pre-commit-autoupdate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Pre-commit auto-update

"on":
schedule:
# Once a month on the 2nd
- cron: "0 0 2 * *"
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
pre-commit-autoupdate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Update pre-commit hooks
run: nix develop --command pre-commit autoupdate
- name: Run pre-commit hooks
run: nix develop --command pre-commit run --all-files
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
assignees: ${{ github.repository_owner }}
branch: "update/pre-commit-hooks"
commit-message: "chore(deps): Update pre-commit hooks"
title: "chore(deps): Update pre-commit hooks"
18 changes: 18 additions & 0 deletions .github/workflows/rustfmt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Format Rust code
"on":
pull_request:
branches: ["main"]
paths:
- .github/workflows/rustfmt.yaml
- '**/flake.lock'
- '**.rs'

jobs:
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Check Rust formatting
run: cd boards/attiny85; nix develop --command nu --commands 'rustfmt --check ../../**/*.rs'
20 changes: 20 additions & 0 deletions .github/workflows/yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: yamllint
"on":
pull_request:
branches: ["main"]
paths:
- .github/workflows/yamllint.yaml
- .yamllint.yaml
- '**/flake.lock'
- '**.yaml'
- '**.yml'

jobs:
yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Check YAML files
run: cd boards/attiny85; nix develop --command yamllint --format github ../..
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ target/

# Ignore any built binaries.
*.bin
*.hex

*.jpg~
*.jpg-autosave.kra

# direnv
.direnv/

# Nix
result/
60 changes: 60 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
exclude: |
(?x)^(
.idea/.*|
.run/.*|
.vscode/.*
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-byte-order-marker
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
args: [--allow-multiple-documents]
- id: end-of-file-fixer
- id: mixed-line-ending
- id: pretty-format-json
args: ["--autofix"]
exclude: ^.vscode/.*\.json$
- id: trailing-whitespace
- repo: local
hooks:
- id: just
entry: just --fmt --unstable
files: |
(?x)^(
.justfile|
justfile
)$
language: system
name: just
pass_filenames: false
- id: rustfmt
name: rustfmt
description: Format Rust files with rustfmt.
entry: rustfmt
pass_filenames: true
types: [file, rust]
language: system
- id: rust-clippy-attiny85
name: Rust clippy ATtiny85
description: Run cargo clippy on files included in the commit.
entry: cargo -C boards/attiny85 clippy --all-targets --all-features -- -Dclippy::all
pass_filenames: false
types: [file, rust]
language: system
# - id: rust-clippy-pico
# name: Rust clippy Pico
# description: Run cargo clippy on files included in the commit.
# entry: cargo -C boards/pico clippy --all-targets --all-features -- -Dclippy::all
# pass_filenames: false
# types: [file, rust]
# language: system
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@
"Asciidoctor",
"assumeyes",
"attiny",
"autofix",
"avrdude",
"binutils",
"BOOTSEL",
"Boxall",
"clippy",
"Datasheet",
"Dclippy",
"devel",
"dialout",
"eabi",
"getent",
"ifdef",
"ifndef",
"ihex",
"justfile",
"Libc",
"libusbx",
"microcontroller",
Expand All @@ -30,6 +36,7 @@
"Pinouts",
"proto",
"Protoboard",
"rustfmt",
"rustup",
"SWCLK",
"SWDIO",
Expand All @@ -38,6 +45,7 @@
"tlsv",
"UART",
"udev",
"usermod",
"VBUS"
]
}
6 changes: 6 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends: default

rules:
document-start: disable
document-end: disable
line-length: disable
4 changes: 2 additions & 2 deletions boards/attiny85/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[build]
target = "avr-specs/avr-attiny85.json"
target = "avr-unknown-none-attiny85.json"

#[target.'cfg(target_arch = "avr")']
# ravedude doesn't support running from an AVR USB programmer like the USB uISP without code modifications.
#runner = "ravedude trinket"
# runner = "ravedude attiny85-usbtiny"

[unstable]
build-std = ["core"]
1 change: 1 addition & 0 deletions boards/attiny85/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
Loading

0 comments on commit 66ff6b5

Please sign in to comment.