Changes to config.h in dwm are not applying

Hello, i have installed dwm on nixos using the following settings, as were defined in this thread

services.xserver = {
enable = true;
windowManager = {
dwm = {
enable = true;
package = pkgs.dwm.overrideAttrs {
src = ./dwm;
};
};
};
};

as the thread had mentioned, i had to make a copy of the config.def.h and create a config.h and then i could make changes in there

i did that and to just test things out i changed these lines

static const char col_gray1
static const char col_gray2
static const char col_gray3
static const char col_gray4
static const char col_cyan
i just changed these to random colors

and i changed this
static const char *termcmd = {“st”, NULL};
to this
static const char *termcmd = {“kitty”, NULL};
and then i just saved the file and did nixos-rebuild switch

none of these changes took place and i didnt try and change anything else since even the most basic settings arent being updated

i have no idea what to do, i have tried looking for a solution for the past week and there is no documentation, article, video or anything helpful on this topic and i dont know what to do anymore so im just asking here

hopefully someone can help me out

Are you using git in your directory? If so run the command git add .
Also if you have code press crtl+e here on the forum and write your code in there.

i dont have git, i just downloaded the repo manually and then placed it in there

Can you post your config and directory structure with tree (nix-shell -p tree than in your /etc/nixos directory run tree and post the output).
Also you always need to restart dwm to see the changes.

.
|__ configuration.nix
|__ dwm
| |__ config.h
| |__ config.mk
| |__ drw.c
| |__ drw.h
| |__ dwm.1
| |__ dwm.c
| |__ dwm.png
| |__ LICENSE
| |__ Makefile
| |__ original.h # this is a backup of the original config.def.h
| |__ README
| |__ transient.c
| |__ util.c
| |__ util.h
|__ hardware-configuration.nix

Please press crtl+e and write outputs and code in there. Makes it easier to read.
Also have you done a restart of dwm?
Can you also post your configuration.nix?

will use ctrl+e from now on,
what do you mean by restart dwm, do you mean 'did i do nixos-rebuild switch,
cant share my config since im an idiot and forgot to download a clipboard

1 Like

No I mean that dwm does not reload the config on the go. You need to restart dwm in order to let dwm apply the changes. To restart it just log out (not lock) and back in.
For the clipboard i can recommend wl-clipboard-rs. Just put this in your packages to have a clipboard

ok, give me a second

1 Like

i pressed alt+shit+q, exited, logged back in, my default terminal is still st and not kitty

@Postboote
i have a question, when i change the config and do ‘nixos-rebuild switch’ do i immediately log out and then log back in or do i do reboot and then log back in, because what i do is

change config
do nixos-rebuild switch
do reboot
login into the system
find that nothing has changed

is this ok

Yeah you can do it but you don’t need to restart you whole computer, just dwm by logging out.
But are the changes you made in the config file in present in your config.def.h file in your home-directory.

there is no file in the home directory, the thread i mentioned never told me to do that
ive never used dwm before this
i thought that i would put everything on my nixos folder and it would work

do i have to make a copy of the config in the home directory as well?

No you don’t need to do that. I thought that dwm had a config file and you just edit it. But to configure dwm you need to sort of “recompile it everytime you do a config change”. So there is no config file in your home direcoty.
But can you post your complete config please?
Also try this:

  services.xserver.windowManager.dwm.package = pkgs.dwm.override {
    conf = ./dwm/config.def.h;
  };

rename your config.h file in your dwm directory to config.def.h file

ok, give me some time, i’ll try that and let you know what happened

also to confirm, im supposed to rename my config.h to config.def.h and point directly to it, right?

1 Like

Nothing worked and heres what i tried


  • configuration.nix setup1
	services.xserver = {
		enable = true;
		windowManager = {
			dwm  = {
				enable = true;
				package = pkgs.dwm.overrideAttrs {
					src = ./dwm;
				}
			}
		}
	}
  • changing the config in config.def.h and then rebuilding the system
  • copying the config into config.h and then rebuilding the system
  • removing the config.def.h entirely and then rebuilding the system

  • configuration.nix setup2
dwm  = {
	enable = true;
	package = pkgs.dwm.override {
		conf = ./config.def.h;
	};
};

-tried everything as before, didnt work


  • configuration.nix setup3
dwm  = {
	enable = true;
	package = pkgs.dwm.override {
		conf = ./dwm/config.def.h;
	};
};
  • tried everything as before, didnt work

  • configuration.nix setup4
dwm  = {
	enable = true;
	package = pkgs.dwm.override {
		dwm = ./dwm;
	};
};
  • tried, failed

  • configuration.nix setup5
dwm  = {
	enable = true;
		package = pkgs.dwm.override {
		src = ./dwm;
	};
};
  • tried, failed

  • configuration.nix setup5
dwm  = {
	enable = true;
		package = pkgs.dwm.overrideAttrs {
		conf = ''
			static const char col_cyan[] = "#ff0000";
		'';
	};
};
  • tried, failed

  • configuration.nix setup5
dwm  = {
	enable = true;
		package = pkgs.dwm.override {
		conf = ''
			static const char col_cyan[] = "#ff0000";
		'';
	};
};
  • tried, failed

truly, the only reason i wanted to use dwm was because it was a lightweight system and i thought, why not use the lightest system out there as my main one, but if it is this annoying to setup than i guess im just moving on

ive heard lxqt has a builtin window manager thats pretty nice, ill just use that

i really hoped to have solved this problem but i have work to do and i cant spend another week on this

thanks for your help though @Postboote, really appreciate it

Yeah dwm’s configuration is pretty wierd. Lxqt is a good option for a lightweight desktop manager. But if you are looking for dynamic tiling windowmanager you could try out i3 for X11 and for wayland sway. Both are really grate configurable with Nixos. But it is purly a window manager, means no taskbar, etc. If you are looking for a desktop manager like kde there are many options. Lxqt is one option.
For more you can check the Arch Wiki:
https://wiki.archlinux.org/title/Desktop_environment

1 Like

UPDATE: I figured it out

I used lxqt for a bit but i really liked the functionality that was built into dwm, so i switched back and ive just been sitting down with chatgpt on and off trying different things to get this working and we finally figured it out,

And since now i know what needs to be done

Here is a full tutorial on how to install dwm on nixos

Get the repo

  • Get the github repo of dwm, by either manually downloading the zip from the website or by pulling it with git
    • If you did the manual download then,
      • Unzip the folder in the nixos folder where you have your configuration.nix
    • If you pulled it through git then,
      • Move the folder into the nixos folder where you have your configuration.nix
    • If the folder ends up having a different name than dwm then rename it as such
    • If you want to change the name to something else entirely then DONOT FORGET to update the name in your configuration.nix as well

Update configuration.nix

  • Go into your config
  • In there it will be formatted like this,
    { config, lib, pkgs, ... }:
    {
        imports = 
            # the
            # rest
            # of
            # your
            # config

    } # the end of your config
  • In there, add the following, anywhere in your configuration.nix
    { config, lib, pkgs, ... }:
    {
        imports = 
            # some stuff
            # more things

            nixpkgs.overlays = [
                (final: prev: {
                    dwm = prev.dwm.overrideAttrs (old: {
                        src = ./dwm; # this is where you tell nixos to get all of your dwm settings from
                    });
                })
            ];
            # you can put something else here

            services.xserver.enable = true;
            services.xserver.windowManager.dwm.enable = true;
            # you can put something else here

    } # the end of your config
  • NOTE: I have no idea what nixpkgs.overlays does, i just copied it from chatgpt

Update DWM config

  • After this is done, go into the dwm folder and then make a copy of the config.def.h file to something like original.h (just in case you break everything and need to go back)
  • Now you can update the config.def.h file to suit your needs
  • When that is done, just save the file and do sudo nixos-rebuild switch and reboot the system or you could just logout and login
  • Your changes should appear as expected, hopefully
1 Like