mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-18 10:53:52 +00:00
plausible: adapt update script to new nix-prefetch-github
Take the opportunity to switch to SRI hashes.
This commit is contained in:
parent
205803c1ee
commit
551db1309c
@ -18,7 +18,7 @@ let
|
||||
owner = "plausible";
|
||||
repo = "analytics";
|
||||
rev = "v${version}";
|
||||
sha256 = "1ckw5cd4z96jkjhmzjq7k3kzjj7bvj38i5xq9r43cz0sn7w3470k";
|
||||
hash = "sha256-Exwy+LEafDZITriXiIbc60j555gHy1+hnNKkTxorfLI=";
|
||||
};
|
||||
|
||||
# TODO consider using `mix2nix` as soon as it supports git dependencies.
|
||||
|
@ -33,18 +33,18 @@ echo "$package_json" \
|
||||
> $dir/package.json
|
||||
|
||||
tarball_meta="$(nix-prefetch-github plausible analytics --rev "$latest")"
|
||||
tarball_hash="$(nix to-base32 sha256-$(jq -r '.sha256' <<< "$tarball_meta"))"
|
||||
tarball_hash="$(jq -r '.hash' <<< "$tarball_meta")"
|
||||
tarball_path="$(nix-build -E 'with import ./. {}; { p }: fetchFromGitHub (builtins.fromJSON p)' --argstr p "$tarball_meta")"
|
||||
fake_hash="$(nix-instantiate --eval -A lib.fakeSha256 | xargs echo)"
|
||||
fake_hash="$(nix-instantiate --eval -A lib.fakeHash | xargs echo)"
|
||||
|
||||
sed -i "$dir/default.nix" \
|
||||
-e 's,version = ".*",version = "'"$nix_version"'",' \
|
||||
-e '/^ src = fetchFromGitHub/,+4{;s/sha256 = "\(.*\)"/sha256 = "'"$tarball_hash"'"/}' \
|
||||
-e '/^ mixFodDeps =/,+3{;s/sha256 = "\(.*\)"/sha256 = "'"$fake_hash"'"/}'
|
||||
-e '/^ src = fetchFromGitHub/,+4{;s#hash = "\(.*\)"#hash = "'"$tarball_hash"'"#}' \
|
||||
-e '/^ mixFodDeps =/,+3{;s#hash = "\(.*\)"#hash = "'"$fake_hash"'"#}'
|
||||
|
||||
mix_hash="$(nix to-base32 $(nix-build -A plausible.mixFodDeps 2>&1 | tail -n3 | grep 'got:' | cut -d: -f2- | xargs echo || true))"
|
||||
mix_hash="$(nix-build -A plausible.mixFodDeps 2>&1 | tail -n3 | grep 'got:' | cut -d: -f2- | xargs echo || true)"
|
||||
|
||||
sed -i "$dir/default.nix" -e '/^ mixFodDeps =/,+3{;s/sha256 = "\(.*\)"/sha256 = "'"$mix_hash"'"/}'
|
||||
sed -i "$dir/default.nix" -e '/^ mixFodDeps =/,+3{;s#hash = "\(.*\)"#hash = "'"$mix_hash"'"#}'
|
||||
|
||||
tmp_setup_dir="$(mktemp -d)"
|
||||
trap "rm -rf $tmp_setup_dir" EXIT
|
||||
|
Loading…
Reference in New Issue
Block a user