summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/bc/bcompare/package.nix
blob: 5ead16ad0a959772887ab29d25497966ad8acc7c (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
{
  lib,
  autoPatchelfHook,
  bzip2,
  fetchurl,
  glibc,
  gobject-introspection,
  kdePackages,
  python3,
  stdenv,
  runtimeShell,
  unzip,
  wrapGAppsHook3,
}:

let
  pname = "bcompare";
  version = "5.2.4.32425";

  throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";

  srcs = {
    x86_64-linux = fetchurl {
      url = "https://www.scootersoftware.com/files/bcompare-${version}_amd64.deb";
      sha256 = "sha256-gXmz7ZgTLPNzqckzKV7r+B8V0oS10/GQNTM0/0EYs3s=";
    };

    aarch64-darwin = fetchurl {
      url = "https://www.scootersoftware.com/files/BCompareOSX-${version}.zip";
      sha256 = "sha256-CzAARAKDBSORI/zCELEdA8VRdWXHq+sMHGPkr3wV+G8=";
    };
  };

  src = srcs.${stdenv.hostPlatform.system} or throwSystem;

  linux =
    let
      python = python3.withPackages (
        pp: with pp; [
          pygobject3
        ]
      );
    in
    stdenv.mkDerivation {
      inherit
        pname
        version
        src
        meta
        ;
      unpackPhase = ''
        ar x $src
        tar xfz data.tar.gz
      '';

      installPhase = ''
        mkdir -p $out/{bin,lib,share}

        cp -R usr/{bin,lib,share} $out/

        # Remove library that refuses to be autoPatchelf'ed
        #  - bcompare_ext_kde.amd64.so is linked with Qt4
        #  - bcompare_ext_kde5.amd64.so is linked with Qt5
        rm $out/lib/beyondcompare/ext/bcompare_ext_kde.amd64.so
        rm $out/lib/beyondcompare/ext/bcompare_ext_kde5.amd64.so

        substituteInPlace $out/bin/bcompare \
          --replace-fail "/usr/lib/beyondcompare" "$out/lib/beyondcompare" \
          --replace-fail "ldd" "${glibc.bin}/bin/ldd" \
          --replace-fail "/bin/bash" "${runtimeShell}"

        substituteInPlace $out/lib/beyondcompare/bcmount.sh \
          --replace-fail "python3" "${python.interpreter}"
      '';

      nativeBuildInputs = [
        autoPatchelfHook
        gobject-introspection
        wrapGAppsHook3
      ];

      buildInputs = [
        (lib.getLib stdenv.cc.cc)
        kdePackages.kio
        kdePackages.kservice
        kdePackages.ki18n
        kdePackages.kcoreaddons
        bzip2
      ];

      dontBuild = true;
      dontConfigure = true;
      dontWrapQtApps = true;

      __structuredAttrs = true;
      strictDeps = true;
    };

  darwin = stdenv.mkDerivation {
    inherit
      pname
      version
      src
      meta
      ;
    nativeBuildInputs = [ unzip ];

    installPhase = ''
      mkdir -p $out/Applications/BCompare.app
      cp -R . $out/Applications/BCompare.app
    '';

    __structuredAttrs = true;
    strictDeps = true;
  };

  meta = {
    description = "GUI application that allows to quickly and easily compare files and folders";
    longDescription = ''
      Beyond Compare is focused. Beyond Compare allows you to quickly and easily compare your files and folders.
      By using simple, powerful commands you can focus on the differences you're interested in and ignore those you're not.
      You can then merge the changes, synchronize your files, and generate reports for your records.
    '';
    homepage = "https://www.scootersoftware.com";
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    license = lib.licenses.unfree;
    maintainers = with lib.maintainers; [
      ktor
      arkivm
      barsikus007
    ];
    platforms = builtins.attrNames srcs;
    mainProgram = "bcompare";
  };
in
if stdenv.hostPlatform.isDarwin then darwin else linux