From b4df919002467b242994f432d54078f45d94a2c8 Mon Sep 17 00:00:00 2001 From: Justinas Stankevicius Date: Thu, 8 Aug 2024 14:15:04 +0300 Subject: [PATCH] teleport_16: 16.0.4 -> 16.1.4 --- pkgs/servers/teleport/16/default.nix | 8 ++-- pkgs/servers/teleport/generic.nix | 63 ++++++++++++++++++---------- pkgs/servers/teleport/tsh_16.patch | 17 ++++++++ 3 files changed, 62 insertions(+), 26 deletions(-) create mode 100644 pkgs/servers/teleport/tsh_16.patch diff --git a/pkgs/servers/teleport/16/default.nix b/pkgs/servers/teleport/16/default.nix index eaf0ab11d992c..8aec5a6dfe032 100644 --- a/pkgs/servers/teleport/16/default.nix +++ b/pkgs/servers/teleport/16/default.nix @@ -1,9 +1,9 @@ { wasm-bindgen-cli, ... }@args: import ../generic.nix (args // { - version = "16.0.4"; - hash = "sha256-svDqcYm6PbmPyHhN00VKn/sGRkfb7ah2N7BtEVdZ9hg="; - vendorHash = "sha256-H4Rwel/UAvxY8/4CfSbneJYjt9HHgsuNbYXUM6MtqXM="; - yarnHash = "sha256-OHNnN66MevDiH4Zr6Uq3Om65XBzf4O3AIrPvhlvhkbE="; + version = "16.1.4"; + hash = "sha256-WgMQzS7nwIwPojcf9HTLajLd0WV+RYEbyp/aWr9XFWc="; + vendorHash = "sha256-8WN4hVueA2o2bHhhxLGPYxPX+1qky8QHGTRqhEGNh9s="; + pnpmHash = "sha256-phDrOSFQsgA+I4PDK9LJasUBXBO8EkVtQIMx9M4v8u0="; cargoLock = { lockFile = ./Cargo.lock; outputHashes = { diff --git a/pkgs/servers/teleport/generic.nix b/pkgs/servers/teleport/generic.nix index caf345d944b3d..87719f03eb728 100644 --- a/pkgs/servers/teleport/generic.nix +++ b/pkgs/servers/teleport/generic.nix @@ -12,6 +12,7 @@ , nodejs , openssl , pkg-config +, pnpm_9 , rustc , Security , stdenv @@ -30,8 +31,10 @@ , extPatches ? [] , cargoHash ? null , cargoLock ? null -, yarnHash +, yarnHash ? null +, pnpmHash ? null }: +assert yarnHash != null || pnpmHash != null; let # This repo has a private submodule "e" which fetchgit cannot handle without failing. src = fetchFromGitHub { @@ -40,6 +43,7 @@ let rev = "v${version}"; inherit hash; }; + pname = "teleport"; inherit version; rdpClient = rustPlatform.buildRustPackage rec { @@ -76,33 +80,45 @@ let 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 - ]; + pnpmDeps = if pnpmHash != null then pnpm_9.fetchDeps { + inherit src pname version; + hash = pnpmHash; + } else null; + + nativeBuildInputs = [ nodejs ] ++ lib.optional (lib.versionAtLeast version "15") [ + binaryen + cargo + nodejs + rustc + rustc.llvmPackages.lld + rustPlatform.cargoSetupHook + wasm-bindgen-cli + wasm-pack + ] ++ (if lib.versionAtLeast version "16" then [ pnpm_9.configHook ] else [ yarn fixup-yarn-lock ]); configurePhase = '' + runHook preConfigure + export HOME=$(mktemp -d) + + runHook postConfigure ''; buildPhase = '' - yarn config --offline set yarn-offline-mirror ${yarnOfflineCache} - fixup-yarn-lock yarn.lock + ${lib.optionalString (lib.versionOlder version "16") '' + yarn config --offline set yarn-offline-mirror ${yarnOfflineCache} + fixup-yarn-lock yarn.lock + + yarn install --offline \ + --frozen-lockfile \ + --ignore-engines --ignore-scripts + patchShebangs . + ''} - yarn install --offline \ - --frozen-lockfile \ - --ignore-engines --ignore-scripts - patchShebangs . + PATH=$PATH:$PWD/node_modules/.bin ${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 @@ -119,9 +135,7 @@ let }; in buildGoModule rec { - pname = "teleport"; - - inherit src version; + inherit pname src version; inherit vendorHash; proxyVendor = true; @@ -136,12 +150,17 @@ buildGoModule rec { patches = extPatches ++ [ ./0001-fix-add-nix-path-to-exec-env.patch ./rdpclient.patch - ./tsh.patch + (if lib.versionAtLeast version "16" then ./tsh_16.patch else ./tsh.patch) ]; # Reduce closure size for client machines outputs = [ "out" "client" ]; + prePatch = '' + # TODO: remove after https://github.com/NixOS/nixpkgs/pull/332852 merges + sed -i 's/go 1.22.6/go 1.22.5/' go.mod + ''; + preBuild = '' cp -r ${webassets} webassets '' + lib.optionalString withRdpClient '' diff --git a/pkgs/servers/teleport/tsh_16.patch b/pkgs/servers/teleport/tsh_16.patch new file mode 100644 index 0000000000000..f510b21d5dec0 --- /dev/null +++ b/pkgs/servers/teleport/tsh_16.patch @@ -0,0 +1,17 @@ +diff --git a/tool/tsh/common/tsh.go b/tool/tsh/common/tsh.go +index 5de21c69d0..3995c19e3c 100644 +--- a/tool/tsh/common/tsh.go ++++ b/tool/tsh/common/tsh.go +@@ -1084,10 +1084,11 @@ func Run(ctx context.Context, args []string, opts ...CliOption) error { + + var err error + +- cf.executablePath, err = os.Executable() ++ tempBinaryPath, err := os.Executable() + if err != nil { + return trace.Wrap(err) + } ++ cf.executablePath = filepath.Dir(tempBinaryPath) + "/tsh" + + // configs + setEnvFlags(&cf)