about summary refs log tree commit diff
path: root/pkgs/by-name/ss/ssh-openpgp-auth/generic.nix
blob: 4cfe2b6ec7c4e3c1b9309f35359465368bb5dce2 (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
73
74
75
76
77
78
79
80
81
# This file is based upon upstream's package.nix shared among both
# "ssh-openpgp-auth" and "sshd-openpgpg-auth"
{ lib
, rustPlatform
, fetchFromGitea
, pkg-config
, just
, rust-script
, installShellFiles
, nettle
, openssl
, sqlite
, stdenv
, darwin
, openssh
# Arguments not supplied by callPackage
, pname , version , srcHash , cargoHash, metaDescription
}:

rustPlatform.buildRustPackage {
  inherit pname version;

  src = fetchFromGitea {
    domain = "codeberg.org";
    owner = "wiktor";
    repo = "ssh-openpgp-auth";
    # See also: https://codeberg.org/wiktor/ssh-openpgp-auth/pulls/92#issuecomment-1635274
    rev = "${pname}/${version}";
    hash = srcHash;
  };
  buildAndTestSubdir = pname;
  inherit cargoHash;

  nativeBuildInputs = [
    pkg-config
    rustPlatform.bindgenHook
    just
    rust-script
    installShellFiles
  ];
  # Otherwise just's build, check and install phases take precedence over
  # buildRustPackage's phases.
  dontUseJustBuild = true;
  dontUseJustCheck = true;
  dontUseJustInstall = true;

  postInstall = ''
    export HOME=$(mktemp -d)
    just generate manpages ${pname} $out/share/man/man1
    just generate shell_completions ${pname} shell_completions
    installShellCompletion --cmd ${pname} \
      --bash shell_completions/${pname}.bash \
      --fish shell_completions/${pname}.fish \
      --zsh  shell_completions/_${pname}
  '';


  buildInputs = [
    nettle
    openssl
    sqlite
  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
    darwin.apple_sdk_11_0.frameworks.CoreFoundation
    darwin.apple_sdk_11_0.frameworks.IOKit
    darwin.apple_sdk_11_0.frameworks.Security
    darwin.apple_sdk_11_0.frameworks.SystemConfiguration
  ];

  doCheck = true;
  nativeCheckInputs = [
    openssh
  ];

  meta = with lib; {
    description = metaDescription;
    homepage = "https://codeberg.org/wiktor/ssh-openpgp-auth";
    license = with licenses; [ mit /* or */ asl20 ];
    maintainers = with maintainers; [ doronbehar ];
    mainProgram = pname;
  };
}