From b1a2e9c9acdef88b639385db96c7ebc5e83b27a5 Mon Sep 17 00:00:00 2001 From: schnusch Date: Wed, 23 Nov 2022 23:59:42 +0100 Subject: [PATCH] firefox_decrypt: replace update script with nix-update --- .../security/firefox_decrypt/default.nix | 6 ++- pkgs/tools/security/firefox_decrypt/update.sh | 49 ------------------- 2 files changed, 5 insertions(+), 50 deletions(-) delete mode 100755 pkgs/tools/security/firefox_decrypt/update.sh diff --git a/pkgs/tools/security/firefox_decrypt/default.nix b/pkgs/tools/security/firefox_decrypt/default.nix index 3ca0774e22ea..86bfb5f72242 100644 --- a/pkgs/tools/security/firefox_decrypt/default.nix +++ b/pkgs/tools/security/firefox_decrypt/default.nix @@ -3,6 +3,7 @@ , stdenvNoCC , nss , wrapPython +, nix-update-script }: stdenvNoCC.mkDerivation rec { @@ -34,7 +35,10 @@ stdenvNoCC.mkDerivation rec { wrapPythonPrograms ''; - passthru.updateScript = ./update.sh; + passthru.updateScript = nix-update-script { + attrPath = pname; + extraArgs = [ "--version=branch" ]; + }; meta = with lib; { homepage = "https://github.com/unode/firefox_decrypt"; diff --git a/pkgs/tools/security/firefox_decrypt/update.sh b/pkgs/tools/security/firefox_decrypt/update.sh deleted file mode 100755 index a56807f0ba0c..000000000000 --- a/pkgs/tools/security/firefox_decrypt/update.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i bash -p common-updater-scripts git jq nix nix-prefetch-git -git_url='https://github.com/unode/firefox_decrypt.git' -git_branch='master' -git_dir='/var/tmp/firefox_decrypt.git' -nix_file="$(dirname "${BASH_SOURCE[0]}")/default.nix" -pkg='firefox_decrypt' - -set -euo pipefail - -info() { - if [ -t 2 ]; then - set -- '\033[32m%s\033[39m\n' "$@" - else - set -- '%s\n' "$@" - fi - printf "$@" >&2 -} - -old_rev=$(nix-instantiate --eval --strict --json -A "$pkg.src.rev" | jq -r) -old_version=$(nix-instantiate --eval --strict --json -A "$pkg.version" | jq -r) -today=$(LANG=C date -u +'%Y-%m-%d') - -info "fetching $git_url..." -if [ ! -d "$git_dir" ]; then - git init --initial-branch="$git_branch" "$git_dir" - git -C "$git_dir" remote add origin "$git_url" -fi -git -C "$git_dir" fetch origin "$git_branch" - -# use latest commit before today, we should not call the version *today* -# because there might still be commits coming -# use the day of the latest commit we picked as version -new_rev=$(git -C "$git_dir" log -n 1 --format='format:%H' --before="${today}T00:00:00Z" "origin/$git_branch") -new_version="unstable-$(git -C "$git_dir" log -n 1 --format='format:%cs' "$new_rev")" -info "latest commit before $today: $new_rev" - -if [ "$new_rev" = "$old_rev" ]; then - info "$pkg is up-to-date." - exit -fi - -new_sha256=$(nix-prefetch-git --rev "$new_rev" "$git_dir" | jq -r .sha256) -update-source-version "$pkg" \ - "$new_version" \ - "$new_sha256" \ - --rev="$new_rev" -git add "$nix_file" -git commit --verbose --message "$pkg: $old_version -> $new_version"