-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
146 lines (134 loc) · 3.67 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
{
description = "Lasy Oliwskie";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05-small";
flake-utils.url = "github:numtide/flake-utils";
flake-parts = {
type = "github";
owner = "hercules-ci";
repo = "flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
# this adds pre commit hooks via nix to our repo
git-hooks = {
type = "github";
owner = "cachix";
repo = "git-hooks.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
nixpkgs-stable.follows = "";
flake-compat.follows = "";
};
};
flake-checker = {
type = "github";
owner = "DeterminateSystems";
repo = "flake-checker";
};
# a tree-wide formatter
treefmt-nix = {
type = "github";
owner = "numtide";
repo = "treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{ self, ... }:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
imports = with inputs; [
git-hooks.flakeModule
treefmt-nix.flakeModule
];
perSystem =
{
pkgs,
lib,
config,
system,
...
}:
let
#
# don't check these
excludes = [ "flake.lock" ];
mkHook =
prev:
lib.attrsets.recursiveUpdate {
inherit excludes;
enable = true;
fail_fast = true;
verbose = true;
} prev;
in
with pkgs;
{
devShells.default = mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
buildInputs = [
self.checks.${system}.pre-commit-check.enabledPackages
circup
];
};
checks = {
pre-commit-check = inputs.git-hooks.lib.${system}.run {
src = ./.;
hooks = {
# make sure our nix code is of good quality before we commit
statix = mkHook { };
deadnix = mkHook { };
flake-checker = mkHook { package = inputs.flake-checker.packages.${system}.flake-checker; };
# ensure we have nice formatting
treefmt = mkHook { package = config.treefmt.build.wrapper; };
# Git police
check-merge-conflicts = mkHook { };
commitizen = mkHook { };
# Various Artists
check-added-large-files = mkHook { };
check-case-conflicts = mkHook { };
detect-private-keys = mkHook { };
fix-byte-order-marker = mkHook { };
mixed-line-endings = mkHook { };
};
};
};
treefmt = {
projectRootFile = "flake.nix";
programs = {
actionlint = {
enable = true;
};
ruff-format = {
enable = true;
};
ruff-check = {
enable = true;
};
deadnix = {
enable = true;
};
dos2unix = {
enable = true;
};
mdformat = {
enable = true;
};
nixfmt = {
enable = true;
};
};
settings.formatter = {
dos2unix = {
excludes = [ "docs/img*" ];
};
};
};
};
};
}