dotfiles.nix/templates/rust/flake.nix

59 lines
1.7 KiB
Nix
Raw Normal View History

2022-11-30 01:41:05 +00:00
{
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";
2022-11-30 03:19:54 +00:00
pre-commit.inputs.nixpkgs.follows = "nixpkgs";
2022-11-30 01:41:05 +00:00
};
2022-11-30 03:19:54 +00:00
outputs = { self, flake-parts, crane, pre-commit, ... }:
2022-11-30 01:41:05 +00:00
flake-parts.lib.mkFlake { inherit self; } {
2022-11-30 03:19:54 +00:00
imports = [ pre-commit.flakeModule ];
2022-11-30 01:41:05 +00:00
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
2022-11-30 03:19:54 +00:00
perSystem = { config, pkgs, system, ... }:
2022-11-30 01:41:05 +00:00
let
2022-11-30 03:19:54 +00:00
crane-lib = crane.lib.${system};
2022-11-30 01:41:05 +00:00
package = crane-lib.buildPackage {
src = crane-lib.cleanCargoSource ./.;
nativeBuildInputs = [ pkgs.libiconv ];
};
in
{
2022-11-30 03:19:54 +00:00
pre-commit.settings.hooks = {
rustfmt.enable = true;
clippy.enable = true;
cargo-check.enable = true;
2022-11-30 01:41:05 +00:00
};
2022-11-30 03:19:54 +00:00
checks = { inherit package; };
2022-11-30 01:41:05 +00:00
packages.default = package;
devShells.default = pkgs.mkShell {
2022-11-30 03:19:54 +00:00
shellHook = ''
${config.pre-commit.installationScript}
echo "welcome to your rust project ()" 1>&2
'';
2022-11-30 01:41:05 +00:00
inputsFrom = builtins.attrValues self.checks;
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
nativeBuildInputs = with pkgs; [
cargo
rustc
];
buildInputs = with pkgs; [
rust-analyzer
2022-11-30 01:41:05 +00:00
rustfmt
clippy
];
};
};
};
}