2021-12-24 04:21:11 +00:00
|
|
|
{ lib
|
2022-02-10 20:34:41 +00:00
|
|
|
, buildGoModule
|
2021-12-24 04:21:11 +00:00
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
2023-02-22 10:55:15 +00:00
|
|
|
, fetchYarnDeps
|
2021-12-24 04:21:11 +00:00
|
|
|
, makeWrapper
|
2022-05-18 14:49:53 +00:00
|
|
|
, CoreFoundation
|
2022-10-21 18:38:19 +00:00
|
|
|
, AppKit
|
2024-04-21 15:54:59 +00:00
|
|
|
, binaryen
|
|
|
|
, cargo
|
2022-10-06 18:32:54 +00:00
|
|
|
, libfido2
|
2023-02-22 10:55:15 +00:00
|
|
|
, nodejs
|
2022-05-18 14:49:53 +00:00
|
|
|
, openssl
|
|
|
|
, pkg-config
|
2024-04-21 15:54:59 +00:00
|
|
|
, rustc
|
2022-05-18 14:49:53 +00:00
|
|
|
, Security
|
2021-12-24 04:21:11 +00:00
|
|
|
, stdenv
|
|
|
|
, xdg-utils
|
2023-02-22 10:55:15 +00:00
|
|
|
, yarn
|
2024-04-21 15:54:59 +00:00
|
|
|
, wasm-bindgen-cli
|
|
|
|
, wasm-pack
|
|
|
|
, fixup-yarn-lock
|
2022-01-13 20:06:32 +00:00
|
|
|
, nixosTests
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
, withRdpClient ? true
|
2023-03-04 12:14:45 +00:00
|
|
|
|
|
|
|
, version
|
|
|
|
, hash
|
|
|
|
, vendorHash
|
2023-10-09 19:29:22 +00:00
|
|
|
, extPatches ? null
|
2023-04-12 12:48:02 +00:00
|
|
|
, cargoHash ? null
|
|
|
|
, cargoLock ? null
|
2023-03-04 12:14:45 +00:00
|
|
|
, yarnHash
|
2021-12-24 04:21:11 +00:00
|
|
|
}:
|
|
|
|
let
|
2020-04-24 23:36:52 +00:00
|
|
|
# This repo has a private submodule "e" which fetchgit cannot handle without failing.
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "gravitational";
|
|
|
|
repo = "teleport";
|
|
|
|
rev = "v${version}";
|
2023-03-04 12:14:45 +00:00
|
|
|
inherit hash;
|
2022-05-18 14:49:53 +00:00
|
|
|
};
|
2023-03-04 12:14:45 +00:00
|
|
|
inherit version;
|
2022-05-18 14:49:53 +00:00
|
|
|
|
|
|
|
rdpClient = rustPlatform.buildRustPackage rec {
|
2022-10-06 18:32:54 +00:00
|
|
|
pname = "teleport-rdpclient";
|
2023-04-12 12:48:02 +00:00
|
|
|
inherit cargoHash cargoLock;
|
2022-05-18 14:49:53 +00:00
|
|
|
inherit version src;
|
|
|
|
|
|
|
|
buildAndTestSubdir = "lib/srv/desktop/rdp/rdpclient";
|
|
|
|
|
|
|
|
buildInputs = [ openssl ]
|
|
|
|
++ lib.optionals stdenv.isDarwin [ CoreFoundation Security ];
|
|
|
|
nativeBuildInputs = [ pkg-config ];
|
|
|
|
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/161570 ,
|
|
|
|
# buildRustPackage sets strictDeps = true;
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = buildInputs;
|
2022-05-18 14:49:53 +00:00
|
|
|
|
|
|
|
OPENSSL_NO_VENDOR = "1";
|
|
|
|
|
|
|
|
postInstall = ''
|
2022-10-06 18:32:54 +00:00
|
|
|
mkdir -p $out/include
|
|
|
|
cp ${buildAndTestSubdir}/librdprs.h $out/include/
|
2021-12-24 04:21:11 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-02-22 10:55:15 +00:00
|
|
|
yarnOfflineCache = fetchYarnDeps {
|
|
|
|
yarnLock = "${src}/yarn.lock";
|
2023-03-04 12:14:45 +00:00
|
|
|
hash = yarnHash;
|
2023-02-22 10:55:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
webassets = stdenv.mkDerivation {
|
|
|
|
pname = "teleport-webassets";
|
|
|
|
inherit src version;
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
cargoDeps = rustPlatform.importCargoLock cargoLock;
|
|
|
|
|
|
|
|
nativeBuildInputs = [ nodejs yarn fixup-yarn-lock ] ++
|
|
|
|
lib.optional (lib.versionAtLeast version "15") [
|
|
|
|
binaryen
|
|
|
|
cargo
|
|
|
|
rustc
|
|
|
|
rustc.llvmPackages.lld
|
|
|
|
rustPlatform.cargoSetupHook
|
|
|
|
wasm-bindgen-cli
|
|
|
|
wasm-pack
|
|
|
|
];
|
|
|
|
|
2023-02-22 10:55:15 +00:00
|
|
|
configurePhase = ''
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
yarn config --offline set yarn-offline-mirror ${yarnOfflineCache}
|
2024-01-02 11:29:13 +00:00
|
|
|
fixup-yarn-lock yarn.lock
|
2023-02-22 10:55:15 +00:00
|
|
|
|
|
|
|
yarn install --offline \
|
|
|
|
--frozen-lockfile \
|
|
|
|
--ignore-engines --ignore-scripts
|
|
|
|
patchShebangs .
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
${if lib.versionAtLeast version "15"
|
|
|
|
then ''
|
|
|
|
PATH=$PATH:$PWD/node_modules/.bin
|
|
|
|
pushd web/packages/teleport
|
|
|
|
# https://github.com/gravitational/teleport/blob/6b91fe5bbb9e87db4c63d19f94ed4f7d0f9eba43/web/packages/teleport/README.md?plain=1#L18-L20
|
|
|
|
RUST_MIN_STACK=16777216 wasm-pack build ./src/ironrdp --target web --mode no-install
|
|
|
|
vite build
|
|
|
|
popd
|
|
|
|
''
|
|
|
|
else "yarn build-ui-oss"}
|
2023-02-22 10:55:15 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp -R webassets/. $out
|
|
|
|
'';
|
2021-12-24 04:21:11 +00:00
|
|
|
};
|
|
|
|
in
|
2022-02-10 20:34:41 +00:00
|
|
|
buildGoModule rec {
|
2021-12-24 04:21:11 +00:00
|
|
|
pname = "teleport";
|
|
|
|
|
|
|
|
inherit src version;
|
2023-03-04 12:14:45 +00:00
|
|
|
inherit vendorHash;
|
2023-02-22 10:55:15 +00:00
|
|
|
proxyVendor = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
subPackages = [ "tool/tbot" "tool/tctl" "tool/teleport" "tool/tsh" ];
|
2022-10-06 18:32:54 +00:00
|
|
|
tags = [ "libfido2" "webassets_embed" ]
|
|
|
|
++ lib.optional withRdpClient "desktop_access_rdp";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-10-06 18:32:54 +00:00
|
|
|
buildInputs = [ openssl libfido2 ]
|
2022-10-21 18:38:19 +00:00
|
|
|
++ lib.optionals (stdenv.isDarwin && withRdpClient) [ CoreFoundation Security AppKit ];
|
2022-10-06 18:32:54 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper pkg-config ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
patches = extPatches ++ [
|
2022-03-30 09:31:56 +00:00
|
|
|
./0001-fix-add-nix-path-to-exec-env.patch
|
2022-05-18 14:49:53 +00:00
|
|
|
./rdpclient.patch
|
2021-08-05 21:33:18 +00:00
|
|
|
];
|
2021-05-04 21:07:42 +00:00
|
|
|
|
2021-08-11 14:56:57 +00:00
|
|
|
# Reduce closure size for client machines
|
|
|
|
outputs = [ "out" "client" ];
|
|
|
|
|
2022-10-06 18:32:54 +00:00
|
|
|
preBuild = ''
|
2023-02-22 10:55:15 +00:00
|
|
|
cp -r ${webassets} webassets
|
2022-10-06 18:32:54 +00:00
|
|
|
'' + lib.optionalString withRdpClient ''
|
|
|
|
ln -s ${rdpClient}/lib/* lib/
|
|
|
|
ln -s ${rdpClient}/include/* lib/srv/desktop/rdp/rdpclient/
|
|
|
|
'';
|
2021-12-24 04:21:11 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
# Multiple tests fail in the build sandbox
|
|
|
|
# due to trying to spawn nixbld's shell (/noshell), etc.
|
|
|
|
doCheck = false;
|
2021-04-26 19:14:03 +00:00
|
|
|
|
2021-02-24 18:30:23 +00:00
|
|
|
postInstall = ''
|
2022-10-06 18:32:54 +00:00
|
|
|
mkdir -p $client/bin
|
|
|
|
mv {$out,$client}/bin/tsh
|
2022-08-21 13:32:41 +00:00
|
|
|
# make xdg-open overrideable at runtime
|
|
|
|
wrapProgram $client/bin/tsh --suffix PATH : ${lib.makeBinPath [ xdg-utils ]}
|
2022-10-06 18:32:54 +00:00
|
|
|
ln -s {$client,$out}/bin/tsh
|
2021-02-24 18:30:23 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
doInstallCheck = true;
|
|
|
|
|
|
|
|
installCheckPhase = ''
|
|
|
|
$out/bin/tsh version | grep ${version} > /dev/null
|
2021-02-24 18:30:23 +00:00
|
|
|
$client/bin/tsh version | grep ${version} > /dev/null
|
2022-05-18 14:49:53 +00:00
|
|
|
$out/bin/tbot version | grep ${version} > /dev/null
|
2021-02-05 17:12:51 +00:00
|
|
|
$out/bin/tctl version | grep ${version} > /dev/null
|
|
|
|
$out/bin/teleport version | grep ${version} > /dev/null
|
|
|
|
'';
|
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
passthru.tests = nixosTests.teleport;
|
|
|
|
|
2021-02-24 18:30:23 +00:00
|
|
|
meta = with lib; {
|
2021-12-24 04:21:11 +00:00
|
|
|
description = "Certificate authority and access plane for SSH, Kubernetes, web applications, and databases";
|
2021-04-26 19:14:03 +00:00
|
|
|
homepage = "https://goteleport.com/";
|
2024-04-21 15:54:59 +00:00
|
|
|
license = if lib.versionAtLeast version "15" then licenses.agpl3Plus else licenses.asl20;
|
2023-10-09 19:29:22 +00:00
|
|
|
maintainers = with maintainers; [ arianvp justinas sigma tomberek freezeboy techknowlogick ];
|
2021-02-24 18:30:23 +00:00
|
|
|
platforms = platforms.unix;
|
2023-07-15 17:15:38 +00:00
|
|
|
# go-libfido2 is broken on platforms with less than 64-bit because it defines an array
|
|
|
|
# which occupies more than 31 bits of address space.
|
2024-06-20 14:57:18 +00:00
|
|
|
broken = stdenv.hostPlatform.parsed.cpu.bits < 64 ||
|
|
|
|
# See comment about wasm32-unknown-unknown in rustc.nix.
|
|
|
|
# version 15 is the first that starts to use wasm
|
|
|
|
(lib.versionAtLeast version "15") && (
|
|
|
|
lib.any (a: lib.hasAttr a stdenv.hostPlatform.gcc) [ "cpu" "float-abi" "fpu" ] ||
|
|
|
|
!stdenv.hostPlatform.gcc.thumb or true
|
|
|
|
);
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|