Closed turboMaCk closed 5 years ago
@Gabriel439 How would you make such a shell
attribute in release.nix
? You would have to combine the env
with the extra packages somehow, but I can't quite figure out the specifics.
@anka-213: I believe you can do this with the pkgs.lib.mkShell
utility (https://github.com/NixOS/nixpkgs/blob/300c205cf9bfd86f65dabcc1f3b4439cea42cbc1/pkgs/build-support/mkshell/default.nix), like this:
pkgs.lib.mkShell {
inputsFrom = [ pkgs.haskellPackages.myPackage.env ];
builtInputs = [ pkgs.myExtraTool ];
}
@Gabriel439 I'm afraid I celebrated too early. That does not seem to work. The shell no longer contains the dependencies for myPackage
with this shell.
@anka-213 what about something like:
rec {
project = ....;
shell = project.env // pkgs.mkShell {
buildInputs = [ pkgs.myExtraTool ];
};
}
nix-shell -A shell
Also, I would maybe try to remove .env
from inputsFrom
but I'm not sure if that should help or not.
@turboMaCk That unfortunately seems to work even worse. Now we are even missing ghc, not just the haskell libraries that we depended on.
I think what I end up doing is to run nix-build
before nix-shell
when some dependencies are changed which I think resolved similar issues for me. I know it seems like a workaround but you can try it. It might also provide some hints of what is going wrong...
@turboMaCk It didn't help and I can't see how it would? nix-build
is supposed to have no side-effects.
However, I believe that the function shellFor could be used successfully. Here's an example of it being used: https://github.com/Infinisil/soph/blob/master/shell.nix
Shouldn't but given derivations are evaluated lazily and bugs do exist... I don't know nix internals enough to guess really. Pls, let us know if you're successful with shellFor
.
Also, my instructions could have been wrong. I didn't test them first 🙂
@anka-213: So I just tested this and as far as I can tell the example I gave should work (except replacing pkgs.lib.mkShell
with pkgs.mkShell
and builtInputs
with buildInputs
):
pkgs.mkShell {
inputsFrom = [ pkgs.haskellPackages.myPackage.env ];
buildInputs = [ pkgs.myExtraTool ];
}
How are you verifying that it doesn't work?
So shell.nix becomes
{ pkgs ? import <nixpkgs> { } }:
let
project = pkgs.haskellPackages.callPackage ./project0.nix { };
in pkgs.mkShell {
buildInputs = [ pkgs.haskellPackages.ghcid ];
inputsFrom = [ project.env ];
}
I've created a repo if anyone wants to try this out: https://github.com/Boshen/nix-haskell
Hello 👋
I've personally found it helpful to have the ability of adding some extra dev tools dependencies to
nix-shell
. I'm not really sure if this the best way to do it but it was not obvious for me at first how to do it and this is what I came up with.Given this repository is under your name feel free to close this PR if this is not something you would personally feel is wise to recommend. No preasure.