Open ckp95 opened 9 months ago
Hey @ckp95, apologies for the late response!
The NIX_PATH
(here configured by nix.nixPath
) is where nix will look when you have a angle bracket lookup.
For example, nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos
will tell nix to use a channel named nixos
owned by root
when looking up <nixpkgs>
. While /nix/var/nix/profiles/per-user/root/channels
will tell nix to look for a channel with the same name for any other angle bracket it finds (e.g. <foo>
will be looked up in /nix/var/nix/profiles/per-user/root/channels/foo
).
When using flakes, you usually want to move away from channels, as they're effectively replaced with flake inputs.
The nix path angle bracket look up is still useful, though, as sometimes you want to evaluate non-flake nix files, which will still use the angle bracket syntax to lookup stuff (mostly nixpkgs
).
In this template, we point NIX_PATH
to /etc/nix/path
, and create a /etc/nix/path/foobar
for each flake input you have (e.g. /etc/nix/path/nixpkgs
). Yep, this directory is created if it doesn't exist already.
This lets you use the exact inputs you have locked in your flake with the "legacy" angle brackets (global nix path) syntax.
The nixos-config
nix path only matters to nixos-rebuild
, when it's called without a --flake
argument.
nixos-rebuild
looks it up to find where your config is (falling back to /etc/nixos/configuration.nix
).
When building your system with flakes, you will specify the path to your config with --flake
, so the nixos-config
nix path does not matter at all.
In practice, the only angled bracket lookup that's actually useful outside of your config is <nixpkgs>
, so we plan on simplifying this on the template to make things clearer.
you can symlink your config folder to /etc/nixos
I have not moved to flakes yet. Right now I keep my
configuration.nix
andhardware.nix
under my home directory at~/me/src/dotfiles
. In myconfiguration.nix
, I have set mynixPath
as:so when I run
sudo nixos-rebuild switch
it uses the config there rather than looking in/etc/nixos
. (I don't know what the channels-related ones are actually doing, I just kept them there from the original config)I want to keep this directory layout in a flake-based config. I notice in the template, this section:
What is this
/etc/nix/path
doing? I don't currently have such a directory. Will it be created automatically? And do I need to add my dotfiles directory to this list?