-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
107 lines (97 loc) · 3.32 KB
/
flake.nix
File metadata and controls
107 lines (97 loc) · 3.32 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
{
description = "Messaging automation for small businesses — WhatsApp, Instagram DM, lead capture";
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";
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, git-hooks }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "clippy" "rustfmt" ];
targets = [ "wasm32-unknown-unknown" ];
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
# Include assets/ alongside standard Cargo sources
src = pkgs.lib.cleanSourceWith {
src = ./.;
filter = path: type:
(craneLib.filterCargoSources path type)
|| (builtins.match ".*assets/.*" path != null);
};
# Common args for all crane builds
commonArgs = {
inherit src;
strictDeps = true;
};
# Build dependencies separately for caching
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
pre-commit-check = git-hooks.lib.${system}.run {
src = ./.;
hooks = {
check-json.enable = true;
check-merge-conflicts.enable = true;
check-toml.enable = true;
check-yaml.enable = true;
detect-private-keys.enable = true;
end-of-file-fixer.enable = true;
mixed-line-endings.enable = true;
trim-trailing-whitespace.enable = true;
nixpkgs-fmt.enable = true;
rustfmt = {
enable = true;
packageOverrides.cargo = rustToolchain;
packageOverrides.rustfmt = rustToolchain;
};
# clippy runs via crane checks (needs network for deps);
};
};
in
{
checks = {
inherit pre-commit-check;
# Run cargo test
tests = craneLib.cargoTest (commonArgs // {
inherit cargoArtifacts;
});
# Run clippy with all warnings as errors
clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- -D warnings";
});
# Check formatting
fmt = craneLib.cargoFmt {
inherit src;
};
};
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
rustToolchain
wrangler
worker-build
wasm-pack
nodejs_22
nodePackages.npm
];
shellHook = ''
${pre-commit-check.shellHook}
echo "Concierge Worker dev environment"
echo " wrangler dev - Start local dev server"
echo " wrangler deploy - Deploy to Cloudflare"
echo " nix flake check - Run CI checks"
'';
};
}
);
}