forcebot_rs/flake.nix
notohh 200d2a86d3
Some checks failed
ci/woodpecker/pr/cargo-checks Pipeline was successful
ci/woodpecker/cron/flake-update Pipeline failed
nix: add pre-commit-hooks
2024-04-08 18:45:30 -04:00

80 lines
2.1 KiB
Nix

{
description = "A basic flake";
inputs = {
systems.url = "github:nix-systems/default-linux";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
fenix.url = "github:nix-community/fenix/monthly";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
};
outputs = {
self,
systems,
nixpkgs,
fenix,
pre-commit-hooks,
}: let
eachSystem = nixpkgs.lib.genAttrs (import systems);
pkgsFor = eachSystem (system:
import nixpkgs {
localSystem.system = system;
overlays = [fenix.overlays.default];
});
in {
packages = eachSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
inherit ((builtins.fromTOML (builtins.readFile ./Cargo.toml)).package) version;
in {
default = pkgsFor.${system}.rustPlatform.buildRustPackage {
pname = "forcebot_rs";
version = "${version}";
src = self;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = with pkgs; [pkg-config];
buildInputs = with pkgs; [openssl];
doCheck = false;
};
});
checks = eachSystem (system: {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
# rust
rustfmt.enable = true;
clippy.enable = true;
# nix
statix.enable = true;
alejandra.enable = true;
deadnix.enable = true;
};
};
});
devShells = eachSystem (system: {
default = pkgsFor.${system}.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
packages = with pkgsFor.${system}; [
nil
alejandra
rust-analyzer-nightly
(fenix.packages.${system}.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
])
];
RUST_BACKTRACE = 1;
RUST_SRC_PATH = "${fenix.packages.${system}.complete.rust-src}/lib/rustlib/src/rust/library";
};
});
nixosModules.default = import ./nix/module.nix {inherit self;};
};
}