about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/teleport/default.nix
blob: d898cc9bcca794d3d9123d4f412f5ca9d3407d3c (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
# This file was generated by https://github.com/kamilchm/go2nix v2.0-dev
{ lib, buildGoModule, zip, fetchFromGitHub, makeWrapper, xdg-utils }:
let
  webassets = fetchFromGitHub {
    owner = "gravitational";
    repo = "webassets";
    rev = "8a30ee4e3570c7db0566028b6b562167aa40f646";
    sha256 = "sha256-noMVcB1cjiMcRke6/qJIzDaEh4uPIewsedLQRdPbzIQ=";
  };
in

buildGoModule rec {
  pname = "teleport";
  version = "6.2.5";

  # This repo has a private submodule "e" which fetchgit cannot handle without failing.
  src = fetchFromGitHub {
    owner = "gravitational";
    repo = "teleport";
    rev = "v${version}";
    sha256 = "sha256-OBo1TWN7KxI7DAUcRLwXXQjErhhgpLBrJBR55ewKiYw=";
  };

  vendorSha256 = null;

  subPackages = [ "tool/tctl" "tool/teleport" "tool/tsh" ];

  nativeBuildInputs = [ zip makeWrapper ];

  # https://github.com/NixOS/nixpkgs/issues/120738
  patches = [ ./tsh.patch ];

  postBuild = ''
    pushd .
    mkdir -p build
    echo "making webassets"
    cp -r ${webassets}/* webassets/
    make build/webassets.zip
    cat build/webassets.zip >> $NIX_BUILD_TOP/go/bin/teleport
    rm -fr build/webassets.zip
    cd $NIX_BUILD_TOP/go/bin
    zip -q -A teleport
    popd
  '';

  # Do not strip the embedded web assets
  dontStrip = true;

  # Reduce closure size for client machines
  outputs = [ "out" "client" ];

  buildTargets = [ "full" ];

  preCheck = ''
    export HOME=$(mktemp -d)
  '';

  postInstall = ''
    install -Dm755 -t $client/bin $out/bin/tsh
    wrapProgram $client/bin/tsh --prefix PATH : ${lib.makeBinPath [ xdg-utils ]}
    wrapProgram $out/bin/tsh --prefix PATH : ${lib.makeBinPath [ xdg-utils ]}
  '';

  doInstallCheck = true;

  installCheckPhase = ''
    $out/bin/tsh version | grep ${version} > /dev/null
    $client/bin/tsh version | grep ${version} > /dev/null
    $out/bin/tctl version | grep ${version} > /dev/null
    $out/bin/teleport version | grep ${version} > /dev/null
  '';

  meta = with lib; {
    description = "A SSH CA management suite";
    homepage = "https://goteleport.com/";
    license = licenses.asl20;
    maintainers = with maintainers; [ sigma tomberek freezeboy ];
    platforms = platforms.unix;
  };
}