Skip to content

Commit

Permalink
chore: add pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
myypo committed Aug 18, 2024
1 parent 5ed68af commit 1c273cc
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 83 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
target
result

/.pre-commit-config.yaml

lua/*
!lua/.gitkeep
127 changes: 92 additions & 35 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

126 changes: 78 additions & 48 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";

pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";

neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
neovim-nightly-overlay.inputs.nixpkgs.follows = "nixpkgs";
Expand All @@ -11,61 +12,90 @@
};

outputs = inputs:
with inputs;
flake-utils.lib.eachDefaultSystem (
system: let
overlays = [fenix.overlays.default neovim-nightly-overlay.overlays.default];
pkgs = import nixpkgs {
inherit overlays system;
};
in {
packages = with pkgs; {
default = rustPlatform.buildRustPackage {
name = "compass";
src = lib.cleanSource ./.;
cargoLock = {
lockFile = ./Cargo.lock;
allowBuiltinFetchGit = true;
};
with inputs; let
forEachSupportedSystem = let
supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
in (
f:
nixpkgs.lib.genAttrs supportedSystems (
system:
f
(let
overlays = [fenix.overlays.default neovim-nightly-overlay.overlays.default];
in
import nixpkgs {inherit overlays system;})
)
);
in {
checks.pre-commit-check = forEachSupportedSystem (pkgs:
inputs.pre-commit-hooks.lib.${pkgs.system}.run {
src = ./.;
hooks = {
alejandra.enable = true;

doCheck = false;
rustfmt = {
enable = true;
packageOverrides.rustfmt = pkgs.fenix.complete.rustfmt;
};
clippy = {
enable = true;
packageOverrides.cargo = pkgs.fenix.complete.cargo;
packageOverrides.clippy = pkgs.fenix.complete.clippy;
settings.allFeatures = true;
settings.denyWarnings = true;
};
};
});

nativeBuildInputs = [
pkg-config
rustPlatform.bindgenHook
];
packages = forEachSupportedSystem (pkgs:
with pkgs; {
default = rustPlatform.buildRustPackage {
name = "compass";
src = lib.cleanSource ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};

doCheck = false;

nativeBuildInputs = [
pkg-config
rustPlatform.bindgenHook
];
};
});

devShells = with pkgs; {
default =
mkShell.override {
stdenv = stdenvAdapters.useMoldLinker clangStdenv;
}
mkShell {
packages = [
openssl
pkg-config
devShells = forEachSupportedSystem (pkgs:
with pkgs; {
default =
mkShell.override {
stdenv = stdenvAdapters.useMoldLinker clangStdenv;
}
{
inherit (self.checks.pre-commit-check.${pkgs.system}) shellHook;

neovim
packages = [
openssl
pkg-config

rust-analyzer-nightly
neovim

rustPlatform.bindgenHook
rust-analyzer-nightly

(fenix.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rust-std"
"rustc"
"rustfmt"
])
rustPlatform.bindgenHook

cargo-watch
];
};
};
}
);
(fenix.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rust-std"
"rustc"
"rustfmt"
])

cargo-watch
];
};
});
};
}

0 comments on commit 1c273cc

Please sign in to comment.