blob: b6e85bdbccaf3667a35cd51dc436b64b758b06b1 (
plain) (
blame)
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
|
let
pkgs = import <nixpkgs> {};
rootSrc = pkgs.nix-gitignore.gitignoreSource [] ./.;
baseTask = pkgs.stdenv.mkDerivation {
name = "dotfiles-task";
src = rootSrc;
buildInputs = [];
phases = "unpackPhase buildPhase";
buildPhase = ''
echo "ERROR: base task buildPhase not overriden."
exit 1
'';
};
in with pkgs; with pkgs.stdenv; rec {
subtasks = rec {
shellcheck = baseTask.overrideAttrs(baseAttrs: {
name = "${baseAttrs.name}-shellcheck";
buildInputs = baseAttrs.buildInputs ++ [ pkgs.shellcheck ];
buildPhase = ''
export SHELLCHECK_OPTS="-e SC1090 -e SC1091 -e SC2139"
ignored='(encrypted|os-installation.sh|notmuch-post.sh)'
find . -type f -name '*.sh' | grep -E -v $ignored | xargs shellcheck
touch $out
'';
});
fixme = baseTask.overrideAttrs(baseAttrs: {
name = "${baseAttrs.name}-fixme";
buildInputs = baseAttrs.buildInputs ++ [ ag ];
buildPhase = ''
ag FIXME --ignore default.nix || {
touch $out
}
'';
});
};
test = baseTask.overrideAttrs(baseAttrs: rec {
name = "${baseAttrs.name}-test";
buildInputs = [
subtasks.shellcheck
subtasks.fixme
];
buildPhase = ''
echo "Ran tests for:"
for d in ${builtins.toString buildInputs}; do
echo " $d"
done
echo "All tests passed!"
touch $out
'';
});
}
|