Derivations failing on macOS due to libattr

Hi!

I’m trying to install several packages, and one common denominator is that libattr fails to build. These are the logs from nix-env -i xpra (for example)

make[1]: Entering directory '/private/var/folders/sm/cz021gxs6ndc48yqz8r8n5wc0000gn/T/nix-build-attr-2.4.48.drv-0/attr-2.4.48'
  CC       libattr/libattr_la-attr_copy_action.lo
  CC       libattr/libattr_la-attr_copy_check.lo
  CC       libattr/libattr_la-attr_copy_fd.lo
libattr/attr_copy_fd.c:76:36: error: too few arguments to function call, expected 4, have 3
        size = flistxattr (src_fd, NULL, 0);
               ~~~~~~~~~~                 ^
/nix/store/x8xzlisjy8lm7d071n10gkiflq7dxdhy-Libsystem-osx-10.12.6/include/sys/xattr.h:75:1: note: 'flistxattr' declared here
ssize_t flistxattr(int fd, char *namebuff, size_t size, int options);
^
libattr/attr_copy_fd.c:92:40: error: too few arguments to function call, expected 4, have 3
        size = flistxattr (src_fd, names, size);
               ~~~~~~~~~~                     ^
/nix/store/x8xzlisjy8lm7d071n10gkiflq7dxdhy-Libsystem-osx-10.12.6/include/sys/xattr.h:75:1: note: 'flistxattr' declared here
ssize_t flistxattr(int fd, char *namebuff, size_t size, int options);
^
libattr/attr_copy_fd.c:111:42: error: too few arguments to function call, expected 6, have 4
                size = fgetxattr (src_fd, name, NULL, 0);
                       ~~~~~~~~~                       ^
/nix/store/x8xzlisjy8lm7d071n10gkiflq7dxdhy-Libsystem-osx-10.12.6/include/sys/xattr.h:63:1: note: 'fgetxattr' declared here
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size, u_int32_t position, int options);
^
libattr/attr_copy_fd.c:128:46: error: too few arguments to function call, expected 6, have 4
                size = fgetxattr (src_fd, name, value, size);
                       ~~~~~~~~~                           ^
/nix/store/x8xzlisjy8lm7d071n10gkiflq7dxdhy-Libsystem-osx-10.12.6/include/sys/xattr.h:63:1: note: 'fgetxattr' declared here
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size, u_int32_t position, int options);
^
libattr/attr_copy_fd.c:139:46: error: too few arguments to function call, expected 6, have 5
                if (fsetxattr (dst_fd, name, value, size, 0) != 0) {
                    ~~~~~~~~~                              ^
/nix/store/x8xzlisjy8lm7d071n10gkiflq7dxdhy-Libsystem-osx-10.12.6/include/sys/xattr.h:67:1: note: 'fsetxattr' declared here
int fsetxattr(int fd, const char *name, const void *value, size_t size, u_int32_t position, int options);
^
5 errors generated.
make[1]: *** [Makefile:1001: libattr/libattr_la-attr_copy_fd.lo] Error 1
make[1]: Leaving directory '/private/var/folders/sm/cz021gxs6ndc48yqz8r8n5wc0000gn/T/nix-build-attr-2.4.48.drv-0/attr-2.4.48'
make: *** [Makefile:1212: all-recursive] Error 1
builder for '/nix/store/yb9q3ridc0kprb8mq164z53mk1rk9xbs-attr-2.4.48.drv' failed with exit code 2
cannot build derivation '/nix/store/llxdb7zj1l4dm98br6hxs73hr33cvdyk-acl-2.2.53.drv': 1 dependencies couldn't be built
building '/nix/store/68932r5ipkaya3cqy5zx8aiq6dh3kwcp-audit-2.8.5.drv'...
cannot build derivation '/nix/store/24gq3wwrfgvl1d70nlnl97z13a7wjlls-libcap-2.27.drv': 1 dependencies couldn't be built
building '/nix/store/07c2a9sl8likijyvbfj6gp2lchd7wz8w-libasyncns-0.8.drv'...
cannot build derivation '/nix/store/fjy1a8sg1pavlkxiqf235w26lqg3m603-systemd-243.4.drv': 1 dependencies couldn't be built
building '/nix/store/s673acgbybawckq072srgq6hcc098rh9-libfakeXinerama-0.1.0.drv'...
cannot build derivation '/nix/store/7v5mc0m2ilra721b5adf2fgwj68syhkb-pulseaudio-13.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/vkhp701bsv97kpyaqrlf01d3bqf61430-python3.7-python-uinput-0.11.2.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/hk0cp5gmmvpdk62yspaffc13hgswjdys-xpra-2.5.3.drv': 1 dependencies couldn't be built
error: build of '/nix/store/hk0cp5gmmvpdk62yspaffc13hgswjdys-xpra-2.5.3.drv' failed

Has anyone else had this problem? I’m on nixpkgs-unstable.

I having the same problem, with nix on my mac and a colleagues mac. If you find a workaround we would much appreciate it. The man page shows signature of with more parameters than header files from channel. i.e. For flistxattr 3 parameters instead of 4, for fgetxattr 4 instead of 6, for fsetxattr 5 instead of 6.

NAME
     setxattr, fsetxattr -- set an extended attribute value

SYNOPSIS
     #include <sys/xattr.h>

     int
     setxattr(const char *path, const char *name, void *value, size_t size, u_int32_t position, int options);

     int
     fsetxattr(int fd, const char *name, void *value, size_t size, u_int32_t position, int options);

I tried different channels I am currently trying to patch manually these files but I don’t know if this is possible, nix might do some kind of verification, I really don’t know much.

I don’t think the attr library will ever build on mac, so the correct solution would be modifying the package to remove the attr library on mac.