about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/editors/jetbrains/darwin.nix
blob: b1002e235824c9a392cbc4a3a123118d3c0b9678 (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
{ lib
, stdenvNoCC
, undmg
, ...
}:

{ meta
, name
, product
, productShort ? product
, src
, version
, ...
}:

let
  loname = lib.toLower productShort;
in
  stdenvNoCC.mkDerivation {
    inherit meta src version;
    desktopName = product;
    installPhase = ''
      runHook preInstall
      APP_DIR="$out/Applications/${product}.app"
      mkdir -p "$APP_DIR"
      cp -Tr "${product}.app" "$APP_DIR"
      mkdir -p "$out/bin"
      cat << EOF > "$out/bin/${loname}"
      open -na '$APP_DIR' --args "\$@"
      EOF
      chmod +x "$out/bin/${loname}"
      runHook postInstall
    '';
    nativeBuildInputs = [ undmg ];
    pname = lib.concatStringsSep "-" (lib.init (lib.splitString "-" name));
    sourceRoot = ".";
  }