···2727 # Allow the nixos-upgrade service (runs as root) to read the flake repo
2828 # owned by the regular user. Without this, git 2.35.2+ refuses to open
2929 # repos not owned by the calling user (CVE-2022-24765 mitigation).
3030+ # Use --file to target root's gitconfig explicitly — activation scripts
3131+ # run without $HOME set, which git --global requires.
3032 system.activationScripts.nixosUpgradeGitSafeDir = ''
3131- ${pkgs.git}/bin/git config --global --add safe.directory /home/${cfg.user.username}/.config/nix-config
3333+ ${pkgs.git}/bin/git config --file /root/.gitconfig --add safe.directory /home/${cfg.user.username}/.config/nix-config
3234 '';
33353436 # Symlink tracked hooks into .git/hooks so they're always up to date.