66 lines
1.2 KiB
Bash
Executable file
66 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
if git rev-parse --verify HEAD >/dev/null 2>&1
|
|
then
|
|
against=HEAD
|
|
else
|
|
# Initial commit: diff against an empty tree object
|
|
against=$(${git}/bin/git hash-object -t tree /dev/null)
|
|
fi
|
|
|
|
diff="git diff-index --name-only --cached $against --diff-filter d"
|
|
|
|
nix_files=($($diff -- '*.nix'))
|
|
all_files=($($diff))
|
|
|
|
# Format staged nix files.
|
|
if [[ -n "${nix_files[@]}" ]]; then
|
|
nixpkgs-fmt "${nix_files[@]}" \
|
|
&& git add "${nix_files[@]}"
|
|
fi
|
|
|
|
# check editorconfig
|
|
editorconfig-checker -- "${all_files[@]}"
|
|
if [[ $? != '0' ]]; then
|
|
printf "%b\n" \
|
|
"\nCode is not aligned with .editorconfig" \
|
|
"Review the output and commit your fixes" >&2
|
|
exit 1
|
|
fi
|
|
|
|
PUBLIC_FILES=[
|
|
'modules/*'
|
|
'doc/*'
|
|
'hosts/bootstrap.nix'
|
|
'hosts/PubSolarOS.nix'
|
|
'iso/*'
|
|
'lib/*'
|
|
'overlays/*'
|
|
'pkgs/*'
|
|
'profiles/base-user/*'
|
|
'profiles/cachix/*'
|
|
'profiles/core/*'
|
|
'profiles/gaming/*'
|
|
'shell/*'
|
|
'users/modules/*'
|
|
'users/nixos/*'
|
|
'users/profiles/*'
|
|
'users/root/*'
|
|
'.drone/*'
|
|
'.github/*'
|
|
'.drone.yml'
|
|
'.editorconfig'
|
|
'.envrc'
|
|
'.gitignore'
|
|
'CHANGELOG.md'
|
|
'COPYING'
|
|
'default.nix'
|
|
'flake.nix'
|
|
'CHANGELOG.md'
|
|
'CHANGELOG.md'
|
|
'README.md'
|
|
'shell.nix'
|
|
]
|
|
public_files=($($diff -- 'modules/*'))
|
|
private_files=($($diff -- '*.nix'))
|