How to (partially) compensate for the lack of static typing / type annotations?

This is what the module system does. It’s used for all kinds of things, including NixOS and Home Manager configurations. There are trade-offs, such as evaluation performance or relative verbosity compared to language-level type annotations.

Here’s the documentation team’s tutorial on writing modules: https://nix.dev/tutorials/module-system/module-system

Other than that, you’d have to substantially change the Nix language, which is unlikely to happen soon, or use a different language to interface with the store, which will get a lot easier with C bindings.

1 Like