From 673c8d72ca29bc6a3d69008e4ca76947f4b5827a Mon Sep 17 00:00:00 2001 From: Ilan Joselevich Date: Sun, 3 Dec 2023 16:38:47 +0200 Subject: [PATCH 1/2] sshx: split components, unstable-2023-11-04 -> unstable-2023-11-23 --- pkgs/by-name/ss/sshx/package.nix | 53 -------------------------------- pkgs/tools/misc/sshx/default.nix | 52 +++++++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 +++ 3 files changed, 56 insertions(+), 53 deletions(-) delete mode 100644 pkgs/by-name/ss/sshx/package.nix create mode 100644 pkgs/tools/misc/sshx/default.nix diff --git a/pkgs/by-name/ss/sshx/package.nix b/pkgs/by-name/ss/sshx/package.nix deleted file mode 100644 index ff3de6705453..000000000000 --- a/pkgs/by-name/ss/sshx/package.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ lib -, rustPlatform -, fetchFromGitHub -, pkg-config -, protobuf -, zstd -, stdenv -, darwin -}: - -rustPlatform.buildRustPackage rec { - pname = "sshx"; - version = "unstable-2023-11-04"; - - src = fetchFromGitHub { - owner = "ekzhang"; - repo = "sshx"; - rev = "91c82d46cde4d1ffa0ae34e2a9a49911e2e53baa"; - hash = "sha256-X9c7ZKIpWI5EsbkgB8FJWlwQQXHAcPjLKp2Bvo0fo/w="; - }; - - cargoHash = "sha256-mOK5gpPuUKzN5xnJs5nFyslxr9IIHtiCylMP53ObDqg="; - - nativeBuildInputs = [ - pkg-config - protobuf - ]; - - buildInputs = [ - zstd - ] ++ lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.Security - ]; - - env = { - ZSTD_SYS_USE_PKG_CONFIG = true; - }; - - outputs = [ "out" "server" ]; - - postInstall = '' - moveToOutput 'bin/sshx' "$out" - moveToOutput 'bin/sshx-server' "$server" - ''; - - meta = with lib; { - description = "Fast, collaborative live terminal sharing over the web"; - homepage = "https://github.com/ekzhang/sshx"; - license = licenses.mit; - maintainers = with maintainers; [ pinpox ]; - mainProgram = "sshx"; - }; -} diff --git a/pkgs/tools/misc/sshx/default.nix b/pkgs/tools/misc/sshx/default.nix new file mode 100644 index 000000000000..d9d37e50c472 --- /dev/null +++ b/pkgs/tools/misc/sshx/default.nix @@ -0,0 +1,52 @@ +{ lib +, callPackage +, rustPlatform +, fetchFromGitHub +, protobuf +, darwin +, stdenv +}: +let + version = "unstable-2023-11-23"; + + src = fetchFromGitHub { + owner = "ekzhang"; + repo = "sshx"; + rev = "2677f7e1fa3b369132cc7f27f6028a04b92ba5cf"; + hash = "sha256-9fo8hNUzJr4gse0J2tw7j+alqE82+y8McADzTkxryWk="; + }; + + mkSshxPackage = { pname, cargoHash, ... }@args: + rustPlatform.buildRustPackage (rec { + inherit + pname + version + src + cargoHash; + + nativeBuildInputs = [ protobuf ]; + buildInputs = lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security; + + cargoBuildFlags = [ "--package" pname ]; + cargoTestFlags = cargoBuildFlags; + + meta = { + description = "Fast, collaborative live terminal sharing over the web"; + homepage = "https://github.com/ekzhang/sshx"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ pinpox kranzes ]; + mainProgram = pname; + }; + } // args); +in +{ + sshx = mkSshxPackage { + pname = "sshx"; + cargoHash = "sha256-dA5Aen/qANW8si75pj/RsBknvOo3KDyU5UISAmmcfRE="; + }; + + sshx-server = mkSshxPackage { + pname = "sshx-server"; + cargoHash = "sha256-1GRWCMXsOzqvORgtwfuywV4wLyX3r4nURhM3Dl5V9Ss="; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b55bb7b37463..8603a0bd865d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13506,6 +13506,10 @@ with pkgs; sshuttle = callPackage ../tools/security/sshuttle { }; + inherit (callPackages ../tools/misc/sshx { }) + sshx + sshx-server; + ssldump = callPackage ../tools/networking/ssldump { }; sslsplit = callPackage ../tools/networking/sslsplit { }; From 54557f8bfa59351354524053d4787ce2ee5c4f90 Mon Sep 17 00:00:00 2001 From: Ilan Joselevich Date: Mon, 4 Dec 2023 04:49:00 +0200 Subject: [PATCH 2/2] sshx-server: add web ui --- pkgs/tools/misc/sshx/default.nix | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/misc/sshx/default.nix b/pkgs/tools/misc/sshx/default.nix index d9d37e50c472..9ae65dcaee1c 100644 --- a/pkgs/tools/misc/sshx/default.nix +++ b/pkgs/tools/misc/sshx/default.nix @@ -5,6 +5,7 @@ , protobuf , darwin , stdenv +, buildNpmPackage }: let version = "unstable-2023-11-23"; @@ -45,8 +46,34 @@ in cargoHash = "sha256-dA5Aen/qANW8si75pj/RsBknvOo3KDyU5UISAmmcfRE="; }; - sshx-server = mkSshxPackage { + sshx-server = mkSshxPackage rec { pname = "sshx-server"; cargoHash = "sha256-1GRWCMXsOzqvORgtwfuywV4wLyX3r4nURhM3Dl5V9Ss="; + + postPatch = '' + substituteInPlace crates/sshx-server/src/web.rs \ + --replace 'ServeDir::new("build")' 'ServeDir::new("${passthru.web.outPath}")' \ + --replace 'ServeFile::new("build/spa.html")' 'ServeFile::new("${passthru.web.outPath}/spa.html")' + ''; + + passthru.web = buildNpmPackage { + pname = "sshx-web"; + + inherit + version + src; + + postPatch = '' + substituteInPlace vite.config.ts \ + --replace 'execSync("git rev-parse --short HEAD").toString().trim()' '"${src.rev}"' + ''; + + npmDepsHash = "sha256-bKePCxo6+n0EG+4tbbMimPedJ0Hu1O8yZsgspmhobOs="; + + installPhase = '' + mkdir -p "$out" + cp -r build/* "$out" + ''; + }; }; }