2022-02-10 20:34:41 +00:00
|
|
|
{ lib
|
|
|
|
, fetchCrate
|
|
|
|
, rustPlatform
|
|
|
|
, pkg-config
|
2023-11-16 04:20:00 +00:00
|
|
|
, installShellFiles
|
2022-02-10 20:34:41 +00:00
|
|
|
, openssl
|
|
|
|
, dbus
|
|
|
|
, sqlite
|
|
|
|
, stdenv
|
|
|
|
, darwin
|
2023-08-22 20:05:09 +00:00
|
|
|
, testers
|
|
|
|
, leetcode-cli
|
2022-02-10 20:34:41 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "leetcode-cli";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "0.4.5";
|
2022-02-10 20:34:41 +00:00
|
|
|
|
|
|
|
src = fetchCrate {
|
|
|
|
inherit pname version;
|
2024-09-19 14:19:46 +00:00
|
|
|
hash = "sha256-Jc0akHj2DHbkF7sjslOwdeI1piW2gnhoalBz18lpQdQ=";
|
2022-02-10 20:34:41 +00:00
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
cargoHash = "sha256-t3u82bjO1Qv32TwpZNCaaEqOVajXIgM7VBNQ4UjMcl8=";
|
2022-02-10 20:34:41 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pkg-config
|
2023-11-16 04:20:00 +00:00
|
|
|
installShellFiles
|
2022-02-10 20:34:41 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
openssl
|
|
|
|
dbus
|
|
|
|
sqlite
|
2024-10-29 11:11:06 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
|
|
|
darwin.apple_sdk.frameworks.Security
|
|
|
|
darwin.apple_sdk.frameworks.SystemConfiguration
|
|
|
|
];
|
2022-02-10 20:34:41 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
2023-11-16 04:20:00 +00:00
|
|
|
installShellCompletion --cmd leetcode \
|
|
|
|
--bash <($out/bin/leetcode completions bash) \
|
|
|
|
--fish <($out/bin/leetcode completions fish) \
|
|
|
|
--zsh <($out/bin/leetcode completions zsh)
|
|
|
|
'';
|
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
passthru.tests = testers.testVersion {
|
|
|
|
package = leetcode-cli;
|
|
|
|
command = "leetcode -V";
|
|
|
|
version = "leetcode ${version}";
|
|
|
|
};
|
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "May the code be with you 👻";
|
|
|
|
longDescription = "Use leetcode.com in command line";
|
|
|
|
homepage = "https://github.com/clearloop/leetcode-cli";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ congee ];
|
|
|
|
mainProgram = "leetcode";
|
|
|
|
};
|
|
|
|
}
|