-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
110 lines (94 loc) · 3.22 KB
/
flake.nix
File metadata and controls
110 lines (94 loc) · 3.22 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
109
110
{
description = "A minimal library for implementing device drivers on resource-constrained targets";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
treefmt-nix.url = "github:numtide/treefmt-nix";
crane.url = "github:ipetkov/crane";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
advisory-db.url = "github:rustsec/advisory-db";
advisory-db.flake = false;
};
outputs =
{
self,
nixpkgs,
flake-utils,
treefmt-nix,
...
}@inputs:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ (import inputs.rust-overlay) ];
pkgs = import nixpkgs { inherit overlays system; };
# Import helpers from the flake (e.g. cleanCargoSource).
helpers = import ./nix/lib {
inherit (pkgs) lib;
};
# Make the Crane lib instance.
craneLib = pkgs.lib.foldl (acc: f: f acc) (inputs.crane.mkLib pkgs) [
# Set the default profile to `dev`.
(helpers.cargoDerivationFor { profile = "dev"; })
# Customize the Rust toolchain for the target and crate.
(helpers.cargoRustToolchainFor {
# All needed extensions for editor completion, build and test.
extensions = [
"clippy"
"llvm-tools"
"rust-analyzer"
"rust-src"
"rust-std"
"rustfmt"
];
# The target we build for.
targets = [ "thumbv8m.main-none-eabihf" ];
})
];
# Apply Crane library to source helper.
cleanCargoSource = helpers.cleanCargoSource craneLib;
# Apply Crane library to build helper (dev mode).
buildPackage = helpers.buildPackage craneLib { };
# Apply Crane library to build helper (dev mode).
buildReleasePackage = helpers.buildPackage craneLib { profile = "release"; };
in
{
# Declare the formatters to be used with `nix fmt`.
formatter = treefmt-nix.lib.mkWrapper pkgs {
# Where to look for the root of the sources.
projectRootFile = "flake.nix";
# What formatters are enabled.
programs.mdformat.enable = true;
programs.just.enable = true;
programs.nixfmt.enable = true;
programs.rustfmt.enable = true;
programs.taplo.enable = true;
# Formatter settings.
settings.formatter.just.includes = [
"Justfile"
"**/*.just"
];
settings.formatter.mdformat.includes = [ "**/*.md" ];
};
# Declare the developer shell with some build and utility packages.
devShells.default = craneLib.devShell {
# Additional environment variables here (e.g. CUSTOM_VAR = ...).
# Extra input packages.
packages = with pkgs; [
bacon
binsider
cargo-audit
cargo-binutils
cargo-deny
cargo-nextest
flip-link
just
gcc-arm-embedded-13
minicom
probe-rs-tools
];
};
}
);
}