Unable to build on NixOS #4

jodonoghue opened this Issue Apr 18, 2012 · 2 comments


None yet

1 participant


Issue reported by Peter Simons. See http://permalink.gmane.org/gmane.comp.lang.haskell.wxhaskell.devel/830

On 17 April 2012 06:15, SourceForge.net noreply@sourceforge.net wrote:

Bugs item #3518787, was opened at 2012-04-17 06:15
Message generated for change (Tracker Item Submitted) made by peti
You can respond by visiting:


Submitted By: Peter Simons (peti)
Assigned to: Nobody/Anonymous (nobody)
Summary: wxc build doesn't install libwxc.so

Initial Comment:
When I build and install wxc on Nixos, then the Setup.hs procedure fails to installs the generated libwxc.so DLL into the target directory. A complete build log is attached below that shows the output from running "./Setup configure -v3 && ./Setup build && ./Setup copy -v3".

I have looked at the log, and I think I understand the source of the problem, but not how to fix it, as I know nothing about NixOS beyond a 5 minute browse at the website just now and a good look at the build log. It looks as though it has a very different idea about where code is built and installed than other Unix systems, and we have designed and tested for a more typical scenario. That said - let's see if we can find a work-around.

Because wxc is a shared library, we try to install it in a location where a typical Unix system stands a chance of finding it. We do this with a custom install hook (in Setup.hs), the relevant part of which is below:

-- Copy shared library
let bld_dir = buildDir local_bld_info

    ver = (pkgVersion . package) pkg_descr
    lib = fromJust (library pkg_descr)
    lib_bi = libBuildInfo lib
    custom_bi = customFieldsBI lib_bi
    dll_name = fromJust (lookup "x-dll-name" custom_bi)
    lib_name = sharedLibName ver dll_name

    inst_lib_dir = libdir $ absoluteInstallDirs pkg_descr local_bld_info NoCopyDest

installOrdinaryFile (fromFlag (installVerbosity inst_flags)) (bld_dir </> lib_name) (inst_lib_dir </> lib_name)
ldconfig inst_lib_dir

What this does it to pick up the requested install directory from the package description and build info. In most cases this translates to somewhere under the ~/.cabal directory in the user's home directory. It sounds like this may not really exist in the same form on NixOS.

If I read the Cabal documentation correctly, you may be able to work around this by using the --libdir= option when running Setup.hs configure. In any event, the install directory you want needs to be passed via the configuration if you want to install anywhere out of the ordinary.

Unfortunately, it's not realistic for me to construct a NixOS build environment (I already maintain MacOS X, Windows 7, Ubuntu and FreeBSD, which is plenty, believe me), so I need to rely on you to try things out and see how they work.


Comment By: Peter Simons (peti)
Date: 2012-04-17 10:26

To the best of my understanding, "./Setup copy" is supposed to perform the
installation -- except for registering the built packages with the
compiler. We perform that last step separately, i.e. by running "./Setup
register". In my humble opinion, wxc's Setup.hs file should support the
copy phase properly, i.e. it should copy the shared object it built.

Comment By: Jeremy O'Donoghue (jodonoghue)
Date: 2012-04-17 10:10

I also note that use you Setup copy. The recommended install procedure is:

Setup configure && Setup build&& Setup install

Without the Setup install stage, the install hook for libwxc.so never gets

Comment By: Jeremy O'Donoghue (jodonoghue)
Date: 2012-04-17 10:08

We don't really claim to support NixOS, but this may not be too difficult
to fix if install directory is specified on the configure command line.


Try adding a custom Copy hook. See copyHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> CopyFlags -> IO (). Code should be similar to the Install hook.

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