Compare commits

..

3 Commits

7 changed files with 47 additions and 18 deletions
+8
View File
@@ -0,0 +1,8 @@
[global]
disable = [
# line length limits
"MD013",
]
[MD057]
absolute-links = "relative_to_roots"
+1 -1
View File
@@ -1,3 +1,3 @@
# project-templates
Nix flake templates for initializing new projects.
Nix flake templates for initializing new projects.
+2 -2
View File
@@ -155,8 +155,8 @@
};
# Formatter for nix files, available through 'nix fmt'
treefmt = lib.mkIf cfg.formatter.enable {
programs.alejandra.enable = lib.mkIf cfg.formatter.nix true;
treefmt.programs = lib.mkIf cfg.formatter.enable {
alejandra.enable = lib.mkIf cfg.formatter.nix true;
};
};
});
+9 -1
View File
@@ -36,6 +36,7 @@
./rust
./rust-esp32-c6
inputs.treefmt-nix.flakeModule
flake-parts.flakeModules.flakeModules
# define the flake.templates option
({lib, ...}: {
@@ -57,6 +58,13 @@
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
};
};
};
}
+2 -2
View File
@@ -1,7 +1,7 @@
[global]
disable = [
# line length limits
"MD013",
# line length limits
"MD013",
]
[MD057]
+23 -10
View File
@@ -29,7 +29,7 @@
manifest = (lib.importTOML "${src}/Cargo.toml").package;
craneLib =
if builtins.pathExists cfg.srcToolchain
if cfg.srcToolchain != null && builtins.pathExists cfg.srcToolchain
then
(inputs.crane.mkLib (pkgs.extend inputs.rust-overlay.overlays.default)).overrideToolchain (
p: p.rust-bin.fromRustupToolchainFile cfg.srcToolchain
@@ -44,8 +44,9 @@
# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly ({
inherit src buildInputs nativeBuildInputs;
} // cfg.cargoArtifacts.extraAttrs);
inherit src buildInputs nativeBuildInputs;
}
// cfg.cargoArtifacts.extraAttrs);
in {
options.krantz.rust = {
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.";
type = lib.types.path;
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 "./.";
};
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.path;
default = "${if cfg.src != null then cfg.src else "/dev/null"}/rust-toolchain.toml";
defaultText = lib.literalExpression "cfg.src + \"/rust-toolchain.toml\"";
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;
'';
example = lib.literalExpression "./rust-toolchain";
};
@@ -192,10 +205,10 @@
# 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;
} // cfg.package.extraAttrs);
}
// cfg.package.extraAttrs);
};
# Formatter for nix files, available through 'nix fmt'
+2 -2
View File
@@ -1,7 +1,7 @@
[global]
disable = [
# line length limits
"MD013",
# line length limits
"MD013",
]
[MD057]