Compare commits

..
1 Commits
Author SHA1 Message Date
reed 25609ea025 feat(rust-esp32-c6): make the rust-esp32-c6 template 2026-06-04 20:20:48 -05:00
15 changed files with 69 additions and 165 deletions
-3
View File
@@ -1,8 +1,5 @@
name: "Flake.lock: update Nix dependencies for development environment only"
permissions:
contents: write
on:
workflow_dispatch: # allows manual triggering
schedule:
-8
View File
@@ -1,8 +0,0 @@
[global]
disable = [
# line length limits
"MD013",
]
[MD057]
absolute-links = "relative_to_roots"
+2 -2
View File
@@ -155,8 +155,8 @@
};
# Formatter for nix files, available through 'nix fmt'
treefmt.programs = lib.mkIf cfg.formatter.enable {
alejandra.enable = lib.mkIf cfg.formatter.nix true;
treefmt = lib.mkIf cfg.formatter.enable {
programs.alejandra.enable = lib.mkIf cfg.formatter.nix true;
};
};
});
Generated
+18 -18
View File
@@ -95,11 +95,11 @@
},
"crane": {
"locked": {
"lastModified": 1790899423,
"narHash": "sha256-THGtz65UGJU+sonZidRboyCMk+9DclpMF7pwL4uDV4M=",
"lastModified": 1777335812,
"narHash": "sha256-bEg5xoAxAwsyfnGhkEX7RJViTIBIYPd8ISg4O1c0HFc=",
"owner": "ipetkov",
"repo": "crane",
"rev": "47b6b27ed9a3a9181415e4367d0c30ab2a0e0250",
"rev": "5e0fb2f64edff2822249f21293b8304dedaaf676",
"type": "github"
},
"original": {
@@ -113,11 +113,11 @@
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1790898470,
"narHash": "sha256-zTwuwezD0w3hpga6a6P8emidzAZFyWqlNeRBlpWOOl8=",
"lastModified": 1775087534,
"narHash": "sha256-91qqW8lhL7TLwgQWijoGBbiD4t7/q75KTi8NxjVmSmA=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "024633cd702b10285db5cb19b40ad48d2399ba60",
"rev": "3107b77cd68437b9a76194f0f7f9c55f2329ca5b",
"type": "github"
},
"original": {
@@ -162,11 +162,11 @@
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1790477367,
"narHash": "sha256-oujbxmVKDhci2E4EM3KyAbRUgp5/IsCoiA/LfEF7OOk=",
"lastModified": 1774748309,
"narHash": "sha256-+U7gF3qxzwD5TZuANzZPeJTZRHS29OFQgkQ2kiTJBIQ=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "f7cd230690d9fc982d06129f9189b101fddcfa3b",
"rev": "333c4e0545a6da976206c74db8773a1645b5870a",
"type": "github"
},
"original": {
@@ -177,11 +177,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1791260994,
"narHash": "sha256-Miqqk/ammqnTUxaoCyvtwoPeLbI1ksFyLxi/CazZpWY=",
"lastModified": 1777268161,
"narHash": "sha256-bxrdOn8SCOv8tN4JbTF/TXq7kjo9ag4M+C8yzzIRYbE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "151fa4e8ddfdd8dd25d945ad94ed54a13de9f6e4",
"rev": "1c3fe55ad329cbcb28471bb30f05c9827f724c76",
"type": "github"
},
"original": {
@@ -273,11 +273,11 @@
]
},
"locked": {
"lastModified": 1791276535,
"narHash": "sha256-iwqAmHTX1IgzTumJR3JayNAQAo5xEmmOuGzB6b2pT/Q=",
"lastModified": 1780197589,
"narHash": "sha256-FVCr2Ij/jKf59a4LW481eeOF6rJRreOBrVgW/aUBTrw=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "b962e5d0c8cd97196c6a882d659fe451b52ad989",
"rev": "21632e942d89bf1cce4e5a63d7e58a215a0cbfcc",
"type": "github"
},
"original": {
@@ -308,11 +308,11 @@
]
},
"locked": {
"lastModified": 1791203292,
"narHash": "sha256-vuzVwvjeucSnwKwMBpyP8r5IzdrMKCHEdwTrRFwUN7I=",
"lastModified": 1775636079,
"narHash": "sha256-pc20NRoMdiar8oPQceQT47UUZMBTiMdUuWrYu2obUP0=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "03d8ee1bcbc8f9638907bb79edb9673151d0e22b",
"rev": "790751ff7fd3801feeaf96d7dc416a8d581265ba",
"type": "github"
},
"original": {
+1 -9
View File
@@ -36,7 +36,6 @@
./rust
./rust-esp32-c6
inputs.treefmt-nix.flakeModule
flake-parts.flakeModules.flakeModules
# define the flake.templates option
({lib, ...}: {
@@ -58,13 +57,6 @@
systems = ["aarch64-linux" "x86_64-linux" "aarch64-darwin"];
perSystem = {pkgs, ...}: {
treefmt.programs = {
alejandra.enable = true; # nix
taplo.enable = true; # toml
rumdl-check.enable = true; # markdown
rumdl-format.enable = true; # markdown
};
};
perSystem = {pkgs, ...}: {formatter = pkgs.alejandra;};
};
}
-8
View File
@@ -37,14 +37,6 @@
krantz.rust.devDeps = lib.mkOptionDefault (with pkgs; [
espflash
]);
krantz.rust.cargoArtifacts.extraAttrs = lib.mkOptionDefault {
doCheck = false;
};
krantz.rust.package.extraAttrs = lib.mkOptionDefault {
doCheck = false;
};
};
});
};
+1 -2
View File
@@ -8,8 +8,7 @@ DEFMT_LOG = "info"
rustflags = [
# Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
# NOTE: May negatively impact performance of produced code
"-C",
"force-frame-pointers",
"-C", "force-frame-pointers",
]
target = "riscv32imac-unknown-none-elf"
-8
View File
@@ -1,8 +0,0 @@
[global]
disable = [
# line length limits
"MD013",
]
[MD057]
absolute-links = "relative_to_roots"
+1 -1
View File
@@ -7,7 +7,7 @@
flake-parts.url = "github:hercules-ci/flake-parts";
project-templates = {
url = "git+https://git.krantz.one/reed/project-templates";
url = "git+file:///home/reed/code/project-templates";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
+27 -80
View File
@@ -25,54 +25,27 @@
}: let
cfg = config.krantz.rust;
manifest = (lib.importTOML "${cfg.srcFiltered}/Cargo.toml").package;
src = cfg.srcFiltered;
manifest = (lib.importTOML "${src}/Cargo.toml").package;
craneLib =
if hasToolchain
then (inputs.crane.mkLib rustPkgs).overrideToolchain mkRustToolchain
if builtins.pathExists cfg.srcToolchain
then
(inputs.crane.mkLib (pkgs.extend inputs.rust-overlay.overlays.default)).overrideToolchain (
p: p.rust-bin.fromRustupToolchainFile cfg.srcToolchain
)
else inputs.crane.mkLib pkgs;
# Attrs to be included for all crane functions that build our crate
cargoBuildAttrs = let
# Include the standard library Cargo.lock if we have the "rust-src" component in our toolchain
cargoVendorDir =
lib.optionalAttrs (
hasToolchain
&& lib.pipe cfg.srcToolchain [
builtins.readFile
fromTOML
(t: t ? toolchain.components && builtins.elem "rust-src" t.toolchain.components)
]
) {
cargoVendorDir = craneLib.vendorMultipleCargoDeps {
inherit (craneLib.findCargoFiles cfg.srcFiltered) cargoConfigs;
cargoLockList = [
"${cfg.srcFiltered}/Cargo.lock"
"${(mkRustToolchain rustPkgs).passthru.availableComponents.rust-src}/lib/rustlib/src/rust/library/Cargo.lock"
];
};
};
in
rec {
src = cfg.srcFiltered;
buildInputs = cfg.runtimeDeps;
# build dependencies
nativeBuildInputs = cfg.buildDeps;
# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly ({
cargoArtifacts = craneLib.buildDepsOnly {
inherit src buildInputs nativeBuildInputs;
}
// cargoVendorDir
// cfg.cargoArtifacts.extraAttrs);
}
// cargoVendorDir;
hasToolchain = cfg.srcToolchain != null && builtins.pathExists cfg.srcToolchain;
rustPkgs = pkgs.extend inputs.rust-overlay.overlays.default;
mkRustToolchain = p: p.rust-bin.fromRustupToolchainFile cfg.srcToolchain;
};
in {
options.krantz.rust = {
enable = lib.mkEnableOption "building a cargo project with crane";
@@ -87,26 +60,14 @@
description = "A path to the filtered directory of the root of the crate.";
type = lib.types.path;
default = craneLib.cleanCargoSource cfg.src;
defaultText = lib.literalExpression "config.krantz.rust.craneLib.cleanCargoSource cfg.src";
defaultText = lib.literalExpression "config.krantz.rust.craneLib cfg.src";
example = lib.literalExpression "./.";
};
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.";
type = lib.types.nullOr lib.types.path;
default =
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;
'';
type = lib.types.path;
default = "${if cfg.src != null then cfg.src else "/dev/null"}/rust-toolchain.toml";
defaultText = lib.literalExpression "cfg.src + \"/rust-toolchain.toml\"";
example = lib.literalExpression "./rust-toolchain";
};
@@ -135,17 +96,6 @@
];
};
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 = {
enable = lib.mkEnableOption "a rust development environment" // {default = true;};
@@ -193,8 +143,6 @@
nix = lib.mkEnableOption "formatting for nix 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 = {
@@ -216,7 +164,8 @@
# Available through 'nix develop'
# Also can be activated automatically if direnv is installed on the system with 'direnv allow'
devShells = lib.mkIf cfg.devShell.enable {
${cfg.devShell.name} = craneLib.devShell ({
${cfg.devShell.name} =
craneLib.devShell {
inherit (self') checks;
# extra tooling dependencies
@@ -224,35 +173,33 @@
inputsFrom = [self'.packages.${cfg.package.name}];
}
// cfg.devShell.extraAttrs);
// cfg.devShell.extraAttrs;
};
# Your custom packages
# Accessible through 'nix build', 'nix shell', 'nix run', etc
packages = lib.mkIf cfg.package.enable {
${cfg.package.name} = craneLib.buildPackage ({
${cfg.package.name} =
craneLib.buildPackage {
inherit src buildInputs nativeBuildInputs cargoArtifacts;
}
// cargoBuildAttrs
// cfg.package.extraAttrs);
// cfg.package.extraAttrs;
};
# Formatter for nix files, available through 'nix fmt'
treefmt.programs = lib.mkIf cfg.formatter.enable {
alejandra.enable = lib.mkIf cfg.formatter.nix true;
rustfmt = lib.mkIf cfg.formatter.rust {
treefmt = lib.mkIf cfg.formatter.enable {
programs.alejandra.enable = lib.mkIf cfg.formatter.nix true;
programs.rustfmt = lib.mkIf cfg.formatter.rust {
enable = true;
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 {
clippy = lib.mkIf cfg.checks.linter (craneLib.cargoClippy ({
clippy = lib.mkIf cfg.checks.linter (craneLib.cargoClippy {
inherit src buildInputs nativeBuildInputs cargoArtifacts;
cargoClippyExtraArgs = "-- --deny warnings";
}
// cargoBuildAttrs));
});
};
};
});
-8
View File
@@ -1,8 +0,0 @@
[global]
disable = [
# line length limits
"MD013",
]
[MD057]
absolute-links = "relative_to_roots"
+1
View File
@@ -15,3 +15,4 @@ tracing-subscriber = "*"
clap = { version = "*", features = ["derive"] }
figment = { version = "*", features = ["toml", "env", "json"] }