stack2nix icon indicating copy to clipboard operation
stack2nix copied to clipboard

Fixing `nix-build` issue on OSX where `CoreServices` was not found.

Open forficate opened this issue 7 years ago • 14 comments

Resolves the below error when building on OSX:

❯ nix-build
error: anonymous function at ~/Work/stack2nix/stack2nix.nix:16465:10 called without required argument 'CoreServices', at /nix/store/shm5fcq49wnwgjhpn4l05jzg53wm0h2b-nixpkgs-18.09pre151052.4477cf04b67/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:88:27
(use '--show-trace' to show detailed location information)

Note I also needed to override the pkgs value as I hit the clang to many arguments issue https://github.com/NixOS/nixpkgs/issues/41340 .

❯ nix-build --arg pkgs 'import <nixpkgs> {}'

forficate avatar Sep 09 '18 06:09 forficate

Thanks, the fix belongs into default.nix as stack2nix.nix is autogenerated.

domenkozar avatar Sep 21 '18 10:09 domenkozar

@domenkozar I have come across this issue myself, how do I override this in default.nix, I can't work it out?

shmish111 avatar Sep 26 '18 11:09 shmish111

Could actually be a bug in stack2nix, hackage2nix generates:

     }) {inherit (pkgs.darwin.apple_sdk.frameworks) Cocoa; 
         inherit (pkgs.darwin.apple_sdk.frameworks) CoreServices;};
``

domenkozar avatar Sep 26 '18 11:09 domenkozar

Ah I see, yes that seems to work except that I'm getting stuck with clang: Argument list too long now :(

shmish111 avatar Sep 26 '18 11:09 shmish111

nix-build (Nix) 2.1.2

shmish111 avatar Sep 26 '18 11:09 shmish111

you should bump nixpkgs, this was a bug a few months ago.

domenkozar avatar Sep 26 '18 11:09 domenkozar

Hmm, I get the same with

➜  stack2nix git:(60c3698) ✗ nix-channel --list
nixpkgs https://nixos.org/channels/nixpkgs-18.09-darwin
unstable https://nixos.org/channels/nixpkgs-unstable
➜  stack2nix git:(60c3698) ✗ nix-channel --update
unpacking channels...
➜  stack2nix git:(60c3698) ✗ NIX_PATH=nixpkgs=/Users/davidsmith/.nix-defexpr/channels/unstable/ nix-build

and NIX_PATH=nixpkgs=/Users/davidsmith/.nix-defexpr/channels/nixpkgs/ nix-build

shmish111 avatar Sep 26 '18 11:09 shmish111

So the error happens when you build resulting stack2nix packages?

domenkozar avatar Sep 26 '18 11:09 domenkozar

no this is actually trying to build stack2nix, with the small change {inherit (pkgs.darwin.apple_sdk.frameworks) Cocoa; inherit (pkgs.darwin.apple_sdk.frameworks) CoreServices;}; in stack2nix.nix

shmish111 avatar Sep 26 '18 11:09 shmish111

@shmish111 we need to bump pinned nixpkgs :) btw, you can use stack2nix from nixpkgs and that surely works. Unless you're trying to contribute something.

domenkozar avatar Sep 26 '18 11:09 domenkozar

ok, no I'm not, I'll try that. I remember a while ago that I needed to install the latest so I guess I just got stuck on that. Thanks.

shmish111 avatar Sep 26 '18 11:09 shmish111

Yes I went down bit of a rabbit hole trying to fix this.

I could not get stack2nix to add CoreServices to the output derivation so added manually not knowing the nix/haskell interop setup.

When that was resolved I got the clang: Argument list too long. I think I managed to resolve that then got another issue then another which took up a weekend when originally reporting that and haven't had a chance to look at it again yet. If I remember correctly I think I got to tracing some issues with cable2nix which where causing stack2nix to fail.

Yesterday I did a nix-channel --update using unstable on osx and stack2nix causes nix-env --update '*' to fail now.

It looks like stack2nix is broken currently, on osx at least. I'll see if I can find how I resolved the clang: Argument list too long issue and trace how far I got.

forficate avatar Sep 26 '18 23:09 forficate

@ajevans85 why not use stack2nix from nixpkgs, that should work. I'll see if I can fix it here as well.

domenkozar avatar Sep 27 '18 13:09 domenkozar

Is there a chance for this PR to be merged?

ryota-ka avatar Sep 09 '20 13:09 ryota-ka