Nix Friday - NixOS Modules

@zimbatm
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=https://github.com/NixOS/nixpkgs/archive/master.tar.gz nix-instantiate --eval --expr "<nixpkgs>"
/nix/store/n3rzaw8mkgqz5d1d1kf20fvxgbam2mck-source

And since nixos-rebuild uses <nixos-config> in the code, it would be possible to use something like nixos-rebuild -I nixos-config=https://github.com/myuser/myconfig/archive/master.tar.gz 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.

4 Likes