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

callCabal2nix: detect invalid names and print a good error #119123

Closed
wants to merge 1 commit into from

Conversation

lf-
Copy link
Member

@lf- lf- commented Apr 11, 2021

Motivation for this change

A friend used an invalid haskell package name, which resulted in a very
bad error message from callCabal2nix, on account of them calling
cabal init from their project directory, bad_name, which generated a
bad-name.cabal file. They didn't notice and did something like
callCabal2nix "bad_name" ./. {}; in their overlay, generating an
atrocious error message on the file not existing:

building '/nix/store/00000000000000000000000000000000-cabal2nix-bad_name.drv'...
installing
cabal2nix: nix-prefetch-url: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
builder for '/nix/store/00000000000000000000000000000000-cabal2nix-bad_name.drv' failed with exit code 1
error: build of '/nix/store/00000000000000000000000000000000-cabal2nix-bad_name.drv' failed

We can and should detect this and throw an assertion explaining what
went wrong on our side.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

A friend used an invalid haskell package name, which resulted in a very
bad error message from callCabal2nix, on account of them calling
`cabal init` from their project directory, `bad_name`, which generated a
`bad-name.cabal` file. They didn't notice and did something like
`callCabal2nix "bad_name" ./. {};` in their overlay, generating an
*atrocious* error message on the file not existing:

```
building '/nix/store/00000000000000000000000000000000-cabal2nix-bad_name.drv'...
installing
cabal2nix: nix-prefetch-url: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
builder for '/nix/store/00000000000000000000000000000000-cabal2nix-bad_name.drv' failed with exit code 1
error: build of '/nix/store/00000000000000000000000000000000-cabal2nix-bad_name.drv' failed
```

We can and should detect this and throw an assertion explaining what
went wrong on our side.
@lf-
Copy link
Member Author

lf- commented Apr 11, 2021

Related, NixOS/cabal2nix#472

But we should stop this happening at all because it could probably allow further frustrating to debug breakages if we allow bad names.

@sternenseemann
Copy link
Member

I'd prefer to resolve this in cabal2nix itself, honestly.

@sternenseemann
Copy link
Member

Fixed by NixOS/cabal2nix#489. Hoping to have a cabal2nix release with this fix soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants