1{ lib
2, fetchCrate
3, rustPlatform
4, pkg-config
5, installShellFiles
6, openssl
7, dbus
8, sqlite
9, stdenv
10, darwin
11, testers
12, leetcode-cli
13}:
14
15rustPlatform.buildRustPackage rec {
16 pname = "leetcode-cli";
17 version = "0.4.3";
18
19 src = fetchCrate {
20 inherit pname version;
21 hash = "sha256-y5zh93WPWSMDXqYangqrxav+sC0b0zpFIp6ZIew6KMo=";
22 };
23
24 cargoHash = "sha256-VktDiLsU+GOsa6ba9JJZGEPTavSKp+aSZm2dfhPEqMs=";
25
26 nativeBuildInputs = [
27 pkg-config
28 installShellFiles
29 ];
30
31 buildInputs = [
32 openssl
33 dbus
34 sqlite
35 ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];
36
37 postInstall = ''
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}