about summary refs log tree commit diff
path: root/pkgs/by-name/un/unison/package.nix
blob: 2d68ba5799b4728ca8adb851f3b80a8608f33e84 (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
{ lib
, stdenv
, fetchFromGitHub
, ocamlPackages
, copyDesktopItems
, makeDesktopItem
, wrapGAppsHook
, gsettings-desktop-schemas
, enableX11 ? !stdenv.isDarwin
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "unison";
  version = "2.53.4";

  src = fetchFromGitHub {
    owner = "bcpierce00";
    repo = "unison";
    rev = "v${finalAttrs.version}";
    hash = "sha256-nFT6FjlQjh6qx0fepmT4aiQj2SxA7U/as+IU9xXNok0=";
  };

  strictDeps = true;

  # uimac requires xcode
  postPatch = ''
    sed -i -e 's/ macuimaybe//' src/Makefile
  '';

  nativeBuildInputs = [ ocamlPackages.ocaml ocamlPackages.findlib ]
    ++ lib.optionals enableX11 [ copyDesktopItems wrapGAppsHook ];
  buildInputs = lib.optionals enableX11 [ gsettings-desktop-schemas ocamlPackages.lablgtk3 ];

  makeFlags = [ "PREFIX=$(out)" ]
    ++ lib.optionals (!ocamlPackages.ocaml.nativeCompilers) [ "NATIVE=false" ];

  postInstall = lib.optionalString enableX11 ''
    install -D $src/icons/U.svg $out/share/icons/hicolor/scalable/apps/unison.svg
  '';

  dontStrip = !ocamlPackages.ocaml.nativeCompilers;

  desktopItems = lib.optional enableX11 (makeDesktopItem {
    name = finalAttrs.pname;
    desktopName = "Unison";
    comment = "Bidirectional file synchronizer";
    genericName = "File synchronization tool";
    exec = "unison-gui";
    icon = "unison";
    categories = [ "Utility" "FileTools" "GTK" ];
    startupNotify = true;
    startupWMClass = "Unison";
  });

  meta = with lib; {
    homepage = "https://www.cis.upenn.edu/~bcpierce/unison/";
    description = "Bidirectional file synchronizer";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ viric nevivurn ];
    platforms = platforms.unix;
    broken = stdenv.isDarwin && enableX11; # unison-gui and uimac are broken on darwin
    mainProgram = if enableX11 then "unison-gui" else "unison";
  };
})