biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / applications / misc / electrum / update.nix
blob509a643780885ad27c89f0b19e8913cd57722ecf
1 { lib
2 , writeScript
3 , common-updater-scripts
4 , bash
5 , coreutils
6 , curl
7 , fetchurl
8 , gnugrep
9 , gnupg
10 , gnused
11 , nix
14 let
15   downloadPageUrl = "https://download.electrum.org";
17   signingKeys = lib.lists.map fetchurl [
18     {
19       url = "https://github.com/spesmilo/electrum/raw/master/pubkeys/Emzy.asc";
20       hash = "sha256-QG0cM6AKlSKFacVlhcso/xvrooUdF7oqoppyezt0hjE=";
21     }
22     {
23       url = "https://github.com/spesmilo/electrum/raw/master/pubkeys/ThomasV.asc";
24       hash = "sha256-37ApVZlI+2EevxQIKXVKVpktt1Ls3UbWq4dfio2ORdo=";
25     }
26     {
27       url = "https://github.com/spesmilo/electrum/raw/master/pubkeys/sombernight_releasekey.asc";
28       hash = "sha256-GgdPJ9TB5hh5SPCcTZURfqXkrU4qwl0dCci52V/wpdQ=";
29     }
30   ];
32   gpgImportPaths = lib.concatStringsSep " " signingKeys;
35 writeScript "update-electrum" ''
36 #! ${bash}/bin/bash
38 set -eu -o pipefail
40 export PATH=${lib.makeBinPath [
41   common-updater-scripts
42   coreutils
43   curl
44   gnugrep
45   gnupg
46   gnused
47   nix
50 version=$(curl -L --list-only -- '${downloadPageUrl}' \
51     | grep -Po '<a href="\K([[:digit:]]+\.?)+' \
52     | sort -Vu \
53     | tail -n1)
55 srcName=Electrum-$version
56 srcFile=$srcName.tar.gz
57 srcUrl="${downloadPageUrl}/$version/$srcFile"
58 sigUrl=$srcUrl.asc
59 sigFile=$srcFile.asc
61 [[ -e "$srcFile" ]] || curl -L -o "$srcFile" -- "$srcUrl"
62 [[ -e "$sigFile" ]] || curl -L -o "$sigFile" -- "$sigUrl"
64 export GNUPGHOME=$PWD/gnupg
65 mkdir -m 700 -p "$GNUPGHOME"
67 gpg --batch --import ${gpgImportPaths}
68 gpg --batch --verify "$sigFile" "$srcFile"
70 sha256=$(nix-prefetch-url --type sha256 "file://$PWD/$srcFile")
72 update-source-version electrum "$version" "$sha256"