Skip to content

Commit

Permalink
Preserve executable bit in files
Browse files Browse the repository at this point in the history
Some commit hooks such as
`pre-commit-hooks/check-executables-have-shebangs` are designed to run
only on executable files via `types = ["executable"]` and the python
tool `identify` uses the executable bit of a file when generating file
tags, so `executable` is only listed when that bit is set.

By removing `--no-preserve=mode` we get to keep the executable bit. We
still need everything to be writable though.
  • Loading branch information
tljuniper committed Jun 15, 2022
1 parent 521a524 commit b6f394d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/pre-commit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ let
runCommand "pre-commit-run" { buildInputs = [ git ]; } ''
set +e
HOME=$PWD
cp --no-preserve=mode -R ${cfg.rootSrc} src
# Use `chmod +w` instead of `cp --no-preserve=mode` to be able to write and to
# preserve the executable bit at the same time
cp -R ${cfg.rootSrc} src
chmod -R +w src
ln -fs ${configFile} src/.pre-commit-config.yaml
cd src
rm -rf src/.git
Expand Down

0 comments on commit b6f394d

Please sign in to comment.