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