Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
109 lines (90 loc) · 2.94 KB
/
Copy pathflake.nix
File metadata and controls
109 lines (90 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{
description = "Vite plugin for processing Norg files";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, pre-commit-hooks, treefmt-nix }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchainToml = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
rustToolchain = rustToolchainToml.override {
extensions = [ "rust-src" ];
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
# Common args for crane
commonArgs = {
src = ./.;
buildInputs = with pkgs; [
# Add any system dependencies here
];
};
# Build dependencies first for reuse
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
};
};
treefmtEval = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs = {
oxfmt.enable = true;
rustfmt = {
enable = true;
package = rustToolchain;
};
nixpkgs-fmt.enable = true;
};
settings.formatter.oxfmt.options = [ "--no-error-on-unmatched-pattern" ];
};
in
{
formatter = treefmtEval.config.build.wrapper;
checks = {
pre-commit-check = pre-commit-check;
# Crane-based Rust checks that handle dependencies properly
clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "-- --deny warnings";
});
rust-tests = craneLib.cargoTest (commonArgs // {
inherit cargoArtifacts;
});
formatting = treefmtEval.config.build.check self;
};
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
# Node
nodejs_24
pnpm
# Rust
rustToolchain
wasm-pack
wasm-bindgen-cli
binaryen # for wasm-opt
# Formatters
treefmtEval.config.build.wrapper
nixpkgs-fmt
git
direnv
] ++ pre-commit-check.enabledPackages;
shellHook = pre-commit-check.shellHook;
};
});
}