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

isDragonfly instead of isDragonFly causes vty-crossplatform to fail to build #2312

Open
thomasjm opened this issue Jan 31, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@thomasjm
Copy link
Contributor

Describe the bug

I'm trying to cross-compile an application to Windows. The application depends on vty-crossplatform, which has some interesting conditionals in its cabal file:

https://github.com/jtdaugherty/vty-crossplatform/blob/9ed037f0420460c04ecd3e1f07fa5ad9e7ed5eec/vty-crossplatform.cabal#L33-L44

As you can see, it includes a cabal conditional test of os(dragonfly).

Now, look at the code generated in hackage.nix for this package:

https://github.com/input-output-hk/hackage.nix/blob/5adaa9f1550f8cf5b6ae2c9183dd5ac197f5620c/hackage/vty-crossplatform-0.4.0.0-r0-50593f91ad16777d921138475a8d2784d538fd206addd30664c620278d6c8544.nix#L38

As you can see, the generated Nix in hackage.nix has mapped this to a test of system.isDragonfly.

This fails for me, and I get an error like this:

error: attribute 'isDragonfly' missing 
...
Did you mean isDragonFly?

Additional context

This error is difficult to trigger, since if you're building on Linux or macOS you short-circuit before hitting this test. It only came up when trying to cross-compile.

I couldn't figure out where these system.* properties are defined. But it appears that the code that generates hackage.nix is following a simple procedure where it capitalizes the word and adds "is," so os(windows) -> system.isWindows and so on.

@thomasjm thomasjm added the bug Something isn't working label Jan 31, 2025
@thomasjm
Copy link
Contributor Author

I forked vty-crossplatform to remove the problematic line from the cabal file. Then I promptly ran into another one, related to the os(hpux) test:

error: attribute 'isHpux' missing

@angerman
Copy link
Collaborator

angerman commented Feb 6, 2025

The test for os(hpux)? Hmm... I wonder how to fix this, someone could put in arbitrary strings os(bluebeard) or something...

@thomasjm
Copy link
Contributor Author

thomasjm commented Feb 6, 2025

I would suggest

  1. Special case certain values so os(dragonfly) -> system.isDragonFly
  2. Make a list of attrs that are known to exist on the system in the Nix code, and for those keep the current behavior (modulo the name remapping in 1.). For unrecognized attrs, emit a Nix check that's more conservative, like
(hasAttr "isBluebeard" system && system.isBluebeard)

or even emit a warning:

(if hasAttr "isBluebeard" system then system.isBluebeard else builtins.trace "Warning: system.isBluebeard from os() condition was not defined" false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants