Compare commits
9 Commits
25609ea025
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
60448993c5
|
|||
|
0d1a37eef3
|
|||
|
ba2dce4b85
|
|||
|
d40b80a910
|
|||
|
7a05bf3d5e
|
|||
|
81008113e3
|
|||
|
bc7f84a854
|
|||
|
c95a397e58
|
|||
|
e6289d758b
|
@@ -0,0 +1,8 @@
|
|||||||
|
[global]
|
||||||
|
disable = [
|
||||||
|
# line length limits
|
||||||
|
"MD013",
|
||||||
|
]
|
||||||
|
|
||||||
|
[MD057]
|
||||||
|
absolute-links = "relative_to_roots"
|
||||||
+2
-2
@@ -155,8 +155,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
# Formatter for nix files, available through 'nix fmt'
|
# Formatter for nix files, available through 'nix fmt'
|
||||||
treefmt = lib.mkIf cfg.formatter.enable {
|
treefmt.programs = lib.mkIf cfg.formatter.enable {
|
||||||
programs.alejandra.enable = lib.mkIf cfg.formatter.nix true;
|
alejandra.enable = lib.mkIf cfg.formatter.nix true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
./rust
|
./rust
|
||||||
./rust-esp32-c6
|
./rust-esp32-c6
|
||||||
|
|
||||||
|
inputs.treefmt-nix.flakeModule
|
||||||
flake-parts.flakeModules.flakeModules
|
flake-parts.flakeModules.flakeModules
|
||||||
# define the flake.templates option
|
# define the flake.templates option
|
||||||
({lib, ...}: {
|
({lib, ...}: {
|
||||||
@@ -57,6 +58,13 @@
|
|||||||
|
|
||||||
systems = ["aarch64-linux" "x86_64-linux" "aarch64-darwin"];
|
systems = ["aarch64-linux" "x86_64-linux" "aarch64-darwin"];
|
||||||
|
|
||||||
perSystem = {pkgs, ...}: {formatter = pkgs.alejandra;};
|
perSystem = {pkgs, ...}: {
|
||||||
|
treefmt.programs = {
|
||||||
|
alejandra.enable = true; # nix
|
||||||
|
taplo.enable = true; # toml
|
||||||
|
rumdl-check.enable = true; # markdown
|
||||||
|
rumdl-format.enable = true; # markdown
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,14 @@
|
|||||||
krantz.rust.devDeps = lib.mkOptionDefault (with pkgs; [
|
krantz.rust.devDeps = lib.mkOptionDefault (with pkgs; [
|
||||||
espflash
|
espflash
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
krantz.rust.cargoArtifacts.extraAttrs = lib.mkOptionDefault {
|
||||||
|
doCheck = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
krantz.rust.package.extraAttrs = lib.mkOptionDefault {
|
||||||
|
doCheck = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
runner = "espflash flash --monitor --chip esp32c6 --log-format defmt"
|
runner = "espflash flash --monitor --chip esp32c6 --log-format defmt"
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
DEFMT_LOG="info"
|
DEFMT_LOG = "info"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
rustflags = [
|
rustflags = [
|
||||||
# Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
|
# Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
|
||||||
# NOTE: May negatively impact performance of produced code
|
# NOTE: May negatively impact performance of produced code
|
||||||
"-C", "force-frame-pointers",
|
"-C",
|
||||||
|
"force-frame-pointers",
|
||||||
]
|
]
|
||||||
|
|
||||||
target = "riscv32imac-unknown-none-elf"
|
target = "riscv32imac-unknown-none-elf"
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
[global]
|
||||||
|
disable = [
|
||||||
|
# line length limits
|
||||||
|
"MD013",
|
||||||
|
]
|
||||||
|
|
||||||
|
[MD057]
|
||||||
|
absolute-links = "relative_to_roots"
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
name = "rust-esp32-c6"
|
name = "rust-esp32-c6"
|
||||||
rust-version = "1.88"
|
rust-version = "1.88"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "rust-esp32-c6"
|
name = "rust-esp32-c6"
|
||||||
@@ -18,7 +18,7 @@ esp-rtos = { version = "0.3.0", features = [
|
|||||||
"esp32c6",
|
"esp32c6",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
defmt = "1.0.1"
|
defmt = "1.0.1"
|
||||||
esp-bootloader-esp-idf = { version = "0.5.0", features = ["defmt", "esp32c6"] }
|
esp-bootloader-esp-idf = { version = "0.5.0", features = ["defmt", "esp32c6"] }
|
||||||
|
|
||||||
embassy-executor = { version = "0.10.0", features = ["defmt"] }
|
embassy-executor = { version = "0.10.0", features = ["defmt"] }
|
||||||
@@ -32,7 +32,7 @@ esp-backtrace = { version = "0.19.0", features = [
|
|||||||
esp-println = { version = "0.17.0", features = ["defmt-espflash", "esp32c6"] }
|
esp-println = { version = "0.17.0", features = ["defmt-espflash", "esp32c6"] }
|
||||||
|
|
||||||
critical-section = "1.2.0"
|
critical-section = "1.2.0"
|
||||||
static_cell = "2.1.1"
|
static_cell = "2.1.1"
|
||||||
|
|
||||||
|
|
||||||
# For fine tuning these settings, please refer to https://doc.rust-lang.org/cargo/reference/profiles.html
|
# For fine tuning these settings, please refer to https://doc.rust-lang.org/cargo/reference/profiles.html
|
||||||
@@ -42,7 +42,7 @@ static_cell = "2.1.1"
|
|||||||
opt-level = "s"
|
opt-level = "s"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
codegen-units = 1 # LLVM can perform better optimizations using a single thread
|
codegen-units = 1 # LLVM can perform better optimizations using a single thread
|
||||||
debug = 2 # prefer slower builds but better debugging experience
|
debug = 2 # prefer slower builds but better debugging experience
|
||||||
lto = 'fat'
|
lto = 'fat'
|
||||||
opt-level = 's'
|
opt-level = 's'
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
|
|
||||||
project-templates = {
|
project-templates = {
|
||||||
url = "git+file:///home/reed/code/project-templates";
|
url = "git+https://git.krantz.one/reed/project-templates";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
inputs.flake-parts.follows = "flake-parts";
|
inputs.flake-parts.follows = "flake-parts";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "stable"
|
channel = "stable"
|
||||||
components = ["rust-src"]
|
components = ["rust-src"]
|
||||||
targets = ["riscv32imac-unknown-none-elf"]
|
targets = ["riscv32imac-unknown-none-elf"]
|
||||||
|
|||||||
+42
-14
@@ -29,7 +29,7 @@
|
|||||||
manifest = (lib.importTOML "${src}/Cargo.toml").package;
|
manifest = (lib.importTOML "${src}/Cargo.toml").package;
|
||||||
|
|
||||||
craneLib =
|
craneLib =
|
||||||
if builtins.pathExists cfg.srcToolchain
|
if cfg.srcToolchain != null && builtins.pathExists cfg.srcToolchain
|
||||||
then
|
then
|
||||||
(inputs.crane.mkLib (pkgs.extend inputs.rust-overlay.overlays.default)).overrideToolchain (
|
(inputs.crane.mkLib (pkgs.extend inputs.rust-overlay.overlays.default)).overrideToolchain (
|
||||||
p: p.rust-bin.fromRustupToolchainFile cfg.srcToolchain
|
p: p.rust-bin.fromRustupToolchainFile cfg.srcToolchain
|
||||||
@@ -43,9 +43,10 @@
|
|||||||
|
|
||||||
# Build *just* the cargo dependencies, so we can reuse
|
# Build *just* the cargo dependencies, so we can reuse
|
||||||
# all of that work (e.g. via cachix) when running in CI
|
# all of that work (e.g. via cachix) when running in CI
|
||||||
cargoArtifacts = craneLib.buildDepsOnly {
|
cargoArtifacts = craneLib.buildDepsOnly ({
|
||||||
inherit src buildInputs nativeBuildInputs;
|
inherit src buildInputs nativeBuildInputs;
|
||||||
};
|
}
|
||||||
|
// cfg.cargoArtifacts.extraAttrs);
|
||||||
in {
|
in {
|
||||||
options.krantz.rust = {
|
options.krantz.rust = {
|
||||||
enable = lib.mkEnableOption "building a cargo project with crane";
|
enable = lib.mkEnableOption "building a cargo project with crane";
|
||||||
@@ -60,14 +61,26 @@
|
|||||||
description = "A path to the filtered directory of the root of the crate.";
|
description = "A path to the filtered directory of the root of the crate.";
|
||||||
type = lib.types.path;
|
type = lib.types.path;
|
||||||
default = craneLib.cleanCargoSource cfg.src;
|
default = craneLib.cleanCargoSource cfg.src;
|
||||||
defaultText = lib.literalExpression "config.krantz.rust.craneLib cfg.src";
|
defaultText = lib.literalExpression "config.krantz.rust.craneLib.cleanCargoSource cfg.src";
|
||||||
example = lib.literalExpression "./.";
|
example = lib.literalExpression "./.";
|
||||||
};
|
};
|
||||||
srcToolchain = lib.mkOption {
|
srcToolchain = lib.mkOption {
|
||||||
description = "A path to the rust-toolchain(.toml) file for the repo. Will use the toolchain from nixpkgs if the file does not exist.";
|
description = "A path to the rust-toolchain(.toml) file for the repo. Will use the toolchain from nixpkgs if the file does not exist.";
|
||||||
type = lib.types.path;
|
type = lib.types.nullOr lib.types.path;
|
||||||
default = "${if cfg.src != null then cfg.src else "/dev/null"}/rust-toolchain.toml";
|
default =
|
||||||
defaultText = lib.literalExpression "cfg.src + \"/rust-toolchain.toml\"";
|
if cfg.src != null
|
||||||
|
then cfg.src + "/rust-toolchain.toml"
|
||||||
|
else null;
|
||||||
|
defaultText =
|
||||||
|
lib.literalExpression
|
||||||
|
/*
|
||||||
|
nix
|
||||||
|
*/
|
||||||
|
''
|
||||||
|
if cfg.src != null
|
||||||
|
then cfg.src + "/rust-toolchain.toml"
|
||||||
|
else null;
|
||||||
|
'';
|
||||||
example = lib.literalExpression "./rust-toolchain";
|
example = lib.literalExpression "./rust-toolchain";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -96,6 +109,17 @@
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cargoArtifacts = {
|
||||||
|
extraAttrs = lib.mkOption {
|
||||||
|
description = "Extra attributes to merge into buildDepsOnly. See https://crane.dev/API.html#cranelibbuilddepsonly";
|
||||||
|
type = lib.types.attrs;
|
||||||
|
default = {};
|
||||||
|
example = {
|
||||||
|
doCheck = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
devShell = {
|
devShell = {
|
||||||
enable = lib.mkEnableOption "a rust development environment" // {default = true;};
|
enable = lib.mkEnableOption "a rust development environment" // {default = true;};
|
||||||
|
|
||||||
@@ -143,6 +167,8 @@
|
|||||||
|
|
||||||
nix = lib.mkEnableOption "formatting for nix files" // {default = true;};
|
nix = lib.mkEnableOption "formatting for nix files" // {default = true;};
|
||||||
rust = lib.mkEnableOption "formatting for rust files" // {default = true;};
|
rust = lib.mkEnableOption "formatting for rust files" // {default = true;};
|
||||||
|
toml = lib.mkEnableOption "formatting for toml files" // {default = true;};
|
||||||
|
markdown = lib.mkEnableOption "formatting for toml files" // {default = true;};
|
||||||
};
|
};
|
||||||
|
|
||||||
checks = {
|
checks = {
|
||||||
@@ -179,20 +205,22 @@
|
|||||||
# Your custom packages
|
# Your custom packages
|
||||||
# Accessible through 'nix build', 'nix shell', 'nix run', etc
|
# Accessible through 'nix build', 'nix shell', 'nix run', etc
|
||||||
packages = lib.mkIf cfg.package.enable {
|
packages = lib.mkIf cfg.package.enable {
|
||||||
${cfg.package.name} =
|
${cfg.package.name} = craneLib.buildPackage ({
|
||||||
craneLib.buildPackage {
|
|
||||||
inherit src buildInputs nativeBuildInputs cargoArtifacts;
|
inherit src buildInputs nativeBuildInputs cargoArtifacts;
|
||||||
}
|
}
|
||||||
// cfg.package.extraAttrs;
|
// cfg.package.extraAttrs);
|
||||||
};
|
};
|
||||||
|
|
||||||
# Formatter for nix files, available through 'nix fmt'
|
# Formatter for nix files, available through 'nix fmt'
|
||||||
treefmt = lib.mkIf cfg.formatter.enable {
|
treefmt.programs = lib.mkIf cfg.formatter.enable {
|
||||||
programs.alejandra.enable = lib.mkIf cfg.formatter.nix true;
|
alejandra.enable = lib.mkIf cfg.formatter.nix true;
|
||||||
programs.rustfmt = lib.mkIf cfg.formatter.rust {
|
rustfmt = lib.mkIf cfg.formatter.rust {
|
||||||
enable = true;
|
enable = true;
|
||||||
edition = manifest.edition;
|
edition = manifest.edition;
|
||||||
};
|
};
|
||||||
|
taplo.enable = lib.mkIf cfg.formatter.toml true;
|
||||||
|
rumdl-check.enable = lib.mkIf cfg.formatter.markdown true;
|
||||||
|
rumdl-format.enable = lib.mkIf cfg.formatter.markdown true;
|
||||||
};
|
};
|
||||||
|
|
||||||
checks = lib.mkIf cfg.checks.enable {
|
checks = lib.mkIf cfg.checks.enable {
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
[global]
|
||||||
|
disable = [
|
||||||
|
# line length limits
|
||||||
|
"MD013",
|
||||||
|
]
|
||||||
|
|
||||||
|
[MD057]
|
||||||
|
absolute-links = "relative_to_roots"
|
||||||
@@ -15,4 +15,3 @@ tracing-subscriber = "*"
|
|||||||
|
|
||||||
clap = { version = "*", features = ["derive"] }
|
clap = { version = "*", features = ["derive"] }
|
||||||
figment = { version = "*", features = ["toml", "env", "json"] }
|
figment = { version = "*", features = ["toml", "env", "json"] }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user