You are right, my bad! Sorry. I was so focused on the hoogle issue that I forgot the former, haha
I’ve completely changed how I do my setup, because I wanted as little repetition as possible (keep everything DRY).
I now use callCabal2nix in order to load the project from my cabal file, so that I don’t need to specify the packages again in my nix file.
It does not work yet, VS Code HIE extension has an issue with cabal-helper-wrapper, but I think I’ve reached something interesting
My ./from-cabal.nix
:
{ haskellPackages ? (import <nixpkgs> { }).haskellPackages }:
haskellPackages.callCabal2nix "my-project" ./.
Then ./default.nix
for classic build:
let
pkgs = import <nixpkgs> { };
in
pkgs.haskellPackages.callPackage (import ./from-cabal.nix) {}
And now the big boy (yet to fix), ./shell.nix
:
let
pkgs = import <nixpkgs> { };
all-hies = import (fetchTarball "https://github.com/infinisil/all-hies/tarball/master") {};
hie = all-hies.selection { selector = p: { inherit (p) ghc865; }; };
haskellPackages-withHoogle = (pkgs.haskellPackages.override {
overrides = (self: super:
{
ghc = super.ghc // { withPackages = super.ghc.withHoogle; };
ghcWithPackages = self.ghc.withPackages;
}
);
});
project-from-cabal = import ./from-cabal.nix { haskellPackages = haskellPackages-withHoogle; };
in
(haskellPackages-withHoogle.callPackage project-from-cabal {}).env.overrideAttrs (oldAttrs: rec {
buildInputs = oldAttrs.buildInputs ++ ([
# IDE packages
hie
pkgs.cabal-install
]);
NIX_GHC_DOCDIR =
let
# helper functions
reverse = builtins.sort (e1: e2: true);
all-but-last = l: reverse (builtins.tail (reverse l));
# first element is empty string after split, last element is "html" to remove
path = all-but-last (builtins.tail (pkgs.lib.strings.splitString "/" oldAttrs.NIX_GHC_DOCDIR));
correctedPath = builtins.map (s: if s == "ghc" then "hoogle" else s) path;
in
pkgs.lib.strings.concatMapStrings (s: "/${s}") correctedPath;
HIE_HOOGLE_DATABASE = NIX_GHC_DOCDIR + "/default.hoo";
})
I am really close to it working… but I get an error from VS Code HIE.
I ran this command in nix-shell to have more information about the error:
[nix-shell:~/projects/deep_space_fights]$ /nix/store/7xir5b0fvblbrpyyh9zwgl055jsn72g5-cabal-helper-0.9.0.0/bin/cabal-helper-wrapper "--with-ghc=ghc" "--with-ghc-pkg=ghc-pkg" "--with-cabal=cabal" "v1-style" "/home/arsleust/projects/deep_space_fights" "/home/arsleust/projects/deep_space_fights/dist-newstyle/build/x86_64-linux/ghc-8.6.5/deep-space-fights-0.1.0.0" "package-db-stack" "flags" "compiler-version" "ghc-merged-pkg-options" "config-flags" "non-default-config-flags" "ghc-src-options" "ghc-pkg-options" "ghc-lang-options" "ghc-options" "source-dirs" "entrypoints" "needs-build-output"
cabal-helper-wrapper: /home/arsleust/projects/deep_space_fights/dist-newstyle/build/x86_64-linux/ghc-8.6.5/deep-space-fights-0.1.0.0/setup-config: openFile: does not exist (No such file or directory)
Please don’t laugh at the project name, it’s just random haha
Seems that it’s linked to Not working with cabal-2.4.1.0 · Issue #1015 · haskell/haskell-ide-engine · GitHub
So the Nix part is fine, but it’s on the HIE side that something fails.
I’ll dig that later.