Open jonringer opened 2 years ago
I have another one. Let attribute-sets let {}
. Not sure if it needs to be covered though, as I think it's just the the syntatic desugaring of rec
blocks, although a bit more explicit.
Let attribute-sets
I'm not even familiar with this. But as an interesting aside, let blocks are implemented as a rec
attr set.
I only found about them recently after getting to know the Nix tree-sitter grammar a bit. So for let {}
, lets label the attribute-set x. It must contain a body
key which is an arbitrary expression where all the other attributes defined in x are in scope. It is essentially another syntax for let
in
. And if body
is an attribute-set itself, can be used as an alternative to rec
. So:
let {
x = 1;
y = 2;
body = x + y;
}
evals to 3
.
seems pretty advanced, in rust-lang book terms, I think that would be something which would go into the rust-nomicon instead "intro to nix" book :/
Was thinking of moving back the build a package
section and instead putting a how to use nixpkgs
section. Then cover, the most common scenarios: using a flake, using nix develop
, nix build
, nix eval
Just need to write these down before I forget: