input-output-hk / haskell.nix

Alternative Haskell Infrastructure for Nixpkgs
https://input-output-hk.github.io/haskell.nix
Apache License 2.0
556 stars 240 forks source link

string cannot refer to other paths #1412

Closed fxttr closed 2 years ago

fxttr commented 2 years ago

Hi,

I have a problem with creating a nix-shell.

I followed the manual and successfully created a default.nix. I can build my project with nix-build -A project.components.exes.project-exe I use a stack based project with enabled nix-integration. But when I try to create a development environment via shell.nix I am getting the error error: string '/nix/store/6qxhfiwjkmga9lmjrz9n43v6lcxgd6pc-hoogle-5.0.18.3-src' cannot refer to other paths, at /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/lib/clean-source-with.nix:109:52 because I enabled "withHoogle". The same happends with any tool I try to install via tools. I am rather new to nix and can't really figure out what the error is.

Informations: OS: NixOS 21.11 Buildsystem: Stack

default.nix:

let
  sources = import ./nix/sources.nix {};
  haskellNix = import sources.haskellNix {};
  pkgs = import
    haskellNix.sources.nixpkgs-unstable
    haskellNix.nixpkgsArgs;

in pkgs.haskell-nix.stackProject {
  name = "stream";

  src = pkgs.haskell-nix.haskellLib.cleanGit {
    name = "stream";
    src = ./.;
  };
}

shell.nix:

let
  project = import ./default.nix;
in
  project.shellFor {
    withHoogle = true;

    tools = {
      cabal = "latest";
      stack = "latest";
      ormolu = "latest";
      hlint = "latest";
      haskell-language-server = "latest";
    };

    buildInputs = [ (import <nixpkgs> {}).git ];

    exactDeps = true;
  }

stack.yaml:

resolver: lts-18.18

nix:
  enable: true
  shell-file: shell.nix

packages:
- .

Thanks for your help!

ocharles commented 2 years ago

Try using the Haskell.nix commit b944c8087d9931d920b7d2c50ba1c875c40c94ee

fxttr commented 2 years ago

Hi, thanks for your reply. Could you give me a hint how to use it? Do I need to pin it somewhere? In source.nix?

ocharles commented 2 years ago

How did you make sources.nix? Is that with niv?

fxttr commented 2 years ago

Yes I used niv like described in the manual.

ocharles commented 2 years ago

Ok, have a look at niv --help - there should be a way to specify a particular commit when you niv add Haskell.nix

fxttr commented 2 years ago

Sadly that didn't solved it.

I will append the trace here :

error: while evaluating the attribute 'NIX_GHC_LIBDIR' of the derivation 'ghc-shell-for-stream' at /nix/store/bn14fy2mc2p1q44681il8idfv5fr5x3z-source/pkgs/stdenv/generic/make-derivation.nix:205:7:
while evaluating the attribute 'buildCommand' of the derivation 'ghc-shell-for-stream-ghc-8.10.7-env' at /nix/store/bn14fy2mc2p1q44681il8idfv5fr5x3z-source/pkgs/stdenv/generic/make-derivation.nix:205:7:
while evaluating 'optionalString' at /nix/store/bn14fy2mc2p1q44681il8idfv5fr5x3z-source/lib/strings.nix:202:5, called from /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/builder/shell-for.nix:111:19:
while evaluating the attribute 'buildCommand' of the derivation 'hoogle-with-packages' at /nix/store/bn14fy2mc2p1q44681il8idfv5fr5x3z-source/pkgs/stdenv/generic/make-derivation.nix:205:7:
while evaluating the attribute 'hoogle' at /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/builder/default.nix:59:16:
while evaluating 'tool' at /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/overlays/tools.nix:71:35, called from /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/builder/default.nix:48:32:
while evaluating 'hackage-tool' at /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/overlays/tools.nix:60:18, called from /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/overlays/tools.nix:76:7:
while evaluating 'hackage-package' at /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/overlays/haskell.nix:449:11, called from /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/overlays/tools.nix:64:8:
while evaluating 'getPackage' at /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/overlays/haskell.nix:663:26, called from /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/overlays/haskell.nix:451:14:
while evaluating the attribute 'pkg-set' at /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/overlays/haskell.nix:522:26:
while evaluating anonymous function at /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/lib/import-and-filter-project.nix:5:1, called from /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/overlays/haskell.nix:495:27:
while evaluating the attribute 'buildCommand' of the derivation 'hoogle-plan-to-nix-pkgs' at /nix/store/bn14fy2mc2p1q44681il8idfv5fr5x3z-source/pkgs/stdenv/generic/make-derivation.nix:205:7:
string '/nix/store/6qxhfiwjkmga9lmjrz9n43v6lcxgd6pc-hoogle-5.0.18.3-src' cannot refer to other paths, at /nix/store/471hzbkjgpy80rc5l8gzvv6wscb4ajw8-haskellNix-src/lib/clean-source-with.nix:109:52
hamishmack commented 2 years ago

What version of nix are you on?

nix --version

fxttr commented 2 years ago

nix (Nix) 2.3.16

ocharles commented 2 years ago

Are you certain you're on b944c8087d9931d920b7d2c50ba1c875c40c94ee? Can you share your new sources.nix file?

hamishmack commented 2 years ago

I think upgrading to 2.4 will fix this or pinning Haskell.nix to b944c8087d9931d920b7d2c50ba1c875c40c94ee. I'm not sure of the correct way to do that, but what I usually do is to edit nix/sources.json and replace the commit hash in there, then change the sha256 (the hash nix uses) to something invalid (change some of the characters in the hash to 0 or something). The first time you build there will be an error telling you the correct sha256 to use. There may be a niv command to do this, but I am not sure what it is.

fxttr commented 2 years ago

Thanks, that did the trick. I tried niv modify haskellNix -r b944c8087d9931d920b7d2c50ba1c875c40c94ee but it only modifies the rev attribute in sources.json. After modifing url and sha256 by hand it worked.

Thanks for your help, except some failing dependency resolving in cabal nix-shell works now.

fxttr commented 2 years ago

Closed because my Problem is solved.