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