Nix Friday - NixOS Modules

Been trying to get my head around what you are explaining in the Nix Friday video on Nixos Modules

Starting at 18:12 - 28:00 you mention nixos-config= as “black magic” by having the config on a remote host. Like the person who was in your channel I am using the “copy configuration.nix to host” but your way opens a ton more options.
Could you perphaps explain it once again in more detail here?

1 Like

Oh wow, people are watching my videos, how embarrassing :sweat_smile:

If I remember correctly this was a bit of a joke.

When NIX_PATH has a value that points to a URL, Nix will fetch that URL as a Tarball and extract it into the /nix/store. You can try this out like this:

$ NIX_PATH=nixpkgs= nix-instantiate --eval --expr "<nixpkgs>"

And since nixos-rebuild uses <nixos-config> in the code, it would be possible to use something like nixos-rebuild -I nixos-config= switch (where -I extends the NIX_PATH).

But that’s the theory. Because the tarball returns a folder, it means that the configuration must be located in the repo top-level and named “default.nix”. So I don’t know how practical that is.