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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
{ stdenv
, lib
, requireFile
, fetchpatch
, runCommand
, rcu
, testers
, copyDesktopItems
, desktopToDarwinBundle
, libsForQt5
, makeDesktopItem
, python3Packages
, system-config-printer
}:
python3Packages.buildPythonApplication rec {
pname = "rcu";
version = "2024.001n";
format = "other";
src = let
src-tarball = requireFile {
name = "rcu-d${version}-source.tar.gz";
sha256 = "1snmf2cr242k946q6fh5b5fqdyafdbs8gbbdzchjhm7n9r1kxyca";
url = "http://www.davisr.me/projects/rcu/";
};
in runCommand "${src-tarball.name}-unpacked" {} ''
gunzip -ck ${src-tarball} | tar -xvf-
mv rcu $out
'';
patches = [
./Port-to-paramiko-3.x.patch
];
postPatch = ''
substituteInPlace src/main.py \
--replace-fail "ui_basepath = '.'" "ui_basepath = '$out/share/rcu'"
substituteInPlace package_support/gnulinux/50-remarkable.rules \
--replace-fail 'GROUP="yourgroup"' 'GROUP="users"'
'';
nativeBuildInputs = [
copyDesktopItems
libsForQt5.wrapQtAppsHook
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
desktopToDarwinBundle
];
buildInputs = [
libsForQt5.qtbase
libsForQt5.qtwayland
];
propagatedBuildInputs = with python3Packages; [
certifi
packaging
paramiko
pdfminer-six
pikepdf
pillow
protobuf
pyside2
];
desktopItems = [
(makeDesktopItem {
name = "rcu";
desktopName = "reMarkable Connection Utility";
comment = "All-in-one offline/local management software for reMarkable e-paper tablets";
icon = "rcu";
exec = "rcu";
})
];
dontConfigure = true;
dontBuild = true;
# No tests
doCheck = false;
installPhase = ''
runHook preInstall
mkdir -p $out/{bin,share}
cp -r src $out/share/rcu
'' + lib.optionalString stdenv.hostPlatform.isLinux ''
install -Dm644 package_support/gnulinux/50-remarkable.rules $out/etc/udev/rules.d/50-remarkable.rules
'' + ''
# Keep source from being GC'd by linking into it
for icondir in $(find icons -type d -name '[0-9]*x[0-9]*'); do
iconsize=$(basename $icondir)
mkdir -p $out/share/icons/hicolor/$iconsize/apps
ln -s ${src}/icons/$iconsize/rcu-icon-$iconsize.png $out/share/icons/hicolor/$iconsize/apps/rcu.png
done
mkdir -p $out/share/icons/hicolor/scalable/apps
ln -s ${src}/icons/64x64/rcu-icon-64x64.svg $out/share/icons/hicolor/scalable/apps/rcu.svg
mkdir -p $out/share/doc/rcu
for docfile in {COPYING,manual.pdf}; do
ln -s ${src}/manual/$docfile $out/share/doc/rcu/$docfile
done
mkdir -p $out/share/licenses/rcu
ln -s ${src}/COPYING $out/share/licenses/rcu/COPYING
runHook postInstall
'';
# Manually creating wrapper, hook struggles with lack of shebang & symlink
dontWrapPythonPrograms = true;
preFixup = ''
makeWrapperArgs+=(
"''${qtWrapperArgs[@]}"
'' + lib.optionalString stdenv.hostPlatform.isLinux ''
--prefix PATH : ${lib.makeBinPath [ system-config-printer ]}
'' + ''
)
'';
postFixup = ''
makeWrapper ${lib.getExe python3Packages.python} $out/bin/rcu \
''${makeWrapperArgs[@]} \
--prefix PYTHONPATH : ${python3Packages.makePythonPath (propagatedBuildInputs ++ [(placeholder "out")])} \
--add-flags $out/share/rcu/main.py
'';
passthru = {
tests.version = testers.testVersion {
package = rcu;
version = let
versionSuffixPos = (lib.strings.stringLength rcu.version) - 1;
in
"d${lib.strings.substring 0 versionSuffixPos rcu.version}(${lib.strings.substring versionSuffixPos 1 rcu.version})";
};
};
meta = with lib; {
mainProgram = "rcu";
description = "All-in-one offline/local management software for reMarkable e-paper tablets";
homepage = "http://www.davisr.me/projects/rcu/";
license = licenses.agpl3Plus;
maintainers = with maintainers; [ OPNA2608 ];
};
}
|