aboutsummaryrefslogtreecommitdiff
path: root/utils.nix
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-08-10 17:43:08 -0300
committerEuAndreh <eu@euandre.org>2020-08-10 17:43:08 -0300
commit99c3d650d6dffa4ab5cba146cfde67c300e16fdc (patch)
treebfb27c895a239f093a8086cd16654874d1ef0f3e /utils.nix
parentSemi working setup: Terraform and LetsEncrypt working (diff)
downloadserver-99c3d650d6dffa4ab5cba146cfde67c300e16fdc.tar.gz
server-99c3d650d6dffa4ab5cba146cfde67c300e16fdc.tar.xz
Filter encrypted files from linting
Diffstat (limited to 'utils.nix')
-rw-r--r--utils.nix35
1 files changed, 19 insertions, 16 deletions
diff --git a/utils.nix b/utils.nix
index 5bcbb10..2c231d7 100644
--- a/utils.nix
+++ b/utils.nix
@@ -20,23 +20,26 @@
touch $out
'';
});
- formatNix = baseTask.overrideAttrs (baseAttrs: {
- name = "${baseAttrs.name}-nixfmt";
- buildInputs = baseAttrs.buildInputs ++ [ pkgs.nixfmt ];
- buildPhase = ''
- format() {
- nix_file="$1"
- diff <(nixfmt < "$nix_file") "$nix_file" || {
- echo "The $nix_file is unformatted. To fix it, run:"
- echo " nixfmt $nix_file"
- exit 1
+ formatNix = ignoredFindPattern:
+ baseTask.overrideAttrs (baseAttrs: rec {
+ name = "${baseAttrs.name}-nixfmt";
+ buildInputs = baseAttrs.buildInputs ++ [ pkgs.nixfmt ];
+ ignoredPattern =
+ if ignoredFindPattern == null then "" else ignoredFindPattern;
+ buildPhase = ''
+ format() {
+ nix_file="$1"
+ diff <(nixfmt < "$nix_file") "$nix_file" || {
+ echo "The $nix_file is unformatted. To fix it, run:"
+ echo " nixfmt $nix_file"
+ exit 1
+ }
}
- }
- export -f format
- find . -type f -name '*.nix' -print0 | xargs -0 -I{} bash -c "format {}" \;
- touch $out
- '';
- });
+ export -f format
+ find . -type f \( -name '*.nix' -and -regextype egrep ! -regex '${ignoredPattern}' \) -print0 | xargs -0 -I{} bash -c "format {}" \;
+ touch $out
+ '';
+ });
fixme = ignoredFiles:
baseTask.overrideAttrs (baseAttrs: rec {
name = "${baseAttrs.name}-fixme";