feat: move to a flake-parts based flake where templates import flake modules from the root flake

This commit is contained in:
2026-04-26 00:44:51 -05:00
parent f3d81b82f0
commit 4fa7424c99
3 changed files with 205 additions and 73 deletions
+11 -67
View File
@@ -6,88 +6,32 @@
flake-parts.url = "github:hercules-ci/flake-parts";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
project-templates = {
url = "git+ssh://gitea@git.krantz.one/reed/project-templates";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
crane.url = "github:ipetkov/crane";
};
outputs = {
flake-parts,
treefmt-nix,
crane,
project-templates,
...
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
treefmt-nix.flakeModule
project-templates.flakeModules.rust
];
systems = ["aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
pkgs,
lib,
...
}: let
craneLib = crane.mkLib pkgs;
src = craneLib.cleanCargoSource ./.;
manifest = (lib.importTOML "${src}/Cargo.toml").package;
perSystem = {pkgs, ...}: {
krantz.rust = {
enable = true;
src = ./.;
# runtime dependencies
buildInputs = with pkgs; [
# openssl
];
# build dependencies
nativeBuildInputs = with pkgs; [
# pkg-config
];
# 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;
};
in rec {
# Dev Shell that lets you enter an environment with all the necessary utilites
# Available through 'nix develop'
# Also can be activated automatically if direnv is installed on the system with 'direnv allow'
devShells.default = craneLib.devShell {
inherit checks;
# extra tooling dependencies
packages = with pkgs; [
rust-analyzer
];
inputsFrom = [packages.default];
};
# Formatter for nix files, available through 'nix fmt'
treefmt = {
programs.alejandra.enable = true;
programs.rustfmt = {
enable = true;
edition = manifest.edition;
};
};
# Your custom packages
# Accessible through 'nix build', 'nix shell', 'nix run', etc
packages = {
default = craneLib.buildPackage {
inherit src buildInputs nativeBuildInputs cargoArtifacts;
};
};
checks = {
clippy = craneLib.cargoClippy {
inherit src buildInputs nativeBuildInputs cargoArtifacts;
cargoClippyExtraArgs = "-- --deny warnings";
};
# runtimeDeps = with pkgs; [];
# buildDeps = with pkgs; [];
};
};
};