about summary refs log tree commit diff
path: root/pkgs/by-name/as/asfa/package.nix
blob: e9be2526dd7297c5259af8c2f6e047625bdcd17b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
  lib,
  rustPlatform,
  fetchFromGitHub,
  stdenv,
  darwin,
  help2man,
  openssl,
  pkg-config,
  installShellFiles,
}:
let
  version = "0.10.0-1";
  src = fetchFromGitHub {
    owner = "obreitwi";
    repo = "asfa";
    rev = "v${version}";
    hash = "sha256-ARdUlACxmbjmOTuNW2oiVUcfd5agR4rcp9aMQYUAYsw=";
  };
in
rustPlatform.buildRustPackage {
  pname = "asfa";
  inherit version src;

  cargoHash = "sha256-pzCTqVUo3LEpR3hmTPKDwvgtUJZ+tsArbi0HDlY2Cy8=";

  outputs = [
    "out"
    "man"
  ];

  buildInputs = [
    openssl
  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.SystemConfiguration ];

  nativeBuildInputs = [
    help2man
    installShellFiles
    pkg-config
  ];

  # checks disabled because tests need to be run against (docker-based) ephemeral ssh-server
  doCheck = false;

  postInstall = ''
    mkdir -p "man/man1"
    help2man -o "man/man1/asfa.1" "$out/bin/asfa"

    # Generate info about all subcommands except for 'help' (which leads to error)
    "$out/bin/asfa" --help | awk 'enabled && $1 != "help" { print $1 } /^SUBCOMMANDS:$/ { enabled=1 }' \
        | while read -r cmd; do
        help2man \
            "--version-string=${version}" \
            -o "man/man1/asfa-$cmd.1" \
            "$out/bin/asfa $cmd"
    done

    installManPage man/man1/*.1
  '';

  meta = {
    description = "Avoid sending file attachments by uploading them via SSH to a remote site and sharing a publicly-accessible URL with non-guessable (hash-based) prefix instead";
    homepage = "https://github.com/obreitwi/asfa";
    changelog = "https://github.com/obreitwi/asfa/blob/${src.rev}/CHANGELOG.md";
    license = with lib.licenses; [
      asl20
      mit
    ];
    maintainers = with lib.maintainers; [ obreitwi ];
    mainProgram = "asfa";
  };
}