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

Support __toString as a special attr set member #198

Open
jwiegley opened this issue Apr 26, 2018 · 2 comments
Open

Support __toString as a special attr set member #198

jwiegley opened this issue Apr 26, 2018 · 2 comments

Comments

@jwiegley
Copy link
Member

If an attr set contains a member __toString, it will be called whenever the attr set is coerced to a string, received the same attr set as its argument. The result is then coerced to a string.

See https://github.com/NixOS/nix/blob/master/src/libexpr/eval.cc#L1538

@jwiegley
Copy link
Member Author

I've added support in Exec.hs, but for now it only applies when coercing for derivation. We need to use this coerceToString function in the same places that nix does.

@layus
Copy link
Collaborator

layus commented Jan 15, 2021

In particular, it needs to apply during conversion:

hnix/src/Nix/Convert.hs

Lines 158 to 160 in a3b95b2

NVSet' s _ -> case M.lookup "outPath" s of
Nothing -> pure Nothing
Just p -> fromValueMay p
But the convert instance does not allow to pass the callFunc utility. Any idea ? Delete the Convert NixString instance ?

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

No branches or pull requests

2 participants