File tree 4 files changed +159
-3
lines changed
4 files changed +159
-3
lines changed Original file line number Diff line number Diff line change @@ -18,3 +18,5 @@ playground-temp
18
18
temp
19
19
TODOs.md
20
20
.eslintcache
21
+ .direnv /
22
+ .pre-commit-config.yaml
Original file line number Diff line number Diff line change @@ -62,7 +62,8 @@ Nixpkgs 源码等各种资料中提取出我需要的信息,同时还要忽略
62
62
我写这本小书的原因只是因为没有人为当时还是新手的我做这件事,如上所述,社区的文档太乱了,所以我选择自己动手,丰衣足食。
63
63
即使我知道我可能会犯错,但这总比什么都不做要好得多。
64
64
65
- 我希望这本书能帮助更多的人,让他们能够体验到 NixOS 的乐趣。希望你们喜欢它!
65
+ 我希望这本书能帮助更多的人,让他们能够体验到 NixOS 的乐趣。希望你们喜欢它!
66
+
66
67
67
68
## 本书的特点
68
69
Original file line number Diff line number Diff line change 4
4
inputs = {
5
5
nixpkgs . url = "github:NixOS/nixpkgs/nixos-23.11" ;
6
6
flake-utils . url = "github:numtide/flake-utils" ;
7
+ pre-commit-hooks . url = "github:cachix/pre-commit-hooks.nix" ;
7
8
} ;
8
9
9
10
outputs = {
10
11
self ,
11
12
nixpkgs ,
12
13
flake-utils ,
14
+ pre-commit-hooks ,
13
15
} :
14
16
flake-utils . lib . eachDefaultSystem ( system : let
15
17
overlays = [
21
23
] ;
22
24
pkgs = import nixpkgs { inherit overlays system ; } ;
23
25
pkgs_chromium = import nixpkgs { inherit system ; } ;
24
- packages = with pkgs ; [ node2nix nodejs pnpm yarn git ] ;
26
+ packages = with pkgs ; [
27
+ node2nix
28
+ nodejs
29
+ pnpm
30
+ yarn
31
+
32
+ git
33
+ typos
34
+ alejandra
35
+ ] ;
25
36
in {
37
+ checks = {
38
+ pre-commit-check = pre-commit-hooks . lib . ${ system } . run {
39
+ src = ./. ;
40
+ hooks = {
41
+ typos . enable = true ; # Source code spell checker
42
+ alejandra . enable = true ; # Nix linter
43
+ } ;
44
+ settings = {
45
+ typos = {
46
+ write = true ; # Automatically fix typos
47
+ ignored-words = [ ] ;
48
+ } ;
49
+ } ;
50
+ } ;
51
+ } ;
52
+
26
53
devShells . default = pkgs . mkShell {
27
54
inherit packages ;
28
55
29
56
shellHook = ''
30
57
echo "node `${ pkgs . nodejs } /bin/node --version`"
58
+ ${ self . checks . ${ system } . pre-commit-check . shellHook }
31
59
'' ;
32
60
} ;
33
61
You can’t perform that action at this time.
0 commit comments