{ lib, stdenv, fetchFromGitHub, nix, rustPlatform, installShellFiles, }: let version = "0.4.52"; in rustPlatform.buildRustPackage rec { inherit version; pname = "mdbook"; src = fetchFromGitHub { owner = "rust-lang"; repo = "mdBook"; tag = "v${version}"; hash = "sha256-a3GSMz1+8Ve5cp4x1NjBlsCU/wMC4Jl3/H9qx7+1XlI="; }; cargoHash = "sha256-wvTixSVHXglJM+nBMulZNZKF8pZfNd2G8Z+1PlAWmpk="; nativeBuildInputs = [ installShellFiles ]; postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' installShellCompletion --cmd mdbook \ --bash <($out/bin/mdbook completions bash) \ --fish <($out/bin/mdbook completions fish) \ --zsh <($out/bin/mdbook completions zsh ) ''; passthru = { tests = { inherit nix; }; }; meta = { description = "Create books from MarkDown"; mainProgram = "mdbook"; homepage = "https://github.com/rust-lang/mdBook"; changelog = "https://github.com/rust-lang/mdBook/blob/v${version}/CHANGELOG.md"; license = [ lib.licenses.mpl20 ]; maintainers = with lib.maintainers; [ havvy Frostman matthiasbeyer ]; }; }