forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevshell.toml
More file actions
85 lines (71 loc) · 1.79 KB
/
devshell.toml
File metadata and controls
85 lines (71 loc) · 1.79 KB
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
imports = [ "git.hooks" ]
[devshell]
name = "nixpkgs"
packages = [
"fd",
"nixpkgs-fmt",
"editorconfig-checker",
]
[[commands]]
package = "editorconfig-checker"
category = "linters"
[[commands]]
package = "gitAndTools.gh"
category = "github"
[[commands]]
name = "bugs"
help = "List issues labeled as bugs"
category = "github"
command = "gh issue list --label=\"0.kind: bug\""
[[commands]]
name = "packaging-requests"
help = "List issues labeled as packaging requests (chill out work)"
category = "github"
command = "gh issue list --label=\"0.kind: packaging request\""
[[commands]]
name = "pr-status"
help = "Information about relevant PRs"
category = "github"
command = "gh pr status"
[[commands]]
name = "issue-status"
help = "Information about relevant issues"
category = "github"
command = "gh issue status"
[[commands]]
name = "fmt"
help = "Check Nix formatting"
category = "folder tree checks"
command = "nixpkgs-fmt ${@} ."
[[commands]]
name = "evalnix"
help = "Check Nix parsing"
category = "folder tree checks"
command = "fd --extension nix --exec nix-instantiate --parse --quiet {} >/dev/null"
[git.hooks]
enable = true
pre-commit.text = """
#!/usr/bin/env bash
set -eou pipefail
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(${git}/bin/git hash-object -t tree /dev/null)
fi
diff="git diff-index --name-only --cached $against --diff-filter d"
nix_files=($($diff -- '*.nix'))
all_files=($($diff))
# Format staged nix files.
if [[ -n "${nix_files[@]}" ]]; then
nixpkgs-fmt "${nix_files[@]}"
git add "${nix_files[@]}"
fi
# check editorconfig
if ! editorconfig-checker -- "${all_files[@]}"; then
echo -e "\nCode is not aligned with .editorconfig
Review the output and commit your fixes" >&2
exit 1
fi
"""