Change:
On a fresh install, lightdm is writing several files to / These should probably be either in /root or in some other runtime .cache and .gtkrc-2.0 Steps to reproduce the behavior: NixOS with X enabled, using the default lightdm display manager. soon as the display manager starts, files are written to / That my / will stay clean. If I stop display-manager.service, delete the files, then restart it, the files return. Looking in my /etc/passwd, shows that lightdm does have a home directory set at /var/lib/lightdm. But for some reason these files are not being written there as they should be. Please run and paste the result.
I just realized after I posted this that I used an old iso from 21.11 to install. So I reinstalled with 22.05, and this still happens
Are you using KDE Plasma? Can you reproduce the issue with SDDM?
I am using KDE. The issue also happens with SDDM. I went ahead and tested GDM as well (while still using plasma,) and it does not happen.
I can reproduce. For my case, in I saw one single file with prefix, after some search it is likely cache for kbuildsycoca5 (). I have no idea what that package does so far though.
All the files in my / are exactly the files being generated in
I can reproduce this with Plasma 5/SDDM on nixpkgs-unstable.
I also observed these files, tracked down the problem and prepared a pull-request that -- hopefully -- fixes the issue: . I came to the conclusion that it is best to entirely remove the code that creates those file. However, I feel a bit unconfident about my solution, so it would be good to have it tested by more users. If you can spare the time, please have a look at my draft pull request, maybe try my solution, and feel free to report back or even drop a review. Thanks a lot!

Discussion:
libsForQt5 = pkgs.plasma5Packages; inherit (libsForQt5) kdeGear kdeFrameworks plasma5; <del> inherit (pkgs) writeText; </del> inherit (lib) getBin optionalString literalExpression mkRemovedOptionModule mkRenamedOptionModule mkDefault mkIf mkMerge mkOption types; <del> ini = pkgs.formats.ini { }; gtkrc2 = writeText "gtkrc-2.0" '' # Default GTK+ 2 config for NixOS Plasma 5 include "/run/current-system/sw/share/themes/Breeze/gtk-2.0/gtkrc" style "user-font" { font_name="Sans Serif Regular" } widget_class "*" style "user-font" gtk-font-name="Sans Serif Regular 10" gtk-theme-name="Breeze" gtk-icon-theme-name="breeze" gtk-fallback-icon-theme="hicolor" gtk-cursor-theme-name="breeze_cursors" gtk-toolbar-style=GTK_TOOLBAR_ICONS gtk-menu-images=1 gtk-button-images=1 ''; gtk3_settings = ini.generate "settings.ini" { Settings = { gtk-font-name = "Sans Serif Regular 10"; gtk-theme-name = "Breeze"; gtk-icon-theme-name = "breeze"; gtk-fallback-icon-theme = "hicolor"; gtk-cursor-theme-name = "breeze_cursors"; gtk-toolbar-style = "GTK_TOOLBAR_ICONS"; gtk-menu-images = 1; gtk-button-images = 1; }; }; kcminputrc = ini.generate "kcminputrc" { Mouse = { cursorTheme = "breeze_cursors"; cursorSize = 0; }; }; </del> activationScript = '' ${set_XDG_CONFIG_HOME}

XDG_CONFIG_HOME=''${XDG_CONFIG_HOME:-$HOME/.config} ''; <del> startplasma = '' ${set_XDG_CONFIG_HOME} mkdir -p "''${XDG_CONFIG_HOME}" '' + optionalString config.hardware.pulseaudio.enable '' # Load PulseAudio module for routing support. # See also: http://colin.guthr.ie/2009/10/so-how-does-the-kde-pulseaudio-support-work-anyway/ ${getBin config.hardware.pulseaudio.package}/bin/pactl load-module module-device-manager "do_routing=1" '' + '' ${activationScript} # Create default configurations if Plasma has never been started. kdeglobals="''${XDG_CONFIG_HOME}/kdeglobals" if ! [ -f "$kdeglobals" ]; then kcminputrc="''${XDG_CONFIG_HOME}/kcminputrc" if ! [ -f "$kcminputrc" ]; then cat ${kcminputrc} >"$kcminputrc" fi gtkrc2="$HOME/.gtkrc-2.0" if ! [ -f "$gtkrc2" ]; then cat ${gtkrc2} >"$gtkrc2" fi gtk3_settings="''${XDG_CONFIG_HOME}/gtk-3.0/settings.ini" if ! [ -f "$gtk3_settings" ]; then mkdir -p "$(dirname "$gtk3_settings")" cat ${gtk3_settings} >"$gtk3_settings" fi fi ''; </del> in {

# Update the start menu for each user that is currently logged in system.userActivationScripts.plasmaSetup = activationScript; <del> services.xserver.displayManager.setupCommands = startplasma; </del> nixpkgs.config.firefox.enablePlasmaBrowserIntegration = true; })