diff --git a/default.nix b/default.nix index 28709d7..71570cc 100644 --- a/default.nix +++ b/default.nix @@ -47,7 +47,7 @@ let cp -a dist $out ''; npmInstallFlags = "--no-audit --no-progress --no-fund"; - npmDepsHash = "sha256-44xcyVk5KcurQLkVJv1MeAj+Pfcu53664pvVgHdyv3E="; + npmDepsHash = "sha256-p4rTpy0t8aajbubvtF1TA83/FFqvfKEOPBb5T0ZRfQY="; npmPackFlags = [ "--ignore-scripts" ]; }; @@ -89,6 +89,7 @@ in packages = [ go golangci-lint + pkgs.prefetch-npm-deps nodejs @@ -116,6 +117,24 @@ in npm --prefix app/frontend run fix ''; } + { + name = "pre-commit"; + help = "Format and fix found issues"; + command = '' + cd ''$PRJ_ROOT + golangci-lint run --sort-results --out-format tab --fix + npm --prefix ''$PRJ_ROOT/app/frontend run fix + + echo "Calculating npm deps" + HASH=''$(prefetch-npm-deps ''$PRJ_ROOT/app/frontend/package-lock.json 2> /dev/null) + [[ ''$HASH = sha256* ]] && echo "Hash is ''$HASH" + [[ ''$HASH != sha256* ]] && echo "Failed" && exit 137 + + # Replace the first occurence of npmDepsHash with the new calculated hash in this file + sed -i "0,/npmDepsHash =/{s@npmDepsHash = .*@npmDepsHash = \"''$HASH\";@}" ''$PRJ_ROOT/default.nix + + ''; + } { name = "dev"; help = "Starts the javascript project in dev";