generated from nix-community/nur-packages-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kindle.nix
66 lines (55 loc) · 1.67 KB
/
kindle.nix
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
{ pkgs
, lib
, stdenv
, wine
, p7zip
, callPackage
, version ? "1.17.44170"
}:
let
versions = import ./versions.nix;
in
stdenv.mkDerivation {
pname = "kindle";
inherit version;
src = versions.${version}.src;
# VeriSign Class 3 Public Primary Certification Authority - G5
# PEM only. this should work too
cert = builtins.fetchurl {
url = "https://github.com/dooglus/intersango/raw/master/cert/facacbc6.0";
sha256 = "sha256:198rixz2ichmzspss3s6wn4zz44p98cq9al52vks0b037cy0p92a";
};
propagatedBuildInputs = [ wine ];
nativeBuildInputs = [ p7zip ];
phases = "buildPhase";
buildPhase = ''
mkdir -p $out/opt/kindle
cd $out/opt/kindle
7z x -y $src
# -> Kindle.exe
mkdir -p $out/etc/ssl/certs
cp -v $cert $out/etc/ssl/certs/facacbc6.0
mkdir $out/bin
cat >$out/bin/kindle <<EOF
#! /bin/sh
export PATH=$PATH:${wine}/bin
if ! [ -e /etc/ssl/certs/facacbc6.0 ]; then
echo FIXME you must sudo and add the SSL certificate /etc/ssl/certs/facacbc6.0
echo to fix: unable to connect https://bugs.winehq.org/show_bug.cgi?id=50471
echo please run:
echo "sudo mkdir -p /etc/ssl/certs/ && sudo ln -s $out/etc/ssl/certs/facacbc6.0 /etc/ssl/certs/facacbc6.0"
echo "TODO find a better solution with LD_PRELOAD (intercept syscalls: statx, fopen, ...)" \
"to provide the virtual file /etc/ssl/certs/facacbc6.0"
exit 1
fi
wine $out/opt/kindle/Kindle.exe "\$@"
EOF
chmod +x $out/bin/kindle
'';
meta = with lib; {
description = "Amazon ebook reader";
homepage = "https://www.amazon.com/b?node=16571048011";
license = licenses.unfree;
platforms = platforms.linux;
};
}