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
|
{ lib
, stdenv
, stdenvNoCC
, rustPlatform
, fetchFromGitHub
, wrapGAppsHook
, cargo
, rustc
, cargo-tauri
, pkg-config
, nodePackages
, esbuild
, buildGoModule
, jq
, moreutils
, libayatana-appindicator
, gtk3
, webkitgtk
, libsoup
, openssl
, xdotool
, cacert
}:
stdenv.mkDerivation rec {
pname = "pot";
version = "2.7.9";
src = fetchFromGitHub {
owner = "pot-app";
repo = "pot-desktop";
rev = version;
hash = "sha256-Y2gFLvRNBjOGxdpIeoY1CXEip0Ht73aymWIP5wuc9kU=";
};
sourceRoot = "${src.name}/src-tauri";
postPatch = ''
substituteInPlace $cargoDepsCopy/libappindicator-sys-*/src/lib.rs \
--replace "libayatana-appindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1"
'';
pnpm-deps = stdenvNoCC.mkDerivation {
pname = "${pname}-pnpm-deps";
inherit src version;
nativeBuildInputs = [
jq
moreutils
nodePackages.pnpm
cacert
];
installPhase = ''
export HOME=$(mktemp -d)
pnpm config set store-dir $out
# use --ignore-script and --no-optional to avoid downloading binaries
# use --frozen-lockfile to avoid checking git deps
pnpm install --frozen-lockfile --no-optional --ignore-script
# Remove timestamp and sort the json files
rm -rf $out/v3/tmp
for f in $(find $out -name "*.json"); do
sed -i -E -e 's/"checkedAt":[0-9]+,//g' $f
jq --sort-keys . $f | sponge $f
done
'';
dontFixup = true;
outputHashMode = "recursive";
outputHash = "sha256-LuY5vh642DgSa91eUcA/AT+ovDcP9tZFE2dKyicCOeQ=";
};
cargoDeps = rustPlatform.importCargoLock {
lockFile = ./Cargo.lock;
outputHashes = {
# All other crates in the same workspace reuse this hash.
"tauri-plugin-autostart-0.0.0" = "sha256-/uxaSBp+N1VjjSiwf6NwNnSH02Vk6gQZ/CzO+AyEI7o=";
};
};
nativeBuildInputs = [
rustPlatform.cargoSetupHook
cargo
rustc
cargo-tauri
wrapGAppsHook
nodePackages.pnpm
pkg-config
];
buildInputs = [
gtk3
libsoup
libayatana-appindicator
openssl
webkitgtk
xdotool
];
ESBUILD_BINARY_PATH = "${lib.getExe (esbuild.override {
buildGoModule = args: buildGoModule (args // rec {
version = "0.18.20";
src = fetchFromGitHub {
owner = "evanw";
repo = "esbuild";
rev = "v${version}";
hash = "sha256-mED3h+mY+4H465m02ewFK/BgA1i/PQ+ksUNxBlgpUoI=";
};
vendorHash = "sha256-+BfxCyg0KkDQpHt/wycy/8CTG6YBA/VJvJFhhzUnSiQ=";
});
})}";
preBuild = ''
export HOME=$(mktemp -d)
pnpm config set store-dir ${pnpm-deps}
chmod +w ..
pnpm install --offline --frozen-lockfile --no-optional --ignore-script
chmod -R +w ../node_modules
pnpm rebuild
# Use cargo-tauri from nixpkgs instead of pnpm tauri from npm
cargo tauri build -b deb
'';
preInstall = ''
mv target/release/bundle/deb/*/data/usr/ $out
'';
meta = with lib; {
description = "A cross-platform translation software";
mainProgram = "pot";
homepage = "https://pot.pylogmon.com";
platforms = platforms.linux;
license = licenses.gpl3Only;
maintainers = with maintainers; [ linsui ];
};
}
|