this post was submitted on 22 Aug 2023
7 points (100.0% liked)

Nix / NixOS

1789 readers
6 users here now

Main links

Videos

founded 1 year ago
MODERATORS
 

I've got a small haskell project and I am building it using a flake using cabal2nix based on a package.yaml file.

nix build works fine, but I have trouble with my nix develop shell. The shell is built using shellFor from haskellPackages.

Is it possible to construct a shell that contains all dependencies to build the package, but not the package itself? I tried returning the buildInputs from the packages function, but that didn't seem to have any effect. When I return my package from that function, all dependencies are available, however the package is also built - is that how it is supposed to be?

#nix #haskell

you are viewing a single comment's thread
view the rest of the comments
[โ€“] expr 3 points 1 year ago (1 children)

The packages you specify via the packages attribute are the ones it will build dependencies for, but not build. You want to return a list of packages selected from the argument attribute set, like

packages = hsPkgs: [hsPkgs.pkgA, hsPkgs.pkgB];
[โ€“] jakalx 1 points 1 year ago

Thanks for clearing that up for me!

I have this snippet in my flake now:

packages = _: [ self.packages.${system}.default ];

And it seems to do exactly what I wanted.