nixpkgs/pkgs/servers/teleport/default.nix
2021-05-03 13:37:48 +02:00

80 lines
2.1 KiB
Nix

# 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 = "cf396f868aebb8ba654ea2398c25f033181e7114";
sha256 = "sha256-12jkpWl/kL0ttRHtxyDnKjYAZNrheEGQF8HEGSXvvAk=";
};
in
buildGoModule rec {
pname = "teleport";
version = "6.1.3";
# This repo has a private submodule "e" which fetchgit cannot handle without failing.
src = fetchFromGitHub {
owner = "gravitational";
repo = "teleport";
rev = "v${version}";
sha256 = "sha256-kb7qRPZKXDY0Qy3/72epAGaN2FCOO/XAN8lOoUYkoM0=";
};
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;
};
}