What can a .nix file export?

I’m learning the nix, now reading this:
https://nixos.org/guides/nix-pills/functions-and-imports.html#idm140737320464880

The example is too simple to use in real project.
Does a .nix file only export the value of last express if there are tons off express?
Can it export many functions and variables?
Suppose I want to define add/sub/mul/div function and PI const in math.nix, how to export them all?

If you import a nix file, it will return the result of the expression.

There is only ever a single expression in a file, not more, not less.

If you want to return many things, you use a list or a set, depending on your actual needs.

1 Like

Awesome. I would like to regard it as only one top-level expression.