DWM problems in NixOS

I’m using dwm on NixOS and building it through nixos-rebuild with a local source (~/.clones/dwm). Patches apply correctly, so the build is being compiled, but changes in config.def.h (like changing MODKEY to Super/Mod4) are not taking effect in the running session.

which dwm shows /run/current-system/sw/bin/dwm, so I’m definitely running the NixOS-managed binary via ly. The problem seems to be that Nix is either caching the previous build or not properly invalidating/rebuilding when config.def.h changes, so the compiled output doesn’t reflect my latest config changes even though patches in dwm.c do apply.

That’s not a thing with nix.

How exactly are you rebuilding? How did you add it to your config? What steps are you taking to restart dwm?

I think you need to restart the display-manager.service
Before restarting, the display manager won’t use the new environment variables.

If you use ‘whereis dwm’, the result will point to /nix/store. I don’t know why this is, but obviously, display managers prefer to use the latter.

So the usual short command (dwm) won’t be updated.
Creating a desktop file that uses the long command (/run/current-system/sw/bin/dwm) works.

I use this in my configuration:

{ pkgs, ... }:
let
  mkDesktopEntry =
    name: text:
    pkgs.writeTextFile {
      inherit name text;
      destination = "/share/wayland-sessions/${name}.desktop";
      derivationArgs = {
        passthru.providedSessions = [ name ];
      };
    };
in
{
  services.displayManager.sessionPackages = [
    (mkDesktopEntry "niri" ''
      [Desktop Entry]
      Name=Niri
      Comment=Niri
      Exec=/run/current-system/sw/bin/niri-wrapped
      Type=Application
    '')
  ];
}

(niri-wrapped is a binary wrapper)