about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/no/nosql-workbench/package.nix
blob: 9fb744fa6570faa68d257ae7ca8949981b591ba0 (plain) (blame)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{
  appimageTools,
  lib,
  fetchurl,
  jdk21,
  stdenv,
  _7zz
}:
let
  pname = "nosql-workbench";
  version = "3.11.0";

  src = fetchurl {
    x86_64-darwin = {
      url = "https://s3.amazonaws.com/nosql-workbench/NoSQL%20Workbench-mac-x64-${version}.dmg";
      hash = "sha256-KM3aDDsQGZwUKU/or0eOoP8okAOPH7q8KL46RwfqhzM=";
    };
    aarch64-darwin = {
      url = "https://s3.amazonaws.com/nosql-workbench/NoSQL%20Workbench-mac-arm64-${version}.dmg";
      hash = "sha256-LzHiCMrDOWDuMNkkojLgKn+UG7x76wSAz0BapyWkAzU=";
    };
    x86_64-linux = {
      url = "https://s3.amazonaws.com/nosql-workbench/NoSQL%20Workbench-linux-${version}.AppImage";
      hash = "sha256-cDOSbhAEFBHvAluxTxqVpva1GJSlFhiozzRfuM4MK5c=";
    };
  }.${stdenv.system} or (throw "Unsupported system: ${stdenv.system}");

  meta = {
    description = "Visual tool that provides data modeling, data visualization, and query development features to help you design, create, query, and manage DynamoDB tables";
    homepage = "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/workbench.html";
    changelog = "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkbenchDocumentHistory.html";
    license = lib.licenses.unfree;
    maintainers = with lib.maintainers; [ DataHearth ];
    platforms = [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" ];
  };
in
if stdenv.isDarwin then stdenv.mkDerivation {
  inherit pname version src meta;

  sourceRoot = ".";

  nativeBuildInputs = [ _7zz ];

  buildInputs = [ jdk21 ];

  # DMG file is using APFS which is unsupported by "undmg".
  # Instead, use "7zz" to extract the contents.
  # "undmg" issue: https://github.com/matthewbauer/undmg/issues/4
  unpackCmd = ''
    runHook preUnpack

    7zz x $curSrc

    runHook postUnpack
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p "$out/Applications"
    mv NoSQL\ Workbench.app $out/Applications/

    runHook postInstall
  '';

} else appimageTools.wrapType2 {
  inherit pname version src meta;

  extraPkgs = ps: (appimageTools.defaultFhsEnvArgs.multiPkgs ps) ++ [
    # Required to run DynamoDB locally
    ps.jdk21
  ];

  extraInstallCommands = let
    appimageContents = appimageTools.extract {
      inherit pname version src;
    };
  in ''
    # Replace version from binary name
    mv $out/bin/${pname}-${version} $out/bin/${pname}

    # Install XDG Desktop file and its icon
    install -Dm444 ${appimageContents}/nosql-workbench.desktop -t $out/share/applications
    install -Dm444 ${appimageContents}/nosql-workbench.png -t $out/share/pixmaps

    # Replace wrong exec statement in XDG Desktop file
    substituteInPlace $out/share/applications/nosql-workbench.desktop \
        --replace 'Exec=AppRun --no-sandbox %U' 'Exec=nosql-workbench'
  '';
}