77 lines
1.7 KiB
Nix
77 lines
1.7 KiB
Nix
{
|
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
inputs.git-hooks.url = "github:cachix/git-hooks.nix";
|
|
inputs.git-hooks.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
outputs = {
|
|
self,
|
|
git-hooks,
|
|
nixpkgs,
|
|
}: let
|
|
inherit (self) outputs;
|
|
supportedSystems = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
|
|
"x86_64-darwin"
|
|
"aarch64-darwin"
|
|
];
|
|
forEachSupportedSystem = nixpkgs.lib.genAttrs supportedSystems;
|
|
in {
|
|
formatter = forEachSupportedSystem (system: nixpkgs.legacyPackages.${system}.alejandra);
|
|
|
|
checks = forEachSupportedSystem (system: {
|
|
pre-commit-check = git-hooks.lib.${system}.run {
|
|
src = ./.;
|
|
hooks = {
|
|
alejandra.enable = true;
|
|
clippy = {
|
|
enable = true;
|
|
};
|
|
rustfmt = {
|
|
enable = true;
|
|
};
|
|
cargo-test = {
|
|
enable = true;
|
|
name = "cargo test";
|
|
entry = "cargo test";
|
|
pass_filenames = false;
|
|
};
|
|
};
|
|
};
|
|
});
|
|
|
|
devShells = forEachSupportedSystem (system: let
|
|
pkgs = import nixpkgs {inherit system;};
|
|
in {
|
|
rust-dev = pkgs.mkShell {
|
|
inherit (outputs.checks.${system}.pre-commit-check) shellHook;
|
|
|
|
buildInputs = with pkgs;
|
|
[
|
|
cargo
|
|
rustc
|
|
rustfmt
|
|
rustPackages.clippy
|
|
rust-analyzer
|
|
|
|
# linker
|
|
clang
|
|
mold
|
|
|
|
# debugger
|
|
lldb
|
|
|
|
# libs
|
|
libopus
|
|
openssl
|
|
pkg-config
|
|
]
|
|
++ outputs.checks.${system}.pre-commit-check.enabledPackages;
|
|
};
|
|
|
|
default = outputs.devShells.${system}.rust-dev;
|
|
});
|
|
};
|
|
}
|