Skip to content

Use XQuartz on Darwin#3101

Merged
jwiegley merged 2 commits intoNixOS:masterfrom
cstrahan:xquartz
Aug 14, 2014
Merged

Use XQuartz on Darwin#3101
jwiegley merged 2 commits intoNixOS:masterfrom
cstrahan:xquartz

Conversation

@cstrahan
Copy link
Copy Markdown
Contributor

I'm opening this ticket to track my work on getting XQuartz into Nixpkgs for X11 on Darwin.

As of writing this, this branch is incredibly chopped up and unstable. I'd would suggest waiting for me to give the thumbs up here before diving in and trying to make any sense of it.

Some notes:

  • The XQuartz repo
  • XQuartz build instructions
  • Some build scripts
  • The MacPorts Portfile: 1.14.6, 1.15.1
  • MacPorts guide
  • The XQuartz project bundles both xorgserver (X, Xvfb, Xnest, Xephyr, Xfake, etc) and the XQuartz.app in the same source tree. They must be compiled separately (the --disable-xquartz --enable-xvfb --enable-xnest --enable-kdrive configure flags mentioned in the build instructions)
  • xorgserver (sans XQuartz.app) builds fine with stdenv (haven't tested that it functions properly yet), while the XQuartz.app will only build with clangStdenv
  • With some minor patches (replacing clock_gettime) in libdrm, all of xorgserver's dependencies build as-is
  • xinit needs to be built with clangStdenv. Currently, the generated pkgs/servers/x11/xorg/default.nix file does not support overriding the stdenv per package, so I'll need to come up with some solution to that.

@cstrahan
Copy link
Copy Markdown
Contributor Author

Here's the LaunchAgent and LaunchDaemon distributed with XQuartz:

/Library/LaunchAgents/org.macosforge.xquartz.startx.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>org.macosforge.xquartz.startx</string>
    <key>ProgramArguments</key>
    <array>
      <string>/opt/X11/lib/X11/xinit/launchd_startx</string>
      <string>/opt/X11/bin/startx</string>
      <string>--</string>
      <string>/opt/X11/bin/Xquartz</string>
    </array>
    <key>Sockets</key>
    <dict>
      <key>org.macosforge.xquartz:0</key>
      <dict>
        <key>SecureSocketWithKey</key>
        <string>DISPLAY</string>
      </dict>
    </dict>
    <key>ServiceIPC</key>
    <true/>
    <key>EnableTransactions</key>
    <true/>
  </dict>
</plist>

/Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>org.macosforge.xquartz.privileged_startx</string>
    <key>ProgramArguments</key>
    <array>
      <string>/opt/X11/lib/X11/xinit/privileged_startx</string>
      <string>-d</string>
      <string>/opt/X11/lib/X11/xinit/privileged_startx.d</string>
    </array>
    <key>MachServices</key>
    <dict>
      <key>org.macosforge.xquartz.privileged_startx</key>
      <true/>
    </dict>
    <key>TimeOut</key>
    <integer>120</integer>
    <key>EnableTransactions</key>
    <true/>
  </dict>
</plist>

@cstrahan
Copy link
Copy Markdown
Contributor Author

This is now feature complete. I've confirmed the following:

  • The installer script works
  • Launching XQuartz.app directly works
  • Starting Xquartz via launching an X app works
  • Xft fonts work
  • Font caching works
  • glxgears works
  • Fonts look goddamn gorgeous

I'm now using this xquartz package instead of the macosforge installer, and it works great.

@jwiegley @viric @vcunat (and any other interested parties):

Can I have you take a look at this? If I did everything correctly, it shouldn't impact Linux/NixOS (maybe some rebuilds due to extra empty environment variables on those platforms, but nothing more).

@cstrahan
Copy link
Copy Markdown
Contributor Author

Here's a teaser (xterm):

screen shot 2014-07-21 at 6 46 44 pm

And here's iTerm for comparison:

screen shot 2014-07-21 at 6 58 15 pm

:)

@cstrahan cstrahan changed the title [DON'T MERGE] Use XQuartz on Darwin Use XQuartz on Darwin Jul 21, 2014
@vcunat
Copy link
Copy Markdown
Member

vcunat commented Jul 22, 2014

Looks well-separated, and quite a lot of work, too.

I know very little about darwin and less about XQuartz, but what is the purpose of mesa there? It is (transitively) used by many other packages, as they need libGL_. At build time it's probably fine to use the newly added mesa-darwin, but during runtime I would expect to prefer the native /usr/lib/libGL_ on the machine, just as on NixOS we use the one from the chosen GPU driver.

@cstrahan
Copy link
Copy Markdown
Contributor Author

@vcunat Thank you for reviewing this. In XQuartz's case, it seems to just be a build time dependency - it isn't dynamically linked to mesa. As for the other cases, I'm not really sure how they might be used on Darwin. (The mesa-darwin package was a pretty direct port from the MacPort's Portfile.)

@vcunat
Copy link
Copy Markdown
Member

vcunat commented Jul 23, 2014

Would you/someone try at least running glxgears from glxinfo? I don't even know if such things worked before, but it would be better not to break them.

@cstrahan
Copy link
Copy Markdown
Contributor Author

@vcunat Aside from a vboxvideo related error message (I ran glxinfo in a VM), it appears to be working:

https://gist.github.com/cstrahan/4874bc101b960486175e

@vcunat
Copy link
Copy Markdown
Member

vcunat commented Jul 24, 2014

A darwin inside VM surprised me, but it's probably almost identical to real darwin. BTW, that mentioned driver is in vbox guest additions (at least on Linux).

@cstrahan
Copy link
Copy Markdown
Contributor Author

@vcunat
Copy link
Copy Markdown
Member

vcunat commented Jul 24, 2014

OpenGL version string: 2.1 NVIDIA-8.24.13 310.90.9.05f01

Yes, looks like it's picking the system driver.

I'm quite confident that linux is unaffected by this (just added -p to mkdir in xkeyboardconfig), but I have no idea about what it can break on darwin (and I never had any darwin). I think it might be best to create a separate darwin-only jobset for this on Hydra, so at least builds are tested and binaries provided for potential testers, before actually merging. I have no Hydra permissions to do this, however. @shlevy: still interested in darwin?

@cstrahan
Copy link
Copy Markdown
Contributor Author

@vcunat

I think it might be best to create a separate darwin-only jobset for this on Hydra, so at least builds are tested and binaries provided for potential testers, before actually merging.

That sounds like an excellent approach. If we can get a jobset configured, I'd be more than happy to tackle any failures. Thanks again for diving into this, I know it's a non-trivial PR to wade through.

@cstrahan
Copy link
Copy Markdown
Contributor Author

I just gave this one last self-review, and I found that there was an error logged in /var/log/system.log mentioning that fc-cache couldn't find the default font config file. I had to export FONTCONFIG_FILE in the script that the privileged daemon invokes. I made that change and fixed a couple copy-paste errors in commit cstrahan@7c7308d.

@cstrahan
Copy link
Copy Markdown
Contributor Author

Per @shlevy, this is pending the merge of other Darwin fixes in staging.

@cstrahan
Copy link
Copy Markdown
Contributor Author

I've rebased this onto current master. @shlevy can I have your or @jwiegley merge this, perhaps (now that staging is merged)?

@jwiegley
Copy link
Copy Markdown
Contributor

This is all working for me, so I'm going to pull the trigger now.

jwiegley added a commit that referenced this pull request Aug 14, 2014
@jwiegley jwiegley merged commit 06a324f into NixOS:master Aug 14, 2014
@vcunat
Copy link
Copy Markdown
Member

vcunat commented Aug 18, 2014

@cstrahan
Copy link
Copy Markdown
Contributor Author

@vcunat Yes, that's an old comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants