I don’t know if this is best practice, but this is what I do:
let nixPath = "/etc/nixPath";
in
{
systemd.tmpfiles.rules = [
"L+ ${nixPath} - - - - ${pkgs.path}"
];
nix = {
nixPath = [ "nixpkgs=${nixPath}" ];
};
}
Instead of using /etc/nixPath
, you could of course also just set the NIX_PATH environment variable, but that would require closing terminals in order to pick up the new value, so the on-disk version is more flexible.
EDIT: just to clarify, doing this means that all your regular nix-*
tools work as expected with flakes.