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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
{ stdenv, lib, fetchurl, fetchgit, fetchpatch, runCommand, p7zip, jq
, winePackages, pcsclite
}:
let
patchedWine = let
libpcsclite = "${pcsclite}/lib/libpcsclite.so";
in winePackages.minimal.overrideAttrs (drv: {
scard4wine = fetchgit {
url = "git://git.code.sf.net/p/scard4wine/code";
rev = "c14c02c80bf1f2bb4cedd1f53a3a2ab9c48bed76";
sha256 = "0ffmbl9mdnaih4h3ggpnzqbih3kgbwl3wv6j1ag5s4czn8gcpdq3";
};
prePatch = (drv.prePatch or "") + ''
cp -t dlls/winscard "$scard4wine/src/"*
sed -i -re 's,"libpcsclite\.so(\.[0-9]+)*","${libpcsclite}",' \
dlls/winscard/winscard.c
'';
patches = (drv.patches or []) ++ [
./winscard.patch
(fetchpatch {
url = "http://achurch.org/patch-pile/wine/3.0/disable-unixfs.diff";
sha256 = "1yj3walwalya9g9aajcp4iygh348npp9dmks66r9dvwbd3fa8wcb";
})
];
configureFlags = lib.toList (drv.configureFlags or []) ++ [
"--disable-unixfs"
];
postConfigure = (drv.postConfigure or "") + ''
# The wineprefix is within the Nix store, so let's ensure wine doesn't
# check the owner of the files:
sed -i -e '/HAVE_GETUID/d' include/config.h
'';
});
in stdenv.mkDerivation rec {
name = "TRAVIC-Sign-${version}";
version = "3.1.3.0";
src = fetchurl {
url = "https://service.santanderbank.de/special/banking/files/"
+ "${name}-Installer.exe";
sha256 = "19a14av3bg6i4iy5q5pa737cwxznqji0lcrapxw0q6qb8rs1rhs7";
};
extensionId = "ilpoejcegjjlgpobjkpjmddkbdkdndaj";
buildInputs = [ p7zip jq ];
unpackCmd = "7z x -y -otavic-sign $curSrc";
phases = [ "unpackPhase" "patchPhase" "installPhase" ];
postPatch = ''
jq '.allowed_origins = [
"chrome-extension://'"$extensionId"'/"
] | .path = "'"$out/share/libexec/travic-sign/travic-sign"'"
| del(.allowed_extensions)' manifest-firefox.json > host.json
7z x -y -oextension FirefoxExtension.xpi
jq '.content_scripts[].matches = ["https://karte.santanderbank.de/*"] | {
# All the object attributes that we want to have (nothing more):
background, web_accessible_resources, content_scripts, page_action,
permissions, author, version, description, name, manifest_version
}' extension/manifest.json > new_manifest.json
mv new_manifest.json extension/manifest.json
(cd extension && 7z a -tzip ../travic-sign.crx *)
'';
winePrefix = runCommand "empty-wineprefix" {
buildInputs = [ patchedWine ];
} ''
export WINEPREFIX="$out"
mkdir -p "$out"
wine wineboot.exe
'';
installPhase = ''
libexec="$out/share/libexec/travic-sign"
install -vD -m 0644 TRAVIC-Sign-Service.exe "$libexec/service.exe"
install -vD -m 0644 host.json \
"$out/etc/chromium/native-messaging-hosts/travic-sign.json"
install -vD -m 0644 travic-sign.crx \
"$out/share/chromium/extensions/$extensionId.crx"
cat > "$libexec/travic-sign" <<EOF
#!${stdenv.shell}
export WINEPREFIX="$winePrefix"
exec ${patchedWine}/bin/wine "$libexec/service.exe"
EOF
chmod +x "$libexec/travic-sign"
'';
}
|