1{ lib
2, rustPlatform
3, fetchFromGitHub
4, installShellFiles
5, pkg-config
6, oniguruma
7, stdenv
8, darwin
9}:
10
11rustPlatform.buildRustPackage rec {
12 pname = "termbook-cli";
13 version = "1.4.6";
14
15 src = fetchFromGitHub {
16 owner = "Byron";
17 repo = "termbook";
18 rev = "v${version}";
19 sha256 = "Bo3DI0cMXIfP7ZVr8MAW/Tmv+4mEJBIQyLvRfVBDG8c=";
20 };
21
22 cargoLock = {
23 lockFile = ./Cargo.lock;
24 };
25
26 nativeBuildInputs = [
27 installShellFiles
28 pkg-config
29 ];
30
31 buildInputs = [
32 oniguruma
33 ] ++ lib.optionals stdenv.isDarwin [
34 darwin.apple_sdk.frameworks.Security
35 ];
36
37 env = {
38 RUSTONIG_SYSTEM_LIBONIG = true;
39 };
40
41 # update dependencies to fix build failure caused by unaligned packed structs
42 postPatch = ''
43 ln -sf ${./Cargo.lock} Cargo.lock
44 '';
45
46 postInstall = ''
47 installShellCompletion --cmd termbook \
48 --bash <($out/bin/termbook completions bash) \
49 --fish <($out/bin/termbook completions fish) \
50 --zsh <($out/bin/termbook completions zsh)
51 '';
52
53 meta = with lib; {
54 description = "A runner for `mdbooks` to keep your documentation tested";
55 homepage = "https://github.com/Byron/termbook/";
56 changelog = "https://github.com/Byron/termbook/blob/${src.rev}/CHANGELOG.md";
57 license = licenses.asl20;
58 maintainers = with maintainers; [ phaer ];
59 };
60}