Add pre-commit hooks

This commit is contained in:
Dave Gallant
2021-01-24 16:19:48 -05:00
parent 088d3bca8f
commit 822c40cb4a
8 changed files with 73 additions and 57 deletions

1
.envrc Normal file
View File

@@ -0,0 +1 @@
use_nix

3
.gitignore vendored
View File

@@ -1,2 +1 @@
# avoid weird recursion problems
.dotfiles
.pre-commit-config.yaml

View File

@@ -9,7 +9,7 @@ This repo stores nix to manage my machines. The initial structure was inspired b
```console
$ git clone git@github.com:davegallant/nix-config.git
$ cd nix-config
$ sudo ./nixos-rebuild switch
$ sudo ./nixos-rebuild.sh switch
```
## Update

12
default.nix Normal file
View File

@@ -0,0 +1,12 @@
let
nix-pre-commit-hooks = import (builtins.fetchTarball
"https://github.com/cachix/pre-commit-hooks.nix/tarball/master");
in {
pre-commit-check = nix-pre-commit-hooks.run {
src = ./.;
hooks = {
shellcheck.enable = true;
nixfmt.enable = true;
};
};
}

View File

@@ -7,10 +7,11 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixos-20.09";
nixpkgs-master.url = "github:NixOS/nixpkgs";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
nixos-hardware.url = github:NixOS/nixos-hardware/master;
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
};
outputs = { self, home-manager, nixpkgs, nixpkgs-master, nixpkgs-unstable, nixos-hardware }: {
outputs = { self, home-manager, nixpkgs, nixpkgs-master, nixpkgs-unstable
, nixos-hardware }: {
nixosConfigurations = let
defaultModules = [
home-manager.nixosModules.home-manager
@@ -34,9 +35,7 @@
nixpkgs-unstable.flake = nixpkgs-unstable;
};
nixpkgs.overlays = [
(import ./overlays)
];
nixpkgs.overlays = [ (import ./overlays) ];
home-manager = {
useGlobalPkgs = true;

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
cd "$(dirname "$0")"
exec nixos-rebuild -I nixos-config=machines/$(hostname)/configuration.nix "$@" --flake '.#'

3
nixos-rebuild.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
cd "$(dirname "$0")" || exit
exec nixos-rebuild -I nixos-config="machines/$(hostname)/configuration.nix" "$@" --flake '.#'

5
shell.nix Normal file
View File

@@ -0,0 +1,5 @@
(import <nixpkgs> { }).mkShell {
shellHook = ''
${(import ./default.nix).pre-commit-check.shellHook}
'';
}