I'm using stack 1.0.2 x86_64 and this stack.yaml:
flags: {}
packages:
- '.'
extra-deps:
- imagemagick-0.0.3.5
resolver: lts-3.20
nix:
enable: true
packages:
- zlib
- imagemagick
- pkgconfig
When I run stack build I get:
Configuring hfsevents-0.1.6...
Building hfsevents-0.1.6...
Preprocessing library hfsevents-0.1.6...
[1 of 1] Compiling System.OSX.FSEvents ( System/OSX/FSEvents.hs, .stack-work/dist/x86_64-osx-nix/Cabal-1.22.4.0/build/System/OSX/FSEvents.o )
cbits/c_fsevents.m:1:10:
fatal error: 'CoreServices/CoreServices.h' file not found
#include <CoreServices/CoreServices.h>
^
1 error generated.
Do I have to include the system frameworks somehow?
cc @YPares any ideas?
I had a look at it. @lippling Can you try to add darwin.xcode to your dependencies? It might ask you to have XCode already installed on your system.
(Nix support for OSX evolves quickly)
@YPares it says:
$ stack build
error: Package ‘xcode-5.1’ in ‘/nix/store/bq67byr5wp5ww84lgli37icfc9aldgf7-nixpkgs-16.03pre75806.77f8f35/nixpkgs/pkgs/os-specific/darwin/xcode/default.nix:49’ has an unfree license (‘unfree’), refusing to evaluate.
a) For `nixos-rebuild` you can set
{ nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.
b) For `nix-env`, `nix-build` or any other Nix command you can add
{ allowUnfree = true; }
to ~/.nixpkgs/config.nix.
(use ‘--show-trace’ to show detailed location information)
Btw: Xcode 7.2 is already installed on my system (and ready to go).
@lippling you'll need to do as it says: copy/paste the code snippet given in option (b) in the error message into the named file.
Ok, now I should download the dmg by hand and call:
either
nix-store --add-fixed sha256 xcode_5.1.dmg
or
nix-prefetch-url --type sha256 file:///path/to/xcode_5.1.dmg
I'll stop that for now, because I don't want my colleagues to go through this for my small project. Everybody has Xcode 7.2 installed, so the process without Nix and with Homebrew is much easier.
One last question: what happens on Linux as I specified darwin.xcode as a dependency?
stack.yaml files don't include conditionals. So in this particular case, if you want a cross platform build, you'll have to either write two stack.yaml's (one for Linux and one for OS X), much like the FAQ recommends for multiple GHC versions, or use nix.shell-file instead of nix.packages, since Nix shell files allow arbitrary conditionals.
Ok thanks.
I don't think you need darwin.xcode, actually. Doing something like idris-lang/idris-dev#2938 solved it for me. Just FYI.
@projedi You're right. Is it something you often have to do on OSX?
If it's the case, maybe Stack should automatically add darwin.apple_sdk.frameworks.CoreServices on OSX to the dependencies (just like it does right now on Linux for glibcLocales) or provide an option so it can easily be activated. Or else you're left with having to roll your own shell.nix or maintain two different stack.yaml files.
I'm not exactly sure how to estimate. Cocoa will probably be required if you depend on one of the Apple frameworks. Other frameworks seem to be more specialized and unlikely to be needed by many packages. To get the statistics one can probably analyze Haskell infrastructure in Nixpkgs themselves since those do have the correct native dependencies, but I don't know how to do that exactly.
Most helpful comment
@projedi You're right. Is it something you often have to do on OSX?
If it's the case, maybe Stack should automatically add
darwin.apple_sdk.frameworks.CoreServiceson OSX to the dependencies (just like it does right now on Linux forglibcLocales) or provide an option so it can easily be activated. Or else you're left with having to roll your ownshell.nixor maintain two differentstack.yamlfiles.