I encountered an issue where root ends up as the owner of my user’s home directory.
The problem arises with the following NixOS configuration, which uses agenix to manage some .env files containing secrets in a subfolder of my home directory:
{ config, pkgs, lib, ... }:
{
age.identityPaths = [ "/home/morten/.ssh/id_rsa" ];
environment.systemPackages = [ pkgs.ragenix ];
systemd.tmpfiles.rules = [
"d /home/morten/repos 0755 morten users -"
];
age.secrets = {
env-test = {
file = ./secrets/env-test.age;
owner = "morten";
group = "users";
path = "/home/morten/repos/.env-test";
};
};
}
When this configuration is applied during the first install, root becomes the owner of /home/morten and subdirectories like .local and .config.
However, if the same configuration is applied after the first install, there are no permission issues — the user correctly owns their home directory.