summaryrefslogtreecommitdiff
path: root/pkgs/by-name/op/opcua-commander/package.nix
blob: 79af40699445534ae2111ee45a1433112a032f6c (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{
  lib,
  stdenv,
  buildNpmPackage,
  fetchFromGitHub,
  typescript,
  esbuild,
  makeWrapper,
  nodejs,
}:
buildNpmPackage rec {
  pname = "opcua-commander";
  version = "0.40.0";

  src = fetchFromGitHub {
    owner = "node-opcua";
    repo = "opcua-commander";
    rev = version;
    hash = "sha256-qoBpYN0EiXiuhH+hXjVPK2ET8Psjz52rocohU8ccVIg=";
  };

  npmDepsHash = "sha256-HB4boWgZWoG+ib+cCoQbUmrrV5rECR3dMwj2lCyJjT0=";
  nativeBuildInputs = [
    esbuild
    typescript
    makeWrapper
  ];

  postPatch =
    let
      esbuildPrefix =
        "esbuild"
        # Workaround for 'No loader is configured for ".node" files: node_modules/fsevents/fsevents.node'
        # esbuild issue is https://github.com/evanw/esbuild/issues/1051
        + lib.optionalString stdenv.hostPlatform.isDarwin " --external:fsevents";
    in
    ''
      substituteInPlace package.json \
        --replace-fail 'npx -y esbuild' '${esbuildPrefix}'
    '';

  # We need to add `nodejs` to PATH for `opcua-commander` to properly work
  # when connected to an OPC-UA server.
  # Test it with:
  # ./opcua-commander -e opc.tcp://opcuademo.sterfive.com:26543
  postFixup = ''
    wrapProgram $out/bin/opcua-commander \
      --prefix PATH : "${lib.makeBinPath [ nodejs ]}"
  '';

  meta = with lib; {
    description = "Opcua client with blessed (ncurses)";
    homepage = "https://github.com/node-opcua/opcua-commander";
    license = licenses.mit;
    maintainers = with maintainers; [ jonboh ];
    mainProgram = "opcua-commander";
  };
}