-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
109 lines (98 loc) · 3.24 KB
/
flake.nix
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
109
{
# Using devcontainer for now, but just in case...
description = "@brushknight's awesome board programmed with Rust!";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# Modules for flakes
flake-parts.url = "github:hercules-ci/flake-parts";
# Hooks for git (even custom)
git-hooks.url = "github:cachix/git-hooks.nix";
# Rust toolchains
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-analyzer-src.follows = "";
};
};
outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ inputs.git-hooks.flakeModule ];
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
perSystem =
{
pkgs,
config,
inputs',
...
}:
let
rustToolchainManifest = pkgs.lib.recursiveUpdate (builtins.fromJSON (builtins.readFile "${inputs.fenix}/data/stable.json")) (
builtins.fromJSON (builtins.readFile ./esp-rs.json)
);
rustToolchain = (inputs'.fenix.packages.fromManifest rustToolchainManifest).toolchain;
in
{
pre-commit = {
check.enable = true;
settings = {
hooks = {
actionlint.enable = true;
cargo-check = {
enable = false; # ESP32 targets mess with this
package = rustToolchain;
};
clippy = {
enable = false; # ESP32 targets mess with this
packageOverrides = {
cargo = rustToolchain;
clippy = rustToolchain;
};
};
convco.enable = true;
markdownlint.enable = false;
nixfmt = {
enable = true;
package = pkgs.nixfmt-rfc-style;
};
rustfmt = {
enable = true;
packageOverrides = {
rustfmt = rustToolchain;
cargo = rustToolchain;
};
};
taplo.enable = true;
};
};
};
devShells.default = pkgs.mkShell {
name = "esp32s3";
# This doesn't exactly make the builds isolated and Nix-like, but it's quick enough for now
shellHook = ''
${config.pre-commit.installationScript}
echo 1>&2 "Welcome to the ESP32S3 with Rust development shell!"
# echo 1>&2 "Setting up Rust toolchain for ESP32..."
# ${pkgs.espup}/bin/espup install --targets esp32s3 --log-level debug --export-file ./export-esp.sh
# source ./export-esp.sh
'';
packages =
[
rustToolchain # Needed?
]
++ (with pkgs; [
# espup # For updating manually?
# To load binary into the board
# run with `espflash flash --monitor`
espflash
probe-rs
]);
# inputsFrom = [];
};
};
};
}