blob: 2b6cd7049a5cecde1ad398ac66876f6b5527d130 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
{ autoPatchelfHook
, electron
, fetchurl
, lib
, makeWrapper
, squashfsTools
, stdenv
}:
stdenv.mkDerivation rec {
pname = "authy";
# curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/authy?channel=stable' | jq '.download_url,.version'
version = "2.2.1";
rev = "11";
src = fetchurl {
url = "https://api.snapcraft.io/api/v1/snaps/download/H8ZpNgIoPyvmkgxOWw5MSzsXK1wRZiHn_${rev}.snap";
sha256 = "sha256-/a0pMXVd7mEp7oaN2mBIJv5uOv1zQ3gvfgiz1XL9ZmM=";
};
nativeBuildInputs = [ autoPatchelfHook makeWrapper squashfsTools ];
unpackPhase = ''
runHook preUnpack
unsquashfs "$src"
cd squashfs-root
if ! grep -q '${version}' meta/snap.yaml; then
echo "Package version differs from version found in snap metadata:"
grep 'version: ' meta/snap.yaml
echo "While the nix package specifies: ${version}."
echo "You probably chose the wrong revision or forgot to update the nix version."
exit 1
fi
runHook postUnpack
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/share/applications $out/share/pixmaps/apps
# Copy only what is needed
cp -r resources* $out/
cp -r locales* $out/
cp meta/gui/authy.desktop $out/share/applications/
cp meta/gui/icon.png $out/share/pixmaps/authy.png
# Replace icon name in Desktop file
sed -i 's|''${SNAP}/meta/gui/icon.png|authy|g' "$out/share/applications/authy.desktop"
runHook postInstall
'';
postFixup = ''
makeWrapper ${electron}/bin/electron $out/bin/${pname} \
--add-flags $out/resources/app.asar
'';
meta = with lib; {
homepage = "https://www.authy.com";
description = "Twilio Authy two factor authentication desktop application";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = licenses.unfree;
maintainers = with maintainers; [ iammrinal0 ];
platforms = [ "x86_64-linux" ];
};
}
|