Some settings don't work w/ `nixos-install`

I have this setting in my configuration:

users.users.crinklywrappr = {
  openssh.authorizedKeys.keyFiles = [ /home/crinklywrappr/.ssh/ ];

This works fine unless I’m re-installing the system from my thumbdrive. When I do that, nixos-install says the path doesn’t exist. That makes sense, b/c /home is mounted under /mnt. So the correct path during reinstallation is /mnt/home/crinklywrappr/.ssh/

[root@nixos:/home/nixos]# nixos-install 
copying channel...
building the configuration in /mnt/etc/nixos/configuration.nix...
error: opening file '/home/crinklywrappr/.ssh/': No such file or directory
(use '--show-trace' to show detailed location information)

I wonder if there is a way to specify the directory so it will work during normal rebuild w/ nixos-rebuild, and reinstallation w/ nixos-install?

1 Like

Seems to me the more basic problem is that your config isn’t self-contained. You’d have the same problem if you wanted to make your config a flake, too. It’s cleaner to put a copy of your together with your config and reference that.

I would still need to write the config to the filesystem, since some applications expect it to be there. Wouldn’t that exhibit the same problem with the path?

Perhaps I would benefit from a “best practice” example.

If it was stored together with the config, you could use a relative path, which would avoid the problem.

Duh. Now I feel dumb lol