-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathshellcheck.nix
44 lines (41 loc) · 857 Bytes
/
shellcheck.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
{
self,
mkTest,
lib,
file,
shellcheck,
}:
let
inherit (lib.lists) any;
inherit (lib.sources) cleanSourceWith;
inherit (lib.strings) hasInfix hasSuffix;
in
mkTest {
name = "lint-shellcheck";
src = cleanSourceWith {
filter =
path: type:
type == "directory"
|| hasInfix "dotfiles/zsh" path
|| hasInfix "pkgs/scripts" path
|| any (ext: hasSuffix ext (baseNameOf path)) [
".zsh"
".bash"
".sh"
".ksh"
];
src = self;
};
checkInputs = [
file
shellcheck
];
checkPhase = ''
mkdir -p $out
scripts=$(find pkgs/scripts -exec file --mime-type {} + \
| grep -e 'text/x-shellscript' \
| cut -d ':' -f 1)
shellcheck $scripts | tee $out/test.log
shellcheck home-config/dotfiles/zsh/*.zsh --shell=bash | tee -a $out/test.log
'';
}