fork/home-manager
git clone https://git.julia.blue/fork/home-manager
9dd107a1
master
1#! /usr/bin/env nix-shell 2#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/6616de389ed55fba6eeba60377fc04732d5a207c.tar.gz -i bash -p git gnugrep gnused findutils nixfmt 3 4nixfmt_args=() 5files=() 6 7for arg do 8 case $arg in 9 -h) 10 echo "$0 [-c]" 11 exit 12 ;; 13 -c) 14 nixfmt_args+=("$arg") 15 ;; 16 -*) 17 echo "unrecognised flag: $arg" >&2 18 exit 1 19 ;; 20 *) 21 files+=("$arg") 22 ;; 23 esac 24done 25 26# The excludes are for files touched by open pull requests and we want 27# to avoid merge conflicts. 28excludes=( 29 modules/default.nix 30 modules/files.nix 31 modules/home-environment.nix 32 modules/lib/default.nix 33 modules/lib/file-type.nix 34 modules/misc/news.nix 35 modules/programs/ssh.nix 36 modules/programs/zsh.nix 37 tests/default.nix 38) 39 40exclude_args=() 41for e in "${excludes[@]}"; do 42 exclude_args+=(-e "$e") 43done 44 45git_root=$(git rev-parse --show-toplevel) 46 47git ls-files -z --cached --others --full-name -- "${files[@]}" | 48 grep -z '\.nix$' | 49 grep -z -v "${exclude_args[@]}" | 50 sed -z "s|^|$git_root/|" | 51 xargs -0 nixfmt "${nixfmt_args[@]}"