File tree 2 files changed +29
-7
lines changed
2 files changed +29
-7
lines changed Original file line number Diff line number Diff line change 22
22
# PLEASE keep this sorted alphabetically.
23
23
options . settings =
24
24
{
25
+ runtimeDeps = mkOption {
26
+ type = types . listOf types . package ;
27
+ description = lib . mdDoc "Runtime dependencies needed to run the checks." ;
28
+ default = [ ] ;
29
+ example = "[ pkgs.openssl ]" ;
30
+ } ;
25
31
alejandra =
26
32
{
27
33
check =
@@ -1039,6 +1045,12 @@ in
1039
1045
description = lib . mdDoc "Path to Cargo.toml" ;
1040
1046
default = null ;
1041
1047
} ;
1048
+ cargoDeps = mkOption {
1049
+ type = types . nullOr types . attrs ;
1050
+ description = lib . mdDoc "Cargo dependencies" ;
1051
+ example = "pkgs.rustPlatform.importCargoLock { lockFile = ./Cargo.lock; }" ;
1052
+ default = null ;
1053
+ } ;
1042
1054
} ;
1043
1055
statix =
1044
1056
{
Original file line number Diff line number Diff line change 13
13
;
14
14
15
15
inherit ( pkgs ) runCommand writeText git ;
16
+ inherit ( pkgs . rustPlatform ) cargoSetupHook ;
17
+ inherit ( pkgs . stdenv ) mkDerivation ;
16
18
17
19
cfg = config ;
18
20
install_stages = lib . unique ( cfg . default_stages ++ ( builtins . concatLists ( lib . mapAttrsToList ( _ : h : h . stages ) enabledHooks ) ) ) ;
@@ -197,17 +199,24 @@ let
197
199
} >$out
198
200
'' ;
199
201
200
- run =
201
- runCommand "pre-commit-run" { buildInputs = [ git ] ; } ''
202
+ run = mkDerivation {
203
+ name = "pre-commit-run" ;
204
+
205
+ src = cfg . rootSrc ;
206
+ buildInputs = [ git ] ;
207
+ nativeBuildInputs = config . settings . runtimeDeps
208
+ ++ ( if config . settings . rust . cargoDeps != null
209
+ then [
210
+ cargoSetupHook
211
+ ]
212
+ else [ ] ) ;
213
+ cargoDeps = config . settings . rust . cargoDeps ;
214
+ buildPhase = ''
202
215
set +e
203
216
HOME=$PWD
204
217
# Use `chmod +w` instead of `cp --no-preserve=mode` to be able to write and to
205
218
# preserve the executable bit at the same time
206
- cp -R ${ cfg . rootSrc } src
207
- chmod -R +w src
208
- ln -fs ${ configFile } src/.pre-commit-config.yaml
209
- cd src
210
- rm -rf .git
219
+ ln -fs ${ configFile } .pre-commit-config.yaml
211
220
git init
212
221
git add .
213
222
git config --global user.email "[email protected] "
226
235
touch $out
227
236
[ $? -eq 0 ] && exit $exitcode
228
237
'' ;
238
+ } ;
229
239
in
230
240
{
231
241
options =
You can’t perform that action at this time.
0 commit comments