68 lines
1.9 KiB
Nix
68 lines
1.9 KiB
Nix
{
|
|
outputs = inputs: with inputs;
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
overlays = [ cargo2nix.overlays.default rust-overlay.overlays.default ];
|
|
};
|
|
rustPkgs = pkgs.rustBuilder.makePackageSet {
|
|
rustToolchain =pkgs.rust-bin.stable.latest.default;
|
|
packageFun = import ./Cargo.nix;
|
|
};
|
|
|
|
inherit (self.outputs.checks.${system}) pre-commit-check;
|
|
|
|
workspaceShell = rustPkgs.workspaceShell {
|
|
inherit (pre-commit-check) shellHook;
|
|
buildInputs = pre-commit-check.enabledPackages;
|
|
};
|
|
in
|
|
{
|
|
packages = rec {
|
|
hello-world = rustPkgs.workspace.cargo_test_flake { };
|
|
default = hello-world;
|
|
};
|
|
checks = {
|
|
pre-commit-check = git-hooks.lib.${system}.run {
|
|
src = ./.;
|
|
hooks = {
|
|
nixpkgs-fmt.enable = true;
|
|
cargo-check.enable = true;
|
|
clippy.enable = true;
|
|
rustfmt.enable = true;
|
|
};
|
|
};
|
|
};
|
|
formatter = pkgs.nixpkgs-fmt;
|
|
devShells = {
|
|
default = workspaceShell;
|
|
inherit (inputs.cargo2nix.outputs.devShells.${system}) bootstrap;
|
|
};
|
|
}
|
|
);
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
cargo2nix = {
|
|
url = "github:cargo2nix/cargo2nix";
|
|
inputs.flake-utils.follows = "flake-utils";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
git-hooks = {
|
|
url = "github:cachix/git-hooks.nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
inputs.gitignore.follows = "gitignore";
|
|
};
|
|
gitignore = {
|
|
url = "github:hercules-ci/gitignore.nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
}
|