Skip to content

Commit

Permalink
+ pre-commit-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
bbigras committed Dec 18, 2021
1 parent 7535b73 commit 9b3fe51
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/.envrc
/*.db
/dendrite-p2p-pinecone.key
/.pre-commit-config.yaml
26 changes: 25 additions & 1 deletion flake.lock

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

11 changes: 9 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,24 @@
url = "github:edolstra/flake-compat";
flake = false;
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};

outputs = { self, nixpkgs, flake-utils, dendrite, flake-compat }:
outputs = { nixpkgs, flake-utils, dendrite, pre-commit-hooks, ... }:
flake-utils.lib.eachDefaultSystem
(system:
let pkgs = import nixpkgs { inherit system; }; in
{
defaultPackage = (import ./build.nix { inherit pkgs dendrite; }).main;
packages.dendrite = (import ./build.nix { inherit pkgs dendrite; }).main;
packages.dockerImage = import ./image.nix { inherit pkgs dendrite; };
devShell = import ./shell.nix { inherit pkgs; };
devShell = import ./shell.nix { inherit pkgs pre-commit-hooks system; };
}
);
}
20 changes: 19 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
{ pkgs }:
{ pkgs, pre-commit-hooks, system }:

let
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
nix-linter.enable = true;
shellcheck.enable = true;
};
# generated files
excludes = [
"Cargo.nix"
];
};
in
pkgs.mkShell {
buildInputs = [
# keep this line if you use bash
pkgs.bashInteractive
];

shellHook = ''
${pre-commit-check.shellHook}
'';
}

0 comments on commit 9b3fe51

Please sign in to comment.