forked from Fachschaft/nixConfig
added pre-commit support for automated code linting/formatting
This commit is contained in:
parent
7acba2a5bb
commit
f5b2ddaf11
4 changed files with 117 additions and 20 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,4 +2,4 @@
|
|||
# Ignore build outputs from performing a nix-build or `nix build` command
|
||||
result
|
||||
result-*
|
||||
|
||||
.pre-commit-config.yaml
|
||||
|
|
|
@ -1,28 +1,60 @@
|
|||
{inputs, ...}:
|
||||
{
|
||||
{inputs, ...}: {
|
||||
# debug = true;
|
||||
# We only define machines config in this flake yet, so we only include
|
||||
# the module that builds these. This file might get fuller, if we need to
|
||||
# build our own packages, that are not flakes.
|
||||
imports = [ ./nixos/flake-module.nix
|
||||
# To import a flake module
|
||||
# 1. Add foo to inputs
|
||||
# 2. Add foo as a parameter to the outputs function
|
||||
# 3. Add here: foo.flakeModule
|
||||
|
||||
imports = [
|
||||
./nixos/flake-module.nix
|
||||
inputs.pre-commit-hooks.flakeModule
|
||||
# To import a flake module
|
||||
# 1. Add foo to inputs
|
||||
# 2. Add foo as a parameter to the outputs function
|
||||
# 3. Add here: foo.flakeModule
|
||||
];
|
||||
systems = [ "x86_64-linux"];
|
||||
# perSystem = { config, self', inputs', pkgs, system, ... }: {
|
||||
# Per-system attributes can be defined here. The self' and inputs'
|
||||
# module parameters provide easy access to attributes of the same
|
||||
# system.
|
||||
systems = ["x86_64-linux"];
|
||||
perSystem = {
|
||||
config,
|
||||
inputs',
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
devShells.default = config.pre-commit.devShell;
|
||||
|
||||
pre-commit = let
|
||||
generatedFiles = [
|
||||
"hardware-configuration\\.nix"
|
||||
];
|
||||
in {
|
||||
check.enable = true;
|
||||
pkgs = inputs'.nixpkgs.legacyPackages;
|
||||
settings = {
|
||||
# for some reason statix takes it config differently than all the other hooks.
|
||||
settings.statix = {
|
||||
format = "stderr";
|
||||
ignore = generatedFiles;
|
||||
};
|
||||
hooks = {
|
||||
nil.enable = true;
|
||||
statix.enable = true;
|
||||
deadnix = {
|
||||
enable = true;
|
||||
excludes = generatedFiles;
|
||||
};
|
||||
alejandra.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Per-system attributes can be defined here. The self' and inputs'
|
||||
# module parameters provide easy access to attributes of the same
|
||||
# system.
|
||||
};
|
||||
|
||||
# Equivalent to inputs'.nixpkgs.legacyPackages.hello;
|
||||
# };
|
||||
# flake = {
|
||||
# The usual flake attributes can be defined here, including system-
|
||||
# agnostic ones like nixosModule and system-enumerating ones, although
|
||||
# those are more easily expressed in perSystem.
|
||||
# flake = {
|
||||
# The usual flake attributes can be defined here, including system-
|
||||
# agnostic ones like nixosModule and system-enumerating ones, although
|
||||
# those are more easily expressed in perSystem.
|
||||
|
||||
# };
|
||||
# };
|
||||
}
|
||||
|
|
56
flake.lock
56
flake.lock
|
@ -33,6 +33,24 @@
|
|||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1685518550,
|
||||
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"impermanence": {
|
||||
"locked": {
|
||||
"lastModified": 1697303681,
|
||||
|
@ -151,12 +169,35 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"pre-commit-hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": [],
|
||||
"flake-utils": "flake-utils",
|
||||
"gitignore": [],
|
||||
"nixpkgs": [],
|
||||
"nixpkgs-stable": []
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1699271226,
|
||||
"narHash": "sha256-8Jt1KW3xTjolD6c6OjJm9USx/jmL+VVmbooADCkdDfU=",
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "ea758da1a6dcde6dc36db348ed690d09b9864128",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"impermanence": "impermanence",
|
||||
"nixos-mailserver": "nixos-mailserver",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"pre-commit-hooks": "pre-commit-hooks",
|
||||
"sops-nix": "sops-nix"
|
||||
}
|
||||
},
|
||||
|
@ -181,6 +222,21 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1605370193,
|
||||
|
|
|
@ -17,6 +17,15 @@
|
|||
impermanence = {
|
||||
url = "github:nix-community/impermanence";
|
||||
};
|
||||
pre-commit-hooks = {
|
||||
url = "github:cachix/pre-commit-hooks.nix";
|
||||
inputs = {
|
||||
flake-compat.follows = "";
|
||||
gitignore.follows = "";
|
||||
nixpkgs-stable.follows = "";
|
||||
nixpkgs.follows = "";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
outputs = inputs@{ flake-parts, ... }:
|
||||
|
|
Loading…
Reference in a new issue