Skip to content

Commit da94fb0

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

File tree

7 files changed

+111
-63
lines changed

7 files changed

+111
-63
lines changed

.github/workflows/ci.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,16 @@ jobs:
3535
steps:
3636
- uses: actions/checkout@v4
3737

38+
- name: Install Nix
39+
uses: cachix/install-nix-action@v27
40+
3841
- name: Install Rust (${{ matrix.toolchain.name }})
3942
uses: actions-rust-lang/[email protected]
4043
with:
4144
toolchain: ${{ matrix.toolchain.version }}
4245

43-
- name: Install just, nextest
44-
uses: taiki-e/[email protected]
45-
with:
46-
tool: just,nextest
46+
- name: Enter Nix devshell
47+
uses: nicknovitski/[email protected]
4748

4849
- name: workaround MSRV issues
4950
if: matrix.toolchain.name == 'msrv'

.github/workflows/coverage.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ jobs:
2222
with:
2323
components: llvm-tools-preview
2424

25-
- name: Install just & cargo-llvm-cov
25+
- name: Enter Nix devshell
26+
uses: nicknovitski/[email protected]
27+
28+
- name: Install cargo-llvm-cov
2629
uses: taiki-e/[email protected]
2730
with:
28-
tool: just,cargo-llvm-cov
31+
tool: cargo-llvm-cov
2932

3033
- name: Generate code coverage
3134
run: just test-coverage-codecov

.github/workflows/lint.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ jobs:
2222
steps:
2323
- uses: actions/checkout@v4
2424

25+
- name: Install Nix
26+
uses: cachix/install-nix-action@v27
27+
2528
- name: Install Rust
2629
uses: actions-rust-lang/[email protected]
2730
with:
2831
components: clippy
2932

30-
- name: Install just & cargo-hack
31-
uses: taiki-e/[email protected]
32-
with:
33-
tool: just,cargo-hack
33+
- name: Enter Nix devshell
34+
uses: nicknovitski/[email protected]
3435

3536
- name: Clippy
3637
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

+40-16
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,51 @@
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, ... }: {
10-
formatter = pkgs.nixpkgs-fmt;
15+
perSystem = { pkgs, config, inputs', system, lib, ... }:
16+
let
17+
x52just = inputs'.x52.packages.x52-just;
18+
in
19+
{
20+
formatter = pkgs.nixpkgs-fmt;
21+
22+
devShells.default = pkgs.mkShell {
23+
buildInputs = [ x52just ];
24+
25+
packages = [
26+
# scripting
27+
pkgs.just
28+
29+
# cargo plugins
30+
pkgs.cargo-hack
31+
pkgs.cargo-nextest
32+
33+
# formatters
34+
config.formatter
35+
pkgs.nodePackages.prettier
36+
pkgs.taplo
37+
] ++ lib.optional pkgs.stdenv.isDarwin [
38+
pkgs.pkgsBuildHost.libiconv
39+
pkgs.pkgsBuildHost.darwin.apple_sdk.frameworks.Security
40+
pkgs.pkgsBuildHost.darwin.apple_sdk.frameworks.CoreFoundation
41+
pkgs.pkgsBuildHost.darwin.apple_sdk.frameworks.SystemConfiguration
42+
];
1143

12-
devShells.default = pkgs.mkShell {
13-
packages = [
14-
config.formatter
15-
pkgs.nodePackages.prettier
16-
pkgs.taplo
17-
pkgs.just
18-
] ++ lib.optional pkgs.stdenv.isDarwin [
19-
pkgs.pkgsBuildHost.libiconv
20-
pkgs.pkgsBuildHost.darwin.apple_sdk.frameworks.Security
21-
pkgs.pkgsBuildHost.darwin.apple_sdk.frameworks.CoreFoundation
22-
pkgs.pkgsBuildHost.darwin.apple_sdk.frameworks.SystemConfiguration
23-
];
44+
shellHook = ''
45+
mkdir -p .toolchain
46+
cp ${x52just}/*.just .toolchain/
47+
'';
48+
};
2449
};
25-
};
2650
};
2751
}

justfile

+13-16
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1+
import '.toolchain/rust.just'
2+
13
_list:
24
@just --list
35

6+
# Format project
7+
fmt:
8+
just --unstable --fmt
9+
nixpkgs-fmt .
10+
fd --hidden --type=file --extension=md --extension=yml --exec-batch prettier --write
11+
fd --hidden --extension=toml --exec-batch taplo format
12+
cargo +nightly fmt
13+
414
# Lint workspace with Clippy
515
clippy:
616
cargo clippy --workspace --no-default-features
717
cargo clippy --workspace --no-default-features --all-features
818
cargo hack --feature-powerset --depth=3 clippy --workspace
919

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-
1720
# Downgrade dev-dependencies necessary to run MSRV checks/tests.
1821
[private]
1922
downgrade-msrv:
@@ -58,13 +61,7 @@ doc-watch:
5861
# Check project
5962
check:
6063
just --unstable --fmt --check
61-
prettier --check $(fd --type=file --hidden --extension=md --extension=yml)
62-
taplo lint $(fd --hidden --extension=toml)
64+
fd --hidden --type=file --extension=md --extension=yml --exec-batch prettier --check
65+
fd --hidden --extension=toml --exec-batch taplo format --check
66+
fd --hidden --extension=toml --exec-batch taplo lint
6367
cargo +nightly fmt -- --check
64-
65-
# Format project
66-
fmt:
67-
just --unstable --fmt
68-
prettier --write $(fd --type=file --hidden --extension=md --extension=yml)
69-
taplo format $(fd --hidden --extension=toml)
70-
cargo +nightly fmt

0 commit comments

Comments
 (0)