e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
83 lines
2.0 KiB
Nix
83 lines
2.0 KiB
Nix
{ lib
|
|
, callPackage
|
|
, rustPlatform
|
|
, fetchFromGitHub
|
|
, protobuf
|
|
, darwin
|
|
, stdenv
|
|
, buildNpmPackage
|
|
}:
|
|
let
|
|
version = "0.2.4";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "ekzhang";
|
|
repo = "sshx";
|
|
rev = "refs/tags/v${version}";
|
|
hash = "sha256-RIQRX4sXlMl73Opi6hK2WD/erdAMNrm40IasHasikuw=";
|
|
};
|
|
|
|
mkSshxPackage = { pname, cargoHash, ... }@args:
|
|
rustPlatform.buildRustPackage (rec {
|
|
inherit
|
|
pname
|
|
version
|
|
src
|
|
cargoHash;
|
|
|
|
nativeBuildInputs = [ protobuf ];
|
|
|
|
buildInputs = lib.optional stdenv.hostPlatform.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";
|
|
changelog = "https://github.com/ekzhang/sshx/releases/tag/v${version}";
|
|
license = lib.licenses.mit;
|
|
maintainers = with lib.maintainers; [ pinpox kranzes ];
|
|
mainProgram = pname;
|
|
};
|
|
} // args);
|
|
in
|
|
{
|
|
sshx = mkSshxPackage {
|
|
pname = "sshx";
|
|
cargoHash = "sha256-PMSKhlHSjXKh/Jxvl2z+c1zDDyuVPzQapvdCdcuaFYc=";
|
|
};
|
|
|
|
sshx-server = mkSshxPackage rec {
|
|
pname = "sshx-server";
|
|
cargoHash = "sha256-ySsTjNoI/nuz2qtZ4M2Fd9zy239+E61hUCq1r/ahgsA=";
|
|
|
|
postPatch = ''
|
|
substituteInPlace crates/sshx-server/src/web.rs \
|
|
--replace-fail 'ServeDir::new("build")' 'ServeDir::new("${passthru.web.outPath}")' \
|
|
--replace-fail '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-fail 'execSync("git rev-parse --short HEAD").toString().trim()' '"${src.rev}"'
|
|
'';
|
|
|
|
npmDepsHash = "sha256-bKePCxo6+n0EG+4tbbMimPedJ0Hu1O8yZsgspmhobOs=";
|
|
|
|
installPhase = ''
|
|
mkdir -p "$out"
|
|
cp -r build/* "$out"
|
|
'';
|
|
};
|
|
};
|
|
}
|