feat(rust): add initial rust template
This commit is contained in:
73
rust/flake.nix
Normal file
73
rust/flake.nix
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
description = "Rust tool";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
|
||||
crane.url = "github:ipetkov/crane";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
flake-parts,
|
||||
crane,
|
||||
...
|
||||
} @ inputs:
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
systems = ["aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin"];
|
||||
|
||||
perSystem = {pkgs, ...}: let
|
||||
craneLib = crane.mkLib pkgs;
|
||||
src = ./.;
|
||||
|
||||
# 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;
|
||||
};
|
||||
in rec {
|
||||
# Formatter for nix files, available through 'nix fmt'
|
||||
formatter = pkgs.alejandra;
|
||||
|
||||
# Your custom packages
|
||||
# Accessible through 'nix build', 'nix shell', 'nix run', etc
|
||||
packages = {
|
||||
default = craneLib.buildPackage {
|
||||
inherit src cargoArtifacts;
|
||||
|
||||
# runtime dependencies
|
||||
# buildInputs = [];
|
||||
|
||||
# build dependencies
|
||||
# nativeBuildInputs = [pkgs.pkg-config];
|
||||
};
|
||||
};
|
||||
|
||||
checks = {
|
||||
clippy = craneLib.cargoClippy {
|
||||
inherit src cargoArtifacts;
|
||||
cargoClippyExtraArgs = "-- --deny warnings";
|
||||
};
|
||||
|
||||
fmt = craneLib.cargoFmt {
|
||||
inherit src cargoArtifacts;
|
||||
};
|
||||
};
|
||||
|
||||
# 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 cargoArtifacts checks;
|
||||
|
||||
# extra tooling dependencies
|
||||
packages = with pkgs; [
|
||||
rust-analyzer
|
||||
];
|
||||
|
||||
inputsFrom = [packages.default];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user