Skip to content

Commit

Permalink
Switch to devenv
Browse files Browse the repository at this point in the history
  • Loading branch information
DanNixon committed Jan 14, 2025
1 parent cbb8293 commit f3626c5
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 131 deletions.
4 changes: 3 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
use flake
source_url "https://raw.githubusercontent.com/cachix/devenv/82c0147677e510b247d8b9165c54f73d32dfd899/direnvrc" "sha256-7u4iDd1nZpxL4tCzmPG0dQgC5V+/44Ba+tHkPob1v2k="

use devenv
39 changes: 20 additions & 19 deletions .github/workflows/control.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,39 @@ on:
branches:
- main
paths:
- 'flake.*'
- '.github/workflows/control.yml'
- 'devenv.*'
- 'control/**'
pull_request:
paths:
- 'flake.*'
- '.github/workflows/control.yml'
- 'devenv.*'
- 'control/**'

jobs:
quality:
name: Code Quality
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./control

steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: cachix/cachix-action@v15
with:
name: devenv
- name: Install devenv.sh
run: nix profile install nixpkgs#devenv

- name: Clippy
shell: devenv shell bash -- -e {0}
run: |
eval "$(nix print-dev-env)"
set -x
cd ./control
cargo clippy -- -Dwarnings
- name: Test
shell: devenv shell bash -- -e {0}
run: |
eval "$(nix print-dev-env)"
set -x
cd ./control
cargo test
build:
Expand All @@ -46,17 +47,17 @@ jobs:
needs:
- quality

defaults:
run:
working-directory: ./control

steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: cachix/cachix-action@v15
with:
name: devenv
- name: Install devenv.sh
run: nix profile install nixpkgs#devenv

- name: Build
shell: devenv shell bash -- -e {0}
run: |
eval "$(nix print-dev-env)"
set -x
cd ./control
cargo build --release
32 changes: 20 additions & 12 deletions .github/workflows/firmware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,40 @@ on:
branches:
- main
paths:
- 'flake.*'
- '.github/workflows/firmware.yml'
- 'devenv.*'
- 'firmware/**'
pull_request:
paths:
- 'flake.*'
- '.github/workflows/firmware.yml'
- 'devenv.*'
- 'firmware/**'

jobs:
quality:
name: Code Quality
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./firmware

steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: cachix/cachix-action@v15
with:
name: devenv
- name: Install devenv.sh
run: nix profile install nixpkgs#devenv

- name: Clippy
env:
WIFI_PASSWORD: super secret
MQTT_PASSWORD: lol nope
CONFIG: ./configs/test.toml
shell: devenv shell bash -- -e {0}
run: |
eval "$(nix print-dev-env)"
set -x
cd ./firmware
rustup target add thumbv6m-none-eabi
rustup show
Expand All @@ -46,10 +51,6 @@ jobs:
needs:
- quality

defaults:
run:
working-directory: ./firmware

strategy:
matrix:
config:
Expand All @@ -60,16 +61,23 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: cachix/cachix-action@v15
with:
name: devenv
- name: Install devenv.sh
run: nix profile install nixpkgs#devenv

- name: Build
env:
WIFI_PASSWORD: super secret
MQTT_PASSWORD: lol nope
CONFIG: "./configs/${{ matrix.config }}"
shell: devenv shell bash -- -e {0}
run: |
eval "$(nix print-dev-env)"
set -x
cd ./firmware
rustup target add thumbv6m-none-eabi
rustup show
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: cachix/cachix-action@v15
with:
name: devenv
- name: Install devenv.sh
run: nix profile install nixpkgs#devenv

- name: Format
run: |
eval "$(nix print-dev-env)"
treefmt --fail-on-change
shell: devenv shell bash -- -e {0}
run: treefmt --fail-on-change
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Devenv
.devenv*
devenv.local.nix

# direnv
.direnv

# pre-commit
.pre-commit-config.yaml
100 changes: 100 additions & 0 deletions devenv.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1736426010,
"owner": "cachix",
"repo": "devenv",
"rev": "1c384bc4be3ee571511fbbc6fdc94fe47d60f6cf",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1733328505,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1733477122,
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "7bd9e84d0452f6d2e63b6e6da29fe73fac951857",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1735882644,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "a5a961387e75ae44cc20f0a57ae463da5e959656",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
}
},
"root": "root",
"version": 7
}
19 changes: 19 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{pkgs, ...}: {
packages = with pkgs; [
# Code formatting tools
treefmt
alejandra
mdl
rustfmt

# Rust toolchain
rustup
probe-rs

# Extra tools for control program
cargo-cross

# Sensor firmware toolchain
esphome
];
}
15 changes: 15 additions & 0 deletions devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling

# If you're using non-OSS software, you can set allowUnfree to true.
# allowUnfree: true

# If you're willing to use a package that's vulnerable
# permittedInsecurePackages:
# - "openssl-1.1.1w"

# If you have more than one devenv you can merge them
#imports:
# - ./backend
60 changes: 0 additions & 60 deletions flake.lock

This file was deleted.

Loading

0 comments on commit f3626c5

Please sign in to comment.