summary refs log tree commit diff
path: root/pkgs/applications/virtualization/open-vm-tools/default.nix
blob: 9c3f3f74e6a62d6e09698620d8866d005433cd7a (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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
{ stdenv
, lib
, fetchFromGitHub
, makeWrapper
, autoreconfHook
, bash
, fuse3
, libmspack
, openssl
, pam
, xercesc
, icu
, libdnet
, procps
, libtirpc
, rpcsvc-proto
, libX11
, libXext
, libXinerama
, libXi
, libXrender
, libXrandr
, libXtst
, libxcrypt
, libxml2
, pkg-config
, glib
, gdk-pixbuf-xlib
, gtk3
, gtkmm3
, iproute2
, dbus
, systemd
, which
, libdrm
, udev
, util-linux
, xmlsec
, withX ? true
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "open-vm-tools";
  version = "12.3.5";

  src = fetchFromGitHub {
    owner = "vmware";
    repo = "open-vm-tools";
    rev = "stable-${finalAttrs.version}";
    hash = "sha256-OuESPenXVDKLckIZ3sQCtQXZXCL6xSLZOxZWVEX2XMk=";
  };

  sourceRoot = "${finalAttrs.src.name}/open-vm-tools";

  outputs = [ "out" "dev" ];

  nativeBuildInputs = [
    autoreconfHook
    makeWrapper
    pkg-config
  ];

  buildInputs = [
    fuse3
    glib
    icu
    libdnet
    libdrm
    libmspack
    libtirpc
    libxcrypt
    libxml2
    openssl
    pam
    procps
    rpcsvc-proto
    udev
    xercesc
    xmlsec
  ] ++ lib.optionals withX [
    gdk-pixbuf-xlib
    gtk3
    gtkmm3
    libX11
    libXext
    libXinerama
    libXi
    libXrender
    libXrandr
    libXtst
  ];

  postPatch = ''
    sed -i Makefile.am \
      -e 's,etc/vmware-tools,''${prefix}/etc/vmware-tools,'
    sed -i scripts/Makefile.am \
      -e 's,^confdir = ,confdir = ''${prefix},' \
      -e 's,usr/bin,''${prefix}/usr/bin,'
    sed -i services/vmtoolsd/Makefile.am \
      -e 's,etc/vmware-tools,''${prefix}/etc/vmware-tools,' \
      -e 's,$(PAM_PREFIX),''${prefix}/$(PAM_PREFIX),'
    sed -i vgauth/service/Makefile.am \
      -e 's,/etc/vmware-tools/vgauth/schemas,''${prefix}/etc/vmware-tools/vgauth/schemas,' \
      -e 's,$(DESTDIR)/etc/vmware-tools/vgauth.conf,''${prefix}/etc/vmware-tools/vgauth.conf,'

    # don't abort on any warning
    sed -i 's,CFLAGS="$CFLAGS -Werror",,' configure.ac

    # Make reboot work, shutdown is not in /sbin on NixOS
    sed -i 's,/sbin/shutdown,shutdown,' lib/system/systemLinux.c

    # Fix paths to fuse3 (we do not use fuse2 so that is not modified)
    sed -i 's,/bin/fusermount3,${fuse3}/bin/fusermount3,' vmhgfs-fuse/config.c

    substituteInPlace services/plugins/vix/foundryToolsDaemon.c \
     --replace "/usr/bin/vmhgfs-fuse" "${placeholder "out"}/bin/vmhgfs-fuse" \
     --replace "/bin/mount" "${util-linux}/bin/mount"
  '';

  configureFlags = [
    "--without-kernel-modules"
    "--with-udev-rules-dir=${placeholder "out"}/lib/udev/rules.d"
    "--with-fuse=fuse3"
  ] ++ lib.optional (!withX) "--without-x";

  enableParallelBuilding = true;

  preConfigure = ''
    mkdir -p ${placeholder "out"}/lib/udev/rules.d
  '';

  postInstall = ''
    wrapProgram "$out/etc/vmware-tools/scripts/vmware/network" \
      --prefix PATH ':' "${lib.makeBinPath [ iproute2 dbus systemd which ]}"
    substituteInPlace "$out/lib/udev/rules.d/99-vmware-scsi-udev.rules" --replace "/bin/sh" "${bash}/bin/sh"
  '';

  meta = with lib; {
    homepage = "https://github.com/vmware/open-vm-tools";
    changelog = "https://github.com/vmware/open-vm-tools/releases/tag/stable-${finalAttrs.version}";
    description = "Set of tools for VMWare guests to improve host-guest interaction";
    longDescription = ''
      A set of services and modules that enable several features in VMware products for
      better management of, and seamless user interactions with, guests.
    '';
    license = licenses.gpl2;
    platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
    maintainers = with maintainers; [ joamaki kjeremy ];
  };
})