Dwm override config.h

got two questions.
first I run dwm on two systems, and I have created two different config.h files, due to different font sizes and different sizes on some scratchpads I use. This is due too different screen sizes. However I was thinking it must be a better way of doing things. Noobz talked to me about using overrides, and I was thinking maybe creating a patch that changes the content in the original config.h file and then using that patch as a override, which I call from my flake for my laptop.

nixpkgs.overlays = [
  (self: super: {
    dwm = super.dwm.overrideAttrs (oldAttrs: rec {
      patches = [
        #Your patches here

Will this work? and I guess I need too keep the patch somewhere inn my system flake?

My second question:

I am constantly fixing my dwm and as of now my dwm flake does not let me use nix develop and I don’t know what more I need to add so I can be able to access a dev env and test build before updating not tested changes in my main flake.

IIRC dwm already provides a config override where you can pass in the config file directly. Alternatively it has patches in the override, rather than in the overrideAttrs.

Then I would have to pass inn the whole config.h for the laptop, instead of just 5-7 lines in a patch?

If you already have the base config in the src or just alter the “defaults” slightly, you can of course use patches, still I’d suggest to use the override function, rather than overrideAttrs.

trying too look for the override in nixpkgs for dwm and I only see overrideAttrs

Would :

(dwm.override {
        patches = [


As you can assume that overrideAttrs exists for anything that ultimately calls stdenv.mkDerivation, you can also assume that override exists for any top-level attribute, as most if not all are defined through callPackage (about which there is a small blog post available which explains its use, but not how it works)

Im confused, how would I write this?
Would it be an new overlay? or can I pass override for my laptop and take inn

configFile = super.writeText "config.h" (builtins.readFile ./dwm-config.h);

could you explain a bit how I would be able to pull this off

{ inputs
, lib
, pkgs
, config
, ...
with lib;
with builtins; let
  cfg = config.services.laptop;
  options.services.laptop.enable = mkEnableOption "laptop dwm config";
  config = mkIf cfg.enable {
    environment.systemPackages = with pkgs; [
      (dwm.override =
        conf = .laptop.conf.h;

getting some syntax errors, and would this work?

A path that refers to a file in the same folder as the current nix-file would be prefixed with a ./, eg. ./.laptop.conf.h. Though I’m curious why you “dotted” that file…

Also override is a function, not some attribute you want to assign a value to, so the = is another syntactic problem.

Not sure if there are more errors hiding.

fixed the .laptop. That was a typo

Here is a link you explaining, what am I missing for this too work?

I have no clue what you have right now, and the link is from ~2.5yrs ago, back when I was rookie by myself and did not carefully fix all the errors in the snippet, but only one.

I would expect that a simple dwm.override { conf = ./config.h; } would totally do. If it doesn’t it would be nice to tell us what errors you get, instead of letting us guess.

That cleared out the errors, sorry if I was bad at explaining, will test this on my laptop now.

What about my second question, my current dwm flake
how can I change this so I can use nix develop?

Provide a devShells.$system.default output that describes the devshell you need.

$ sudo nixos-rebuild switch --flake .#mXlaptop
warning: Git tree '/home/merrinx/Sources/nixos' is dirty
building the system configuration...
warning: Git tree '/home/merrinx/Sources/nixos' is dirty
error: A definition for option `environment.systemPackages."[definition 2-entry 1]"' is not of type `package'. Definition values:
       - In `/nix/store/qk7fmc3w33iwy6lz6z5xvv94lngrz6yb-source/modules/nixos/overrides/laptop.nix': <function, args: {conf?, fetchurl, lib, libX11, libXft, libXinerama, patches?, stdenv, writeText}>
(use '--show-trace' to show detailed location information)

This is the error I get when trying to build on my laptop with my current config

Does not dwm have conf? to override config.h?

You forgot the parenthesis around dwm.override { … }.

Nix currently sees dwm.override and { … } as distinct entries in the list.

Thank you so much for helping. will be working on getting the the devshell working.

Did some work with the flake, Im stuck on error: expected a derivation

$ nix flake show
warning: Git tree '/home/merrinx/Projects/suckless/dwm' is dirty
evaluating ''...
evaluating 'checks'...
evaluating 'checks.x86_64-linux'...
evaluating 'checks.x86_64-linux.build'...
evaluating 'devShell'...
evaluating 'devShell.__ignoreNulls'...
error: expected a derivation
e[32;1m│   └───e[0me[1mx86_64-linuxe[0m
e[32;1m│       └───e[0me[1mbuilde[0m: derivation 'dwm-6.3'

here is my flake

what is missing?

  1. it is devShells (plural), the singular form has been removed durin Q1 '22 IIRC
  2. A system (was necessary in the singular form as well) and an attribute name are missing

pkgs inherit system and I dont understand what attribute I am missing