mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-14 07:14:00 -04:00
* pre-commit: add nix-vendor-hash pre-commit hook * nix: remove deprecation warning
21 lines
697 B
Bash
Executable File
21 lines
697 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
command -v nix >/dev/null 2>&1 || { printf '%s\n' "nix is required to update the vendorHash" >&2; exit 1; }
|
|
|
|
if output=$(nix build --no-link .#dms-shell.goModules 2>&1); then
|
|
exit 0
|
|
fi
|
|
|
|
new_hash=$(grep -m1 -oP 'got:\s+\K\S+' <<<"$output" || true)
|
|
[ -n "$new_hash" ] || { printf '%s\n' "Could not extract new vendorHash" >&2; printf '%s\n' "$output" >&2; exit 1; }
|
|
|
|
current_hash=$(grep -m1 -oP 'vendorHash = "\K[^"]+' flake.nix)
|
|
[ "$current_hash" = "$new_hash" ] && exit 0
|
|
|
|
sed -i "s|vendorHash = \"$current_hash\"|vendorHash = \"$new_hash\"|" flake.nix
|
|
if [ "${1:-}" = "--stage" ]; then
|
|
git add flake.nix
|
|
fi
|
|
nix build --no-link .#dms-shell.goModules
|