Problems while trying to patch in DWM

i tried to add a patch to dwm, but this error appeared and i cant do rebuild-switch, what do i do?

patching file dwm.c
Hunk #1 FAILED at 49.
Hunk #2 FAILED at 147.
Hunk #3 FAILED at 184.
Hunk #4 succeeded at 442 with fuzz 2 (offset 36 lines).
Hunk #5 FAILED at 1084.
Hunk #6 succeeded at 1442 with fuzz 1 (offset 228 lines).
Hunk #7 FAILED at 1449.
Hunk #8 FAILED at 1932.
6 out of 8 hunks FAILED -- saving rejects to file dwm.c.rej

this is the error that appears when i try to rebuild-switch

error: Cannot build '/nix/store/yix3sl7mhc02gzk6aj09v9phy0p52815-dwm-6.6.drv'. Reason: builder failed with exit code 2. Output paths: /nix/store/hxl8pci4mvcn7gas0abrsl0m1bz9y6d4-dwm-6.6 Last 17 log lines: > Running phase: unpackPhase > unpacking source archive /nix/store/pkc2iabz3ysdqiij7i2bscjh33hwg7cq-dwm > source root is dwm > Running phase: patchPhase > Running phase: updateAutotoolsGnuConfigScriptsPhase > Running phase: configurePhase > no configure script, doing nothing > Running phase: buildPhase > build flags: SHELL=/nix/store/gik3rh1vz2jlgnifb9dh6vc6sxwwz9jj-bash-5.3p9/bin/bash PREFIX=/nix/store/hxl8pci4mvcn7gas0abrsl0m1bz9y6d4-dwm-6.6 CC=gcc > gcc -c -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -I/usr/X11R6/include -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"6.8\" -DXINERAMA drw.c > gcc -c -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -I/usr/X11R6/include -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"6.8\" -DXINERAMA dwm.c > In file included from dwm.c:273: > config.h:47:10: fatal error: vanitygaps.c: No such file or directory > 47 | #include "vanitygaps.c" > | ^~~~~~~~~~~~~~ > compilation terminated. > make: *** [Makefile:12: dwm.o] Error 1 For full logs, run: nix log /nix/store/yix3sl7mhc02gzk6aj09v9phy0p52815-dwm-6.6.drv error: Cannot build '/nix/store/c9md63q34b4r9a1nnxsm4vjw52136g2a-system-path.drv'. Reason: 1 dependency failed. Output paths: /nix/store/adpsyb1g23bdhjqfqrx59fm9xwqhpsg2-system-path error: Build failed due to failed dependency error: Cannot build '/nix/store/gdgy9mwiiwifhdfyf8agrk19wllyydxz-X-Restart-Triggers-polkit.drv'. Reason: 1 dependency failed. Output paths: /nix/store/7dhvgid0mbzdhchxbx56n15wa3dk6vp5-X-Restart-Triggers-polkit error: Cannot build '/nix/store/dcmzc9malcfsa2010kq9dzp5g9rb28ci-dbus-1.drv'. Reason: 1 dependency failed. Output paths: /nix/store/nlrn129dp5v6z3wrajcgsxz5b45w6i6n-dbus-1 error: Cannot build '/nix/store/x3ib71q9089r46dg680k0b6sq77lsqkk-etc.drv'. Reason: 1 dependency failed. Output paths: /nix/store/xdnm3grgx4l91ixr3bxdzx3pj06w628b-etc error: Cannot build '/nix/store/26hmawnsmfln091and039k4l99q4yh2h-nixos-system-nixos-26.05.20260611.a037402.drv'. Reason: 1 dependency failed. Output paths: /nix/store/sxj7al2ww6hly7s9sv7czmhr2ybjmrqb-nixos-system-nixos-26.05.20260611.a037402 error: Build failed due to failed dependency Command 'nix --extra-experimental-features 'nix-command flakes' build --print-out-paths '/home/snece/nixos-dotfiles#nixosConfigurations."nixos".config.system.build.toplevel' --no-link' returned non-zero exit status 1.

i dont know which files do i have to put here also, so ask me for any file

(btw i have flakes and home-manager, if thats important to add)

The patch failed. This has nothing to do with nix(os) but just the fact that your patches are written incorrectly, hence the “hunk failed” messages. So you’ll have to fix the patches, or just fork dwm entirely and override dwm’s src to point at your fork.

1 Like

how do i fix a patch?

Clone the code, make your changes, diff the old vs new code to make the patch.
This isn’t nix-specific, so feel free to use any online resource that you think may help.

2 Likes

Yeah, the overlay method is very convenient to add some patches, but when patches fail it’s annoying to deal with, and i also ended up just forking the project and patching it that way, then using my fork as the source for the derivation (in my case it was dwl instead of dwm). There’s some good sources on youtube that give you some basic explanation on how to deal with failed patches and patching the rejected hunks manually. Websites like Github and Codeberg also have explanation on how to go about forking.

1 Like