dotfiles.nix/templates/rust/flake.nix

52 lines
1.8 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
};
2023-01-04 00:37:19 +00:00
outputs = inputs@{ self, flake-parts, crane, pre-commit, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
2022-11-30 03:19:54 +00:00
imports = [ pre-commit.flakeModule ];
2023-08-23 00:50:29 +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 ./.;
2023-08-23 00:50:29 +00:00
nativeBuildInputs =
pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.libiconv ];
2022-11-30 01:41:05 +00:00
};
2023-08-23 00:50:29 +00:00
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;
2023-08-23 00:50:29 +00:00
RUST_SRC_PATH =
"${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
nativeBuildInputs =
builtins.attrValues { inherit (pkgs) cargo rustc; };
2023-01-04 00:37:19 +00:00
buildInputs = builtins.attrValues {
2023-08-23 00:50:29 +00:00
inherit (pkgs) rust-analyzer rustfmt clippy;
2023-01-04 00:37:19 +00:00
};
2022-11-30 01:41:05 +00:00
};
};
};
}