haskell.nix icon indicating copy to clipboard operation
haskell.nix copied to clipboard

How to include packages from pkgs?

Open miuirussia opened this issue 5 years ago • 10 comments

I have project with stack.yaml:

resolver: lts-14.7
packages:
  - '.'
nix:
  packages: [
    bzip2
    icu
    libcxx
    lzma
    mysql80
    pcre
    pkg-config
    postgresql
    zlib
  ]

When I use stack-to-nix, it does not consider for the nix section of stack.yaml, so the build fails with mysql_config not found error. How I can add this packages to default.nix?

miuirussia avatar Jan 28 '20 17:01 miuirussia

@miuirussia I assume you figure out how to fix this? It is true that stack-to-nix ignores the nix section. stack-to-nix just translates the lts + packages into a build plan. Haskell.nix pulls system packages from nixpkgs by default.

Anyway if you figured out how to fix this in a way that works for you, and could let us know that would be great!

angerman avatar Jan 30 '20 09:01 angerman

I added packages manually with modules section in default.nix, maybe it would be great if stack-to-nix do it automatically.

miuirussia avatar Jan 30 '20 09:01 miuirussia

@miuirussia patches welcome! stack-to-nix lives in github.com/input-output-hk/nix-tools, the binaries are all pretty simple haskell programs.

angerman avatar Jan 30 '20 09:01 angerman

I added packages manually with modules section in default.nix, maybe it would be great if stack-to-nix do it automatically.

@miuirussia can you tell me how exactly you added it to modules? I'm running into the same issue and cannot figure out how to add it properly. thanks

JorisM avatar Jul 01 '20 13:07 JorisM

I have the same problem with mysql_config, did you ever figure it out @JorisM ? I tried all of the below options I could find in the documentation but no luck:

packages.mysql.components.library.libs = [pkgs.mysql];
packages.mysql.components.setup.libs = [pkgs.mysql];
packages.mysql.components.library.build-tools = [pkgs.mysql];
packages.mysql.components.setup.build-tools = [pkgs.mysql];
packages.mysql.components.foreignlibs.build-tools = [pkgs.mysql];
packages.mysql.components.sublibs.build-tools = [pkgs.mysql];

thomasjm avatar Jul 22 '20 23:07 thomasjm

Never mind, I was just having confusion from using a nixpkgs version where mysql didn't provide the mysql_config binary. The modules command that worked was

packages.mysql.components.library.build-tools = [pkgs.mysql];

thomasjm avatar Jul 23 '20 00:07 thomasjm

@thomasjm awesome!

angerman avatar Jul 23 '20 02:07 angerman

(Also, if you are on newer nixpkgs, you might need pkgs.libmysqlclient instead.)

IMO this issue can be closed, but it would be great if there were a page in the documentation about this. There are a bewildering number of options in the "Module options" section of the docs, and it's not always obvious how they map to the final Nix expressions. I had to go digging into the haskell.nix code to confirm my understanding that build-tools options end up turning into nativeBuildInputs.

thomasjm avatar Jul 23 '20 05:07 thomasjm

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 28 '22 21:09 stale[bot]

So we need to add docs that indicate that if you need to add to a components buildInputs use .libs and if you need to add to nativeBuildInputs use .build-tools.

hamishmack avatar Oct 05 '22 10:10 hamishmack