summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/cr/crossover/package.nix
blob: 59a6fce0fe34539ae2cd5a3cafa67e80ea9945df (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
  lib,
  stdenvNoCC,
  fetchurl,
  unzip,
  writeShellScript,
  curl,
  gnugrep,
  gnused,
  coreutils,
  common-updater-scripts,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "crossover";
  version = "26.3.0";

  __structuredAttrs = true;
  strictDeps = true;

  src = fetchurl {
    url = "https://media.codeweavers.com/pub/crossover/cxmac/demo/crossover-${finalAttrs.version}.zip";
    hash = "sha256-hojghIxOX3nxzDUctS0yRH2gDGwAz9O0uy0WTURYmiY=";
  };

  sourceRoot = ".";

  nativeBuildInputs = [ unzip ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out/Applications
    cp -R CrossOver.app $out/Applications/

    runHook postInstall
  '';

  passthru.updateScript = writeShellScript "crossover-update-script" ''
    set -euo pipefail
    export PATH="${
      lib.makeBinPath [
        curl
        gnugrep
        gnused
        coreutils
        common-updater-scripts
      ]
    }"

    new_version=$(curl -s "https://www.codeweavers.com/xml/versions/cxmac.xml" \
      | grep -oE 'crossover-[0-9]+\.[0-9]+\.[0-9]+\.zip' \
      | sed -E 's/crossover-(.*)\.zip/\1/' \
      | sort -V \
      | tail -n1)

    if [[ "${finalAttrs.version}" = "$new_version" ]]; then
      echo "crossover is already at the latest version $new_version."
      exit 0
    fi

    update-source-version "crossover" "$new_version" \
      --ignore-same-version
  '';

  meta = {
    description = "Run Windows applications on macOS without a Windows license";
    homepage = "https://www.codeweavers.com/crossover";
    license = lib.licenses.unfree;
    maintainers = [ lib.maintainers.delafthi ];
    platforms = lib.platforms.darwin;
    sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
  };
})