1{
2 lib,
3 fetchCrate,
4 rustPlatform,
5 pkg-config,
6 installShellFiles,
7 openssl,
8 dbus,
9 sqlite,
10 stdenv,
11 testers,
12 leetcode-cli,
13}:
14
15rustPlatform.buildRustPackage rec {
16 pname = "leetcode-cli";
17 version = "0.4.6";
18
19 src = fetchCrate {
20 inherit pname version;
21 hash = "sha256-AYBBW9VtdvqqqiouhkS3diPcOdaQOs8Htkw9DTRX2t4=";
22 };
23
24 cargoHash = "sha256-o2RkhYsSQKwU+dsHQvlcxAVKUjOTqg424dqrM7JRoN8=";
25
26 nativeBuildInputs = [
27 pkg-config
28 installShellFiles
29 ];
30
31 buildInputs = [
32 openssl
33 dbus
34 sqlite
35 ];
36
37 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
38 installShellCompletion --cmd leetcode \
39 --bash <($out/bin/leetcode completions bash) \
40 --fish <($out/bin/leetcode completions fish) \
41 --zsh <($out/bin/leetcode completions zsh)
42 '';
43
44 passthru.tests = testers.testVersion {
45 package = leetcode-cli;
46 command = "leetcode -V";
47 version = "leetcode ${version}";
48 };
49
50 meta = with lib; {
51 description = "May the code be with you 👻";
52 longDescription = "Use leetcode.com in command line";
53 homepage = "https://github.com/clearloop/leetcode-cli";
54 license = licenses.mit;
55 maintainers = with maintainers; [ congee ];
56 mainProgram = "leetcode";
57 };
58}