Two similar-ish modules in specialisation config, but only one actually works as intended

Hi, so I’m sure this is an extremely obvious issue (but I can’t spot it for some reason), but I’m currently in the process of implementing a (NixOS, not home-manager) specialization for KDE alongside the one I already have for XFCE in my config (actual branch with the KDE stuff is here), which involves doing some weird nonsense to the desktop itself, which I’m doing through some modules, and there’s two of those (works and doesn’t work) and which do one operation in both of them but which only works in one of those modules.

The thing in common that they’re trying to do in particular is home-manager.users.user.home.file.".config/autostart/<name>.desktop".text, which is done here (works) and here (doesn’t work). The modules are imported in core/specialisations/kde_uid1000/arcane-hacks/default.nix, and are both preceded by instances of this:

  home-manager.users.user = { lib, config, pkgs, ... }: { <this is where the stuff actually goes> };

which I’m wondering if it’s causing issues because it’s defined in multiple modules (but it’s defined multiple times elsewhere and works there…), however I don’t quite think that’s the issue because it wasn’t working even when I (accidentally) built it with the dpi.nix module commented out but had firefox-gtk-no-round-corners.nix (the bad one) imported, so…

It was definitely being evaluated because it gave me a fuckton of syntax errors the first time I decided to attempt building it, however after fixing those (and before I realized the dpi module was commented out), it didn’t actually do much of any of what it was supposed to do (~/.config/autostart/patch-gtk-firefox-corners.desktop wasn’t/isn’t present), so it wasn’t an issue with it not being imported necessarily.

And… not sure what it is that I’m doing wrong? Is it trivial or do I need to rework this whole thing? Thanks in advance.

Update: changed the offending module to be imported straight from home-manager configuration, which didn’t make it work either.

So it builds properly, but nothing actually happens? Is home-manager failing to activate? Have you checked the logs of the home-manager-user.service unit?

Side note: home-manager can make desktop entries in a more structured way, if you want, with the xdg.desktopEntries options.

It builds “just fine”, but ~/.config/autostart/patch-gtk-firefox-corners.desktop doesn’t actually exist afterwards (yes I logged in and out and rebooted… because I’ve run into that before). home-manager-user.service complains, but not about this:

Jun 08 20:13:52 t480 hm-activate-user[11517]: Starting Home Manager activation
Jun 08 20:13:52 t480 hm-activate-user[11517]: Activating checkFilesChanged
Jun 08 20:13:52 t480 hm-activate-user[11517]: Activating checkLinkTargets
Jun 08 20:13:52 t480 hm-activate-user[11753]: Please do one of the following:
Jun 08 20:13:52 t480 hm-activate-user[11753]: - Move or remove the files below and try again.
Jun 08 20:13:52 t480 hm-activate-user[11753]: - In standalone mode, use 'home-manager switch -b backup' to back up
Jun 08 20:13:52 t480 hm-activate-user[11753]:   files automatically.
Jun 08 20:13:52 t480 hm-activate-user[11753]: - When used as a NixOS or nix-darwin module, set
Jun 08 20:13:52 t480 hm-activate-user[11753]:     'home-manager.backupFileExtension'
Jun 08 20:13:52 t480 hm-activate-user[11753]:   to, for example, 'backup' and rebuild.
Jun 08 20:13:52 t480 hm-activate-user[11753]: Existing file '/home/user/.config/fontconfig/conf.d/10-hm-fonts.conf.backup' would be clobbered by backing up '/home/user/.config/fontconfig/conf.d/10-hm-fonts.conf'

Removed those just in case, this time built “just fine” but still not actually in place.

Also was trying to debug this with a to-be-left-unnamed-because-I’m-not-proud-of-using-it LLM (which generally suck for Nix, I know and have been bitten by this many times, but… desperation), got suggested to create a 00-hello.desktop file just for testing purposes like this:

      ".config/autostart/00-hello.desktop" = {
       text = ''
          [Desktop Entry]
          Name=Hello Test
          Exec=/usr/bin/true
          Type=Application
        '';
      }; 

and it works (generates) just fine.

warning: Git tree '/home/user/.git_repos/nixos-config' is dirty
> Building NixOS configuration
warning: Git tree '/home/user/.git_repos/nixos-config' is dirty
these 8 derivations will be built:
  /nix/store/fzgajh583ydy01ci6n3kkp9g08plfias-hm_.configautostart00hello.desktop.drv
  /nix/store/rr3452rjq1zwr4zrxd8pkcyvij5w3iqi-home-manager-files.drv
  /nix/store/a7sphy967wlfqy2igan7byvgpvqpphhv-home-manager-generation.drv
  /nix/store/gjhw3bsaik4h7b2g7l1dl4a8w67avg44-unit-home-manager-user.service.drv
  /nix/store/4g0bk9nqs12ki118ksdl0nv8nisim1jk-system-units.drv
  /nix/store/d2zdvizcxbmfr2vvnili825bc9skhng1-etc.drv
  /nix/store/305ysr4098s6qm0y77xvn1cf70w61313-nixos-system-t480-25.11.20250607.3e3afe5.drv
  /nix/store/ykxyaybcifg9fn7ki5ccw8l31in4jr22-nixos-system-t480-25.11.20250607.3e3afe5.drv
hm_.configautostart00hello.desktop> building '/nix/store/fzgajh583ydy01ci6n3kkp9g08plfias-hm_.configautostart00hello.desktop.drv'
home-manager-files> building '/nix/store/rr3452rjq1zwr4zrxd8pkcyvij5w3iqi-home-manager-files.drv'
home-manager-generation> building '/nix/store/a7sphy967wlfqy2igan7byvgpvqpphhv-home-manager-generation.drv'
unit-home-manager-user.service> building '/nix/store/gjhw3bsaik4h7b2g7l1dl4a8w67avg44-unit-home-manager-user.service.drv'
system-units> building '/nix/store/4g0bk9nqs12ki118ksdl0nv8nisim1jk-system-units.drv'
etc> building '/nix/store/d2zdvizcxbmfr2vvnili825bc9skhng1-etc.drv'
nixos-system-t480-25.11.20250607.3e3afe> building '/nix/store/305ysr4098s6qm0y77xvn1cf70w61313-nixos-system-t480-25.11.20250607.3e3afe5.drv'
nixos-system-t480-25.11.20250607.3e3afe> building '/nix/store/ykxyaybcifg9fn7ki5ccw8l31in4jr22-nixos-system-t480-25.11.20250607.3e3afe5.drv'
┏━ Dependency Graph:
┃                   ┌─ ✔ hm_.configautostart00hello.desktop 
┃                ┌─ ✔ home-manager-files 
┃             ┌─ ✔ home-manager-generation 
┃          ┌─ ✔ unit-home-manager-user.service 
┃       ┌─ ✔ system-units ⏱ 2s
┃    ┌─ ✔ etc ⏱ 1s
┃ ┌─ ✔ nixos-system-t480-25.11.20250607.3e3afe5 
┃ ✔ nixos-system-t480-25.11.20250607.3e3afe5 
┣━━━ Builds         
┗━ ∑ ⏵ 0 │ ✔ 8 │ ⏸ 0 │ Finished at 20:17:50 after 1m0s
> Comparing changes
<<< /run/current-system
>>> /tmp/nh-os1fy0X8/result/specialisation/kde_uid1000
Added packages:
[A.]  #1  hm_.configautostart00hello.desktop  <none>
Closure size: 2309 -> 2310 (7 paths added, 6 paths removed, delta +1, disk usage +456B).
> Apply the config?
[y/N] 

Side note: home-manager can make desktop entries in a more structured way, if you want, with the xdg.desktopEntries options.

Know about that, but these specifically are autostart entries and not menu entries, though below (and above) there’s another thing for hacking up the upstream provided firefox menu entry (which doesn’t work either, actually) so…

I’m weird. My entire config (and the readme page on it doubly so) reflects that now that I think about it.

If home-manager fails to activate due to a colliding file, it fails completely. Nothing is changed at all. So it doesn’t matter that the collision wasn’t on that file.

To clarify, the home-manager activation is succeeding now (no errors in the log of home-manager-user.service) and the file still isn’t created? If so, that rules that theory out.

To clarify, the home-manager activation is succeeding now and the file still isn’t created?

Yes, pretty much. It also never showed up in nh’s Dependency Graph or Added Packages sections, which the hello world thing and the other, actually functional, autostart entry did, so…

Update: it works now for whichever reason! (entry exists, that is. Underlying script it’s launching is probably broken lol) Took a few reboots to get here which is annoying, but it is there:

[user@t480:~]$ stat ~/.config/autostart/patch-gtk-firefox-corners.desktop 
  File: /home/user/.config/autostart/patch-gtk-firefox-corners.desktop -> /nix/store/sb6ih59c3jjrnsrbncldpzlybkk0cv7w-home-manager-files/.config/autostart/patch-gtk-firefox-corners.desktop
  Size: 114       	Blocks: 8          IO Block: 4096   symbolic link
Device: 0,51	Inode: 1237093     Links: 1
Access: (0777/lrwxrwxrwx)  Uid: ( 1000/    user)   Gid: ( 1000/    user)
Access: 2025-06-08 20:50:56.678000907 +0200
Modify: 2025-06-08 20:50:49.536000327 +0200
Change: 2025-06-08 20:50:49.536000327 +0200
 Birth: 2025-06-08 20:50:49.536000327 +0200

Well, good to know it’s resolved. Hate the lack of closure on what was wrong, though. I’m still suspicious that it was just the failure to activate, and you lost track of the state a bit when checking that. Whatever it was, though, glad you’ve got it fixed.

1 Like