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

Getting a handle on the current state is hard #767

Closed
angerman opened this issue Dec 5, 2020 · 8 comments
Closed

Getting a handle on the current state is hard #767

angerman opened this issue Dec 5, 2020 · 8 comments
Labels
documentation Art of how not to explain.

Comments

@angerman
Copy link

angerman commented Dec 5, 2020

Trying to understand where Hnix is compared to nix. The readme suggests hnix can't evaluate nixpkgs, but it's not very clear what exactly the open issues/complications are.

If I wanted to replace nix with hnix today, what issues would need to be solved?

@sorki
Copy link
Member

sorki commented Dec 5, 2020

#554 gets us pretty close - with that PR Hnix produces output paths on par with Nix. That one was blocked by hnix-store which was released just a week ago.

Then there's a complicated one which is path filtering (#755 + haskell-nix/hnix-store#72) as it makes our transfomer stacks explode a bit.

That said everything is gonna be slow and we might uncover tons of other issues (Hnix/Nix inconsistencies) when we actually start using Hnix at its full potential.

If you don't need evaluation / building then Hnix is pretty viable and stable solution already and there are few projects that use it as library e.g.

@angerman
Copy link
Author

angerman commented Dec 5, 2020

@sorki thanks! https://github.com/input-output-hk/haskell.nix uses hnix as well in https://github.com/input-output-hk/nix-tools, to construct nix expressions. Has been very solid for us. I'm just curious if/when we can take it a step further :-)

My primary motivation for looking at hnix would be nix being too slow. And really bad at evaluation, especially around IFDs. I'd like to improve this, but I'd rather not work with C++ if I can help it.

/cc @Ericson2314 -- because you didn't know either :p

@layus
Copy link
Collaborator

layus commented Dec 7, 2020

Hi @angerman,

To elaborate on @sorki answer, here is the graps I got while playing with HNix.

At the moment, it is good at parsing nix code. As the parser is feature rich, it can help finding location of expressions, and potentially debug code (but no interface like that exists AFAIK). @sorki has a very good project highlighting what can be done with HNix: https://github.com/sorki/update-nix-file.

With #554 you get an extra step because you can now evaluate derivations, and get a proper .drv in the nix store. I manged to evaluate nixpkgs.firefox for example. As it is easy to compare the output of nix and hnix, It helped discover a lot of small discrepancies between nix and hnix (#757, #756).

To discover what is missing, you should have a look at Builtins.hs to find missing builtins, and the ones that defer to nix through a system call (as was the case with derivationStrict).

Some of them are "simple" but no-one knows exactly how to implement them without a bit a thinking, nor cared to do so (storePath, unsafeDiscardOutputDependency). Some are more involved, and not that widely used (fromTOML).

Two bigger parts remain.

  1. Implement all the fetchers (fetchurl, fetchGit, fetchMercurial). fetchurl is the only one that works because it calls nix behind the scene.

  2. Implement path and filterPath whose implementation requires to serialize to a network socket the content of the file system filtered by evaluating a nix function. Not triavial, but also not that much needed in nixpkgs. Much more in local dev setups I guess.

HNix is not capable of instantiating derivations by itself. I do not think that the project intends to redefine execution, sandboxing, permissions and daemons like nix does.

@bqv
Copy link

bqv commented Dec 29, 2020

Having gone through OP's thought process too recently, I agree. Hopefully this issue helps that

@bqv
Copy link

bqv commented Jan 2, 2021

So I'd like to suggest that first of all, this issue be pinned, but second, I feel much of the confusion about current state stems from the fact that there is a genuinely insane number of issues (the former is to slightly mitigate the latter)

@Anton-Latukha
Copy link
Collaborator

Anton-Latukha commented Jan 13, 2021

@angerman regarding #767 (comment)

And really bad at evaluation, especially around IFDs.

Canonical Nix is unperfect ad-hock dynamically type-checked, that is from where the terrible Nix lang code debugging comes from.

In HNix - the parsing, testing, debugging, the code evaluation are the project strongpoints that are forming.

Due to Haskell & Nix languages share the paradigms. Due to Haskell strong type system & HNix nix lang type system implementation. The project would have superior parsing, debugging, and evaluation capabilities. Code is already pretty lean in terms of size and conciseness. And after refactoring due to paradigm alignment the code should become leaner. When everything in the Nix type system would be Ok - HNix should be able to even compile the Nix code.

So, happy to receive improvements.

The speed question is addressed in the #781 (comment) and further.

@Anton-Latukha
Copy link
Collaborator

Anton-Latukha commented Jan 13, 2021

And currently, it is not strange that the project status is somewhat hard to grasp.
HNix embodies a lot of functionality fields: store storage & operations, functional programming language, parsing, evaluation, some code for import/export, linting, reduction, normalization, interpreter execution, and the verbose excessive API to all that.
No wonder getting the status is hard. The project has a different status at different parts, and after 2 years of working with the project, I still keep learning understanding new things and new angles to it.

Anton-Latukha added a commit that referenced this issue Jan 13, 2021
"Project status" currently formed by the composition on the theme from #767 (comment) & #767 (comment)
@Anton-Latukha
Copy link
Collaborator

Anton-Latukha commented Jan 13, 2021

To address the headpost topic "Getting a handle on the current state is hard":

In the future, the design notes and project status should be in one article, so we can go and change/update everything in one place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Art of how not to explain.
Projects
None yet
Development

No branches or pull requests

5 participants