dotfiles.nix/templates/rust/flake.nix

59 lines
1.6 KiB
Nix

{
description = "FILL-ME-IN";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
pre-commit.url = "github:cachix/pre-commit-hooks.nix";
};
outputs = { self, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit self; } {
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
perSystem = { self', inputs', pkgs, ... }:
let
inherit (inputs') crane pre-commit;
crane-lib = crane.lib;
package = crane-lib.buildPackage {
src = crane-lib.cleanCargoSource ./.;
nativeBuildInputs = [ pkgs.libiconv ];
};
in
{
checks = {
inherit package;
pre-commit = pre-commit.lib.run {
src = ./.;
hooks = {
rustfmt.enable = true;
clippy.enable = true;
cargo-check.enable = true;
};
};
};
packages.default = package;
devShells.default = pkgs.mkShell {
inherit (self'.checks.pre-commit) shellHook;
inputsFrom = builtins.attrValues self.checks;
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
nativeBuildInputs = with pkgs; [
cargo
rustc
];
buildInputs = with pkgs; [
rustfmt
clippy
];
};
};
};
}