nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 rustPlatform,
4 fetchFromGitHub,
5 installShellFiles,
6 stdenv,
7 unixtools,
8}:
9
10rustPlatform.buildRustPackage (finalAttrs: {
11 pname = "halp";
12 version = "0.2.0";
13
14 src = fetchFromGitHub {
15 owner = "orhun";
16 repo = "halp";
17 tag = "v${finalAttrs.version}";
18 hash = "sha256-tJ95rvYjqQn0ZTlEdqfs/LbyfBP7PqnevxX8b1VfokA=";
19 };
20
21 cargoHash = "sha256-sJdZjTzfawwBK8KxQP7zvn+kByCMSxrrQjY1t9RWmhU=";
22
23 patches = [
24 # patch tests to point to the correct target directory
25 ./fix-target-dir.patch
26 ];
27
28 nativeBuildInputs = [ installShellFiles ];
29
30 nativeCheckInputs = [ unixtools.script ];
31
32 # tests are failing on darwin
33 doCheck = !stdenv.hostPlatform.isDarwin;
34
35 checkFlags = [
36 # requires internet access
37 "--skip=helper::docs::cheat::tests::test_fetch_cheat_sheet"
38 "--skip=helper::docs::cheat_sh::tests::test_fetch_cheat_sheet"
39 "--skip=helper::docs::cheatsheets::tests::test_fetch_cheatsheets"
40 "--skip=helper::docs::eg::tests::test_eg_page_fetch"
41 ];
42
43 postPatch = ''
44 substituteInPlace src/helper/args/mod.rs \
45 --subst-var-by releaseDir target/${stdenv.hostPlatform.rust.rustcTargetSpec}/$cargoCheckType
46 '';
47
48 preCheck = ''
49 export NO_COLOR=1
50 export OUT_DIR=target
51 '';
52
53 postInstall = ''
54 mkdir -p man completions
55
56 OUT_DIR=man $out/bin/halp-mangen
57 OUT_DIR=completions $out/bin/halp-completions
58
59 installManPage man/halp.1
60 installShellCompletion \
61 completions/halp.{bash,fish} \
62 --zsh completions/_halp
63
64 rm $out/bin/halp-{completions,mangen,test}
65 '';
66
67 meta = {
68 description = "CLI tool to get help with CLI tools";
69 homepage = "https://github.com/orhun/halp";
70 changelog = "https://github.com/orhun/halp/blob/v${finalAttrs.version}/CHANGELOG.md";
71 license = with lib.licenses; [
72 asl20
73 mit
74 ];
75 maintainers = [ ];
76 mainProgram = "halp";
77 };
78})