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
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, likepackages = hsPkgs: [hsPkgs.pkgA, hsPkgs.pkgB];
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.