Dwm: Difference between revisions

From NixOS Wiki
imported>Sikmir
m Fix typos
imported>Hypnosis2839
replace overlays with override, deduplicate info
Line 1: Line 1:


<code>dwm</code> is a window manager made by the suckless team
<code>dwm</code> is a window manager made by the suckless team.


== Installation ==
== Installation ==


Installation is simple when using an xserver. In your <code>configuration.nix</code> just enable <code>dwm</code> like this:
Enable <code>dwm</dwm> in your system configuration:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 11: Line 11:




== Creating overlay ==
== Creating override ==


To apply patches, and modify config file, you have to create an overlay for dwm which will be used to override config files and applying patches. This can be done like the following
To patch dwm, override `services.xserver.windowManager.dwm.package` as below:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
nixpkgs.overlays = [
services.xserver.windowManager.dwm.package = pkgs.dwm.overrideAttrs (oldAttrs: rec {
  (self: super: {
  patches = [
    dwm = super.dwm.overrideAttrs (oldAttrs: rec {
    # for local patch files, replace with relative path to patch file
      # ...
     ./path/to/local.patch
    });
     # for external patches
  })
    (pkgs.fetchpatch {
];
      # replace with actual URL
</syntaxhighlight>
      url = "https://dwm.suckless.org/patches/path/to/patch.diff";
 
      # replace hash with the value from `nix-prefetch-url "https://dwm.suckless.org/patches/path/to/patch.diff"`
== Configuration ==
       hash = "";
 
Missing. For now, refer to [https://nixos.wiki/wiki/St st], this explains how to modify config st, you have to do it in a similar way for dwm, but you have to use the overlay instead of the way it is done for st.
 
== Patching ==
 
Patches can be applied by using the patches array:
 
<syntaxhighlight lang="nix">
nixpkgs.overlays = [
  (self: super: {
    dwm = super.dwm.overrideAttrs (oldAttrs: rec {
      patches = [
        #Your patches here
      ];
    });
  })
];
</syntaxhighlight>
 
Patches can be applied in different ways and in combination with each other
 
=== Patches using local files ===
 
patches can be installed by just giving the path to a local diff files. for example:
 
<syntaxhighlight lang="nix">
nixpkgs.overlays = [
  (self: super: {
     dwm = super.dwm.overrideAttrs (oldAttrs: rec {
      patches = [
        ./path/to/local.diff
      ];
     });
  })
];
</syntaxhighlight>
 
=== patches using fetchpatch ===
 
If you want to use fetchpatch you need to obtain the hash for the patch you want to apply .
 
To obtain the hash of a patch you need to run the command <code>nix-prefetch-url <url></code> for example:
 
<syntaxhighlight lang="sh">
$ nix-prefetch-url https://dwm.suckless.org/patches/steam/dwm-steam-6.2.diff
</syntaxhighlight>
 
This will output the hash that you need.
 
In your patches array you can then apply the patch in the following way using fetchpatch
 
<syntaxhighlight lang="nix">
nixpkgs.overlays = [
  (self: super: {
    dwm = super.dwm.overrideAttrs (oldAttrs: rec {
      patches = [
        (super.fetchpatch {
          url = "https://dwm.suckless.org/patches/steam/dwm-steam-6.2.diff";
          sha256 = "1ld1z3fh6p5f8gr62zknx3axsinraayzxw3rz1qwg73mx2zk5y1f";
        })
       ];
    });
  })
];
</syntaxhighlight>
== Using Custom Builds ==
If you want to use an existing config of DWM you can create a custom local nix overlay
<syntaxhighlight lang="nix">
nixpkgs.overlays = [
    (final: prev: {
      dwm = prev.dwm.overrideAttrs (old: { src = /path/to/dwm ;});
     })
     })
];
  ];
})
</syntaxhighlight>
</syntaxhighlight>
This will make sure it will rebuild your suckless build when nix is rebuilt.


Note: nix will only rebuild DWM if there are changes to the files.
The same thing can be done with other suckless programs like [https://nixos.wiki/wiki/St ST] and [https://tools.suckless.org/dmenu/ DMenu]
== See also ==
== See also ==
[https://nixos.wiki/wiki/St st]
[https://nixos.wiki/wiki/St st]
[https://tools.suckless.org/dmenu/ DMenu]


[[Category:Window managers]]
[[Category:Window managers]]
[[Category:Applications]]
[[Category:Applications]]

Revision as of 16:16, 17 August 2023

dwm is a window manager made by the suckless team.

Installation

Enable dwm</dwm> in your system configuration:

services.xserver.windowManager.dwm.enable = true;


Creating override

To patch dwm, override `services.xserver.windowManager.dwm.package` as below:

services.xserver.windowManager.dwm.package = pkgs.dwm.overrideAttrs (oldAttrs: rec {
  patches = [
    # for local patch files, replace with relative path to patch file
    ./path/to/local.patch
    # for external patches
    (pkgs.fetchpatch {
      # replace with actual URL
      url = "https://dwm.suckless.org/patches/path/to/patch.diff";
      # replace hash with the value from `nix-prefetch-url "https://dwm.suckless.org/patches/path/to/patch.diff"`
      hash = "";
    })
  ];
})

See also

st

DMenu