Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Nix-the-language imports are dead simple: https://nixos.org/guides/nix-pills/05-functions-and-imports#... - `builtins.import ./foo.nix` makes it like we had `./foo.nix` copied and pasted in place of it. If we want to pass something, we make contents of `./foo.nix` a function (thus the frequently seen `import ./foo.nix {}` or `import ./foo.nix { inherit bar; }`).

It’s the nixpkgs’ module convention system that is a little bit less straightforward as it relies on some conventions: https://nixos.wiki/wiki/NixOS_modules#Module_Imports_vs_buil...

Oh, and Flakes have inputs (which are closer to built-in module system, as IIRC Flake support is baked into Nix itself rather than being a part of Nixpkgs like the module system), which is another different convention, but it all boils down to using `builtins.import` somewhere deep down the chain, all extra semantics in the libraries.

Again, I would've preferred a language with module system built-in but it's not a bad design either - it's just minimalistic. IMHO, Ruby and Perl can be more confusing than this - and they're still sane (if we don't intentionally start having fun with their metaprogramming capabilities). But then Flakes probably wouldn't be a thing, so minimal core has its advantages too. Or disadvantages, as it all depends on the viewer.

Either way, it’s all well documented. I still forget how it works now and then, but that’s my memory/attention span problem rather than a Nix/Nixpkgs issue.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: