Skip to content

Commit a45dc22

Browse files
committed
ci: use nix devshell
1 parent 937f921 commit a45dc22

File tree

6 files changed

+107
-38
lines changed

6 files changed

+107
-38
lines changed

.github/workflows/ci.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,21 @@ jobs:
3535
steps:
3636
- uses: actions/checkout@v4
3737

38+
- name: Install Nix
39+
uses: cachix/install-nix-action@v27
40+
41+
- name: Enter Nix devshell
42+
uses: nicknovitski/[email protected]
43+
3844
- name: Install Rust (${{ matrix.toolchain.name }})
3945
uses: actions-rust-lang/[email protected]
4046
with:
4147
toolchain: ${{ matrix.toolchain.version }}
4248

43-
- name: Install just, nextest
49+
- name: Install nextest
4450
uses: taiki-e/[email protected]
4551
with:
46-
tool: just,nextest
52+
tool: nextest
4753

4854
- name: workaround MSRV issues
4955
if: matrix.toolchain.name == 'msrv'

.github/workflows/lint.yml

+30-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15+
print-msrv:
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
contents: read
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install Nix
25+
uses: cachix/install-nix-action@v27
26+
27+
- name: Enter Nix devshell
28+
uses: nicknovitski/[email protected]
29+
30+
- name: Install Rust
31+
uses: actions-rust-lang/[email protected]
32+
33+
- run: ls -la .toolchain
34+
- run: cat .toolchain/rust.just
35+
- run: just --evaluate msrv
36+
1537
clippy:
1638
runs-on: ubuntu-latest
1739

@@ -22,15 +44,21 @@ jobs:
2244
steps:
2345
- uses: actions/checkout@v4
2446

47+
- name: Install Nix
48+
uses: cachix/install-nix-action@v27
49+
50+
- name: Enter Nix devshell
51+
uses: nicknovitski/[email protected]
52+
2553
- name: Install Rust
2654
uses: actions-rust-lang/[email protected]
2755
with:
2856
components: clippy
2957

30-
- name: Install just & cargo-hack
58+
- name: Install cargo-hack
3159
uses: taiki-e/[email protected]
3260
with:
33-
tool: just,cargo-hack
61+
tool: cargo-hack
3462

3563
- name: Clippy
3664
run: just clippy

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
/target/
33
Cargo.lock
44

5+
# x52 toolchain
6+
/.toolchain/
7+
58
# direnv
69
/.direnv/
710

flake.lock

+40-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
{
22
inputs = {
33
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
4+
flake-parts.url = "github:hercules-ci/flake-parts";
5+
x52 = {
6+
url = "github:x52dev/nix";
7+
inputs.nixpkgs.follows = "nixpkgs";
8+
inputs.flake-parts.follows = "flake-parts";
9+
};
410
};
511

6-
outputs = inputs@{ flake-parts, ... }:
12+
outputs = inputs @ { flake-parts, x52, ... }:
713
flake-parts.lib.mkFlake { inherit inputs; } {
814
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
9-
perSystem = { pkgs, config, inputs', system, lib, ... }: {
15+
perSystem = { pkgs, config, inputs', system, lib, ... }:
16+
let
17+
x52just = inputs'.x52.packages.x52-just;
18+
in
19+
{
1020
formatter = pkgs.nixpkgs-fmt;
1121

1222
devShells.default = pkgs.mkShell {
23+
buildInputs = [ x52just ];
24+
1325
packages = [
1426
config.formatter
1527
pkgs.nodePackages.prettier
@@ -21,6 +33,11 @@
2133
pkgs.pkgsBuildHost.darwin.apple_sdk.frameworks.CoreFoundation
2234
pkgs.pkgsBuildHost.darwin.apple_sdk.frameworks.SystemConfiguration
2335
];
36+
37+
shellHook = ''
38+
mkdir -p .toolchain
39+
cp ${x52just}/rust.just .toolchain/
40+
'';
2441
};
2542
};
2643
};

justfile

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import '.toolchain/rust.just'
2+
13
_list:
24
@just --list
35

@@ -7,13 +9,6 @@ clippy:
79
cargo clippy --workspace --no-default-features --all-features
810
cargo hack --feature-powerset --depth=3 clippy --workspace
911

10-
msrv := ```
11-
cargo metadata --format-version=1 \
12-
| jq -r 'first(.packages[] | select(.source == null and .rust_version)) | .rust_version' \
13-
| sed -E 's/^1\.([0-9]{2})$/1\.\1\.0/'
14-
```
15-
msrv_rustup := "+" + msrv
16-
1712
# Downgrade dev-dependencies necessary to run MSRV checks/tests.
1813
[private]
1914
downgrade-msrv:
@@ -58,13 +53,14 @@ doc-watch:
5853
# Check project
5954
check:
6055
just --unstable --fmt --check
61-
prettier --check $(fd --type=file --hidden --extension=md --extension=yml)
62-
taplo lint $(fd --hidden --extension=toml)
56+
fd --hidden --type=file --extension=md --extension=yml --exec-batch prettier --check
57+
fd --hidden --extension=toml --exec-batch taplo format --check
58+
fd --hidden --extension=toml --exec-batch taplo lint
6359
cargo +nightly fmt -- --check
6460

6561
# Format project
6662
fmt:
6763
just --unstable --fmt
68-
prettier --write $(fd --type=file --hidden --extension=md --extension=yml)
69-
taplo format $(fd --hidden --extension=toml)
64+
fd --hidden --type=file --extension=md --extension=yml --exec-batch prettier --write
65+
fd --hidden --extension=toml --exec-batch taplo format
7066
cargo +nightly fmt

0 commit comments

Comments
 (0)