File tree 1 file changed +23
-7
lines changed
1 file changed +23
-7
lines changed Original file line number Diff line number Diff line change 290
290
'' ;
291
291
} ;
292
292
293
+ overwriteConfig =
294
+ mkOption {
295
+ type = types . bool ;
296
+ default = false ;
297
+ description =
298
+ ''
299
+ Whether to overwrite any existing config at `configPath`.
300
+
301
+ When enabled, any existing config will be overwritten without prompting.
302
+ '' ;
303
+ } ;
304
+
293
305
src =
294
306
lib . mkOption {
295
307
description = ''
397
409
398
410
config =
399
411
{
400
-
401
412
rawConfig =
402
413
{
403
414
repos =
430
441
echo 1>&2 "git-hooks.nix: updating $PWD repo"
431
442
[ -L ${ cfg . configPath } ] && unlink ${ cfg . configPath }
432
443
433
- if [ -e "'' ${GIT_WC}/${ cfg . configPath } " ]; then
434
- echo 1>&2 "git-hooks.nix: WARNING: Refusing to install because of pre-existing ${ cfg . configPath } "
435
- echo 1>&2 " 1. Translate ${ cfg . configPath } contents to the new syntax in your Nix file"
436
- echo 1>&2 " see https://github.com/cachix/git-hooks.nix#getting-started"
437
- echo 1>&2 " 2. remove ${ cfg . configPath } "
438
- echo 1>&2 " 3. add ${ cfg . configPath } to .gitignore"
444
+ if [ -e "'' ${GIT_WC}/${ cfg . configPath } " && ! ${ boolToString cfg . overwriteConfig } ]; then
445
+ echo 1>&2 "git-hooks.nix: WARNING: Refusing to install because of an existing config at ${ cfg . configPath } "
446
+ echo 1>&2 ""
447
+ echo 1>&2 " To migrate the existing config to a Nix configuration:"
448
+ echo 1>&2 " 1. Translate the contents of ${ cfg . configPath } into a Nix configuration."
449
+ echo 1>&2 " See https://github.com/cachix/git-hooks.nix#getting-started"
450
+ echo 1>&2 " 2. Remove ${ cfg . configPath } "
451
+ echo 1>&2 " 3. Add ${ cfg . configPath } to .gitignore"
452
+ echo 1>&2 ""
453
+ echo 1>&2 " To always overwrite the existing config, enable `overwriteConfig` in Nix."
454
+
439
455
else
440
456
if ${ boolToString cfg . addGcRoot } ; then
441
457
nix-store --add-root "'' ${GIT_WC}/${ cfg . configPath } " --indirect --realise ${ cfg . configFile }
You can’t perform that action at this time.
0 commit comments