Skip to content
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

haskell developPackage error: creating directory '/nix/var #45775

Closed
teto opened this issue Aug 30, 2018 · 11 comments
Closed

haskell developPackage error: creating directory '/nix/var #45775

teto opened this issue Aug 30, 2018 · 11 comments
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: haskell

Comments

@teto
Copy link
Member

teto commented Aug 30, 2018

Issue description

I try using haskell's developPackage but the

{ pkgs ? import <nixpkgs> {} }: 

  devPkg = pkgs.haskellPackages.developPackage {
  root = ./hs;
};
in 
  devPkg

that I run from a folder that contains hs/hs.cabal and the haskell source code. Then I run nix-shell

$ nix-shell shell-develop.nix                                                                                                                                                                                                                          
building '/nix/store/h5vyjlmllyvcqsbq89gs06i09j1l9gm1-cabal2nix-hs.drv'...
installing
error: creating directory '/nix/var': Permission denied
error: creating directory '/nix/var': Permission denied
** need a revision for VCS when the hash is given. skipping.
** need a revision for VCS when the hash is given. skipping.
** need a revision for VCS when the hash is given. skipping.
** need a revision for VCS when the hash is given. skipping.
cabal2nix: user error (Failed to fetch source. Does this source exist? Source {sourceUrl = "/nix/store/fgiafw1caz7bnqwy7lrp6rg076z5n19s-hs", sourceRevision = "", sourceHash = Guess "", sourceCabalDir = ""})
note: keeping build directory '/tmp/nix-build-cabal2nix-hs.drv-7'
builder for '/nix/store/h5vyjlmllyvcqsbq89gs06i09j1l9gm1-cabal2nix-hs.drv' failed with exit code 1
error: while evaluating anonymous function at /home/teto/mptcpnetlink/shell-develop.nix:5:1, called from undefined position:
while evaluating 'developPackage' at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:207:7, called from /home/teto/mptcpnetlink/shell-develop.nix:10:12:
while evaluating anonymous function at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:210:20, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:218:34:
while evaluating 'callCabal2nix' at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:180:32, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:213:9:
while evaluating 'overrideCabal' at /home/teto/nixpkgs/pkgs/development/haskell-modules/lib.nix:37:24, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:190:8:
while evaluating 'callPackageKeepDeriver' at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:156:33, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:190:23:
while evaluating 'overrideCabal' at /home/teto/nixpkgs/pkgs/development/haskell-modules/lib.nix:37:24, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:157:5:
while evaluating 'callPackage' at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:115:22, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:157:20:
while evaluating 'callPackageWithScope' at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:75:37, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:115:28:
while evaluating 'makeOverridable' at /home/teto/nixpkgs/lib/customisation.nix:67:24, called from /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:98:8:
while evaluating 'drvScope' at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:88:18, called from /home/teto/nixpkgs/lib/customisation.nix:69:12:
build of '/nix/store/h5vyjlmllyvcqsbq89gs06i09j1l9gm1-cabal2nix-hs.drv' failed

and the error is not that clear, why would it try to create /nix/var ?
the hs.cabal file contains:

name: netlink-pm
version: 1.0.0
license: GPL-3
license-file: LICENSE
cabal-version: >= 1.18
build-type: Simple

executable project1
    build-depends: base < 5, netlink
    main-is: daemon.hs
    default-language: Haskell2010

Steps to reproduce

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.14.24, NixOS, 18.09.git.31145cb (Jellyfish)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.0.4
  • nixpkgs: /home/teto/nixpkgs
@mpickering
Copy link
Contributor

I can't reproduce this.

@teto
Copy link
Member Author

teto commented Aug 31, 2018

@mpickering thanks for trying.
I tried on upstream nixos-unstable with the same result. My haskell overlay just consists in zeromq4-haskell = prev.haskell.lib.dontCheck hprev.zeromq4-haskell;so I doubt it's responsible for the error.
You might be able to reproduce by cloning https://github.com/teto/netlink_pm and running nix-shell shell-develop.nix in the root folder. This repository is a huge mess as I try to convert a python script in haskell and learning about the haskell/nix quirks.

@srhb
Copy link
Contributor

srhb commented Aug 31, 2018

I can reproduce this with

{ pkgs ? import <nixpkgs> {} }:

pkgs.haskellPackages.developPackage {
  root = ./emptydir; # this directory does not contain an emptydir.cabal
}

Note that your hs.cabal is a symlink to a file in /home/teto.

@teto
Copy link
Member Author

teto commented Aug 31, 2018

thanks !
hs.cabal is a symlink towards /home/teto/mptcpnetlink/hs/netlink-pm.cabal, ie, the netlink-pm.cabal in the same folder (https://github.com/teto/netlink_pm/blob/new/hs/netlink-pm.cabal). Depending on the tool (I don't remember if it's cabal/stack or another one), the name of the .cabal file must adopt different conventions. Either way, I am not sure why developPackage has this constraint. Wouldn't it be possible to search for a *.cabal and warn if there are several.

The symlink is valid

$ head /home/teto/mptcpnetlink/hs/hs.cabal                                                                                                                                                                                                       
name: netlink-pm
version: 1.0.0
license: GPL-3
license-file: LICENSE
cabal-version: >= 1.18
build-type: Simple

executable project1
    build-depends: base < 5, netlink
    main-is: daemon.hs

but it's cool you could reproduce it with an empty dir.

@srhb
Copy link
Contributor

srhb commented Aug 31, 2018

The symlink is valid

But it's not dereferenced during import to the store.

{ pkgs ? import <nixpkgs> {} }:

pkgs.stdenv.mkDerivation {
  name = "test";
  version = "1";
  src = ./.;
  phases = [ "installPhase" ];
  installPhase = ''
    ls -l $src/symlink
    cp $src/symlink $out; # symlink points to a file outside ./
  '';
}

results in

these derivations will be built:
  /nix/store/1gwl1220gfd5i4b7vzdwwyvqsrzllarr-test.drv
building '/nix/store/1gwl1220gfd5i4b7vzdwwyvqsrzllarr-test.drv'...
installing
lrwxrwxrwx 7 nobody nogroup 26 Jan  1  1970 /nix/store/64ycv3s7a5qhick3bhknnlm18q13q92x-emptydir/symlink -> /home/sarah/scratch/target
cp: cannot stat '/nix/store/64ycv3s7a5qhick3bhknnlm18q13q92x-emptydir/symlink': No such file or directory

Or, without the sandbox but still using normal nixbld isolation

these derivations will be built:
  /nix/store/1gwl1220gfd5i4b7vzdwwyvqsrzllarr-test.drv
building '/nix/store/1gwl1220gfd5i4b7vzdwwyvqsrzllarr-test.drv'...
installing
lrwxrwxrwx 7 root root 26 Jan  1  1970 /nix/store/64ycv3s7a5qhick3bhknnlm18q13q92x-emptydir/symlink -> /home/sarah/scratch/target
cp: cannot stat '/nix/store/64ycv3s7a5qhick3bhknnlm18q13q92x-emptydir/symlink': Permission denied

@teto
Copy link
Member Author

teto commented Aug 31, 2018

right, thanks for investigating this. I hadn't thought about it because hs.cabal was originally a real file and I had (a different) problems. I replaced it iwth a hardlink and it seems fine (hell there are other haskell errors but I've gotten used to override everything).
This gave me a hunch I was at fault user error (Failed to fetch source. Does this source exist? Source {sourceUrl = "/nix/store/fgiafw1caz7bnqwy7lrp6rg076z5n19s-hs" but ... well I have no excuse :'(

@teto teto closed this as completed Aug 31, 2018
@srhb
Copy link
Contributor

srhb commented Aug 31, 2018

No problem! :) The error message isn't exactly very clear, and could be worth improving, if you want to file an issue! :)

@puffnfresh
Copy link
Contributor

I got this error for a different reason.

I had my Haskell package named differently (e.g. nix-batch) from the directory it was in (e.g. nix-batch-hs)

I read the code and realised it expects the directory to be named the same. In my case I just renamed the directory.

@domenkozar
Copy link
Member

domenkozar commented Aug 7, 2019

name ? builtins.baseNameOf root

Ugh, such code shouldn't exist :)

So what happens is:

  1. developPackage gets passed root = ./.
  2. name is determined by it's parent directory name (which will be different as it's user specific)
  3. cabal2nix can't find the cabal file so it falls back to git and other fetchers

@stale
Copy link

stale bot commented Jun 2, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 2, 2020
@cdepillabout
Copy link
Member

Since this issue was opened, it appears that developPackage and cabal2nix have been fixed:

  • developPackage now uses "" as the name of the resulting derivation when passes a path (like ./.).
  • cabal2nix / callCabal2nix tries to find the .cabal file for the passed-in package even if it doesn't match the name it was given.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: haskell
Projects
None yet
Development

No branches or pull requests

6 participants