-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint.nix
More file actions
129 lines (114 loc) · 3.1 KB
/
lint.nix
File metadata and controls
129 lines (114 loc) · 3.1 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
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
{ pkgs }:
let
inherit (pkgs) callPackage;
licensePkg = callPackage ./license.nix { };
in
let
name = "lint";
version = "0.0.1";
description = "Lint code using various tools";
in
pkgs.stdenvNoCC.mkDerivation {
pname = name;
inherit version;
src = ./.;
dontBuild = true;
doCheck = false;
nativeBuildInputs = with pkgs; [
makeWrapper
];
buildInputs = with pkgs; [
# Include license checker
licensePkg
checkmake
golangci-lint
golangci-lint-langserver
nodePackages.eslint
nodePackages.prettier
shellcheck
python3Packages.flake8
python3Packages.pylint
python3Packages.black
python3Packages.isort
python3Packages.yamllint
nixfmt-rfc-style
statix
sqlfluff
squawk
jq
yq-go
redocly
];
installPhase = ''
mkdir -p $out/bin
mkdir -p $out/share/lint/config
# Copy the main script
cp scripts/${name} $out/bin/${name}
chmod +x $out/bin/${name}
# Copy shared configuration files
if [ -d shared ]; then
find shared -maxdepth 1 -type f -exec cp {} $out/share/lint/config/ \;
fi
# Create nixfmt-tree wrapper for directory formatting
cat > $out/bin/nixfmt-tree <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
# Wrapper for nixfmt that recursively formats Nix files in directories
# This avoids the deprecated behavior of passing directories to nixfmt directly
ARGS=()
DIRS=()
for arg in "$@"; do
if [[ -d "$arg" ]]; then
DIRS+=("$arg")
else
ARGS+=("$arg")
fi
done
if [[ ''${#DIRS[@]} -gt 0 ]]; then
for dir in "''${DIRS[@]}"; do
find "$dir" -name "*.nix" -type f -exec nixfmt "''${ARGS[@]}" {} +
done
else
nixfmt "''${ARGS[@]}"
fi
EOF
chmod +x $out/bin/nixfmt-tree
# Wrap nixfmt-tree to ensure nixfmt is in PATH
wrapProgram $out/bin/nixfmt-tree \
--prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.nixfmt-rfc-style ]}
# Wrap the script to ensure all dependencies are in PATH and set config path
wrapProgram $out/bin/${name} \
--prefix PATH : ${
pkgs.lib.makeBinPath [
pkgs.checkmake
pkgs.golangci-lint
pkgs.golangci-lint-langserver
pkgs.nodePackages.eslint
pkgs.nodePackages.prettier
pkgs.shellcheck
pkgs.python3Packages.flake8
pkgs.python3Packages.pylint
pkgs.python3Packages.black
pkgs.python3Packages.isort
pkgs.python3Packages.yamllint
pkgs.nixfmt-rfc-style
pkgs.statix
pkgs.sqlfluff
pkgs.squawk
pkgs.postgresql
pkgs.jq
pkgs.yq-go
pkgs.redocly
licensePkg
]
}:$out/bin \
--set LINT_CONFIG_DIR "$out/share/lint/config"
runHook postInstall
'';
meta = with pkgs.lib; {
inherit description;
platforms = platforms.unix;
maintainers = [ ];
license = licenses.mit;
};
}