1{ lib
2, fetchFromSourcehut
3, rustPlatform
4, installShellFiles
5, scdoc
6, makeWrapper
7
8# Script dependencies.
9, fzf
10, wl-clipboard
11, xclip
12}:
13
14rustPlatform.buildRustPackage rec {
15 pname = "license-cli";
16 version = "3.1.0";
17
18 src = fetchFromSourcehut {
19 owner = "~zethra";
20 repo = "license";
21 rev = version;
22 hash = "sha256-OGS26mE5rjxlZOaBWhYc7C8aM3Lq2xX0f31LgckjJF8=";
23 };
24
25 cargoHash = "sha256-Zj9t/e6QhiOxU8mlVRBKEbviSTKXM4WQ3lqtoCcMbMI=";
26
27 nativeBuildInputs = [ installShellFiles makeWrapper ];
28
29 preInstall = ''
30 ${scdoc}/bin/scdoc < doc/license.scd > license.1
31 '';
32
33 postInstall = ''
34 installShellCompletion completions/license.{bash,fish}
35 installShellCompletion --zsh completions/_license
36 installManPage ./license.1
37
38 install -Dm0755 ./scripts/set-license -t $out/bin
39 wrapProgram $out/bin/set-license \
40 --prefix PATH : "$out/bin" \
41 --prefix PATH : ${lib.makeBinPath [ fzf ]}
42
43 install -Dm0755 ./scripts/copy-header -t $out/bin
44 wrapProgram $out/bin/copy-header \
45 --prefix PATH : "$out/bin" \
46 --prefix PATH : ${lib.makeBinPath [ wl-clipboard xclip ]}
47 '';
48
49 meta = with lib; {
50 homepage = "https://git.sr.ht/~zethra/license";
51 description = "Command-line tool to easily add license to your project";
52 license = licenses.mpl20;
53 mainProgram = "license";
54 maintainers = with maintainers; [ foo-dogsquared ];
55 };
56}