-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show how to incorporate ghcWithHoogle into shell.nix #33
Comments
ghcWithHoogle
into shell.nix
I don't know of an (easy) way to do this. Normally the way you would do this for a package already in |
@Gabriel439, so far I ended up including additional { compiler ? "ghc821" }:
let
bootstrap = import <nixpkgs> {};
nixpkgs = builtins.fromJSON (builtins.readFile ./nixpkgs.json);
src = bootstrap.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
inherit (nixpkgs) rev sha256;
};
pkgs = import src { };
in
with pkgs;
runCommand "shell" {
buildInputs = [
( haskell.packages.${compiler}.ghcWithHoogle ( ps: with ps; [
data-default
] ) )
];
} "" This file needs to be modified every time dependencies change (at least every time developer needs documentation on another dependency he/she is using). In addition there is a simple #!/usr/bin/env bash
nix-shell hoogle.nix --command "hoogle server -p 8080 --local --haskell" This has a bit of code duplication to re-use pinned This works kind of on the side from Though it would still be nice to enclose such things solely in
|
I've used this as my shell.nix in the past: { nixpkgs ? import <nixpkgs> {}, compiler ? "default", withHoogle ? true }:
let
inherit (nixpkgs) pkgs;
f = import ./default.nix;
packageSet = (
if compiler == "default"
then pkgs.haskellPackages
else pkgs.haskell.packages.${compiler}
);
haskellPackages = (
if withHoogle
then packageSet.override {
overrides = (self: super:
{
ghc = super.ghc // { withPackages = super.ghc.withHoogle; };
ghcWithPackages = self.ghc.withPackages;
}
);
}
else packageSet
);
drv = haskellPackages.callPackage f {};
in
if pkgs.lib.inNixShell then drv.env else drv It's designed to import a default.nix produced by The key idea is to override |
@cumber thanks a lot! I ended up extending your { compiler ? "ghc821"
, withHoogle ? true
}:
let
bootstrap = import <nixpkgs> {};
nixpkgs = builtins.fromJSON (builtins.readFile ./nixpkgs.json);
src = bootstrap.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
inherit (nixpkgs) rev sha256;
};
pkgs = import src {};
f = import ./default.nix;
packageSet = pkgs.haskell.packages.${compiler};
hspkgs = (
if withHoogle then
packageSet.override {
overrides = (self: super: {
ghc = super.ghc // { withPackages = super.ghc.withHoogle; };
ghcWithPackages = self.ghc.withPackages;
});
}
else packageSet
);
drv = hspkgs.callPackage f {};
in
if pkgs.lib.inNixShell then drv.env else drv |
Blocked-By: NixOS/nixpkgs#82245 Fixes Gabriella439#33
Show how to incorporate
ghcWithHoogle
intoshell.nix
preferably without modifyingdefault.nix
that is generated withcabal2nix . > default.nix
.The text was updated successfully, but these errors were encountered: