Search code examples
packagenixhome-directorynixos

building custom packages in a user's home directory


I've noticed that any attempt to build custom packages in a user's home directory fails, due to the home directory permissions:

drwx------

coupled with the fact that nix-rebuild switch uses the nixbld{n} user.

Is there any way of getting around that? Can custom packages (user config files, for example) be built in a user's home directory, or is does this go against the underlying principles of NixOS?


Solution

  • Can custom packages (user config files, for example) be built in a user's home directory, or is does this go against the underlying principles of NixOS?

    No, you cannot build in a user's home directory because it goes against Nix's design. Nix performs the actual build in /tmp running as a nixbld{n} user and stores the output in /nix/store.

    In general, NixOS doesn't provide a mechanism for dealing with user configurations. However there are exceptions, such as adding SSH authentication keys.