Dwm: Difference between revisions

From NixOS Wiki
imported>Nix
m add window manager and application categories
fix links
 
(12 intermediate revisions by 3 users not shown)
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</code> in your system configuration:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 10: Line 10:
</syntaxhighlight>
</syntaxhighlight>


== Creating an override ==
=== Patching dwm ===


== Creating overlay ==
To patch dwm, override <code>services.xserver.windowManager.dwm.package</code> as below:
 
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


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
nixpkgs.overlays = [
services.xserver.windowManager.dwm.package = pkgs.dwm.override {
  (self: super: {
  patches = [
    dwn = 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
      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" | xargs nix hash to-sri --type sha256`
      # or just leave it blank, rebuild, and use the hash value from the error
      hash = "";
     })
     })
   })
   ];
];
};
</syntaxhighlight>
</syntaxhighlight>


== Configuration ==
=== Using custom sources ===
 
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:
If you have a locally stored source tree for dwm with changes already applied, you can use that instead:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
nixpkgs.overlays = [
services.xserver.windowManager.dwm.package = pkgs.dwm.overrideAttrs {
  (self: super: {
  src = ./path/to/dwm/source/tree;
    dwn = super.dwm.overrideAttrs (oldAttrs: rec {
};
      patches = [
        #Your patches here
      ]
    })
  })
];
</syntaxhighlight>
</syntaxhighlight>


Patches can be applied in different ways and in combination with each other
Alternatively, you can set <code>src</code> to [https://nixos.org/manual/nixpkgs/stable/#chap-pkgs-fetchers the output of a fetcher], if you have the source tree stored online.


=== Patches using local files ===
== Troubleshooting ==


patches can be installed by just giving the path to a local diff files. for example:
If your change does not appear to take effect:
 
<syntaxhighlight lang="nix">
nixpkgs.overlays = [
  (self: super: {
    dwn = 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>
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.
* You must '''not''' have <code>dwm</code> listed anywhere in your <code>environment.systemPackages</code> or <code>home.packages</code>.
* Remove any packages installed via <code>nix-env</code> or <code>nix profile</code>.
* After rebuilding and switching, reboot and check again.


The same thing can be done with other suckless programs like [https://nixos.wiki/wiki/St ST] and [https://suckless.org/tools/dmenu/ DMenu]
== See also ==
== See also ==
[https://nixos.wiki/wiki/St st]
* [[St]]
* [https://tools.suckless.org/dmenu/ DMenu]


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

Latest revision as of 13:28, 1 April 2024

dwm is a window manager made by the suckless team.

Installation

Enable dwm in your system configuration:

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

Creating an override

Patching dwm

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

services.xserver.windowManager.dwm.package = pkgs.dwm.override {
  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" | xargs nix hash to-sri --type sha256`
      # or just leave it blank, rebuild, and use the hash value from the error
      hash = "";
    })
  ];
};

Using custom sources

If you have a locally stored source tree for dwm with changes already applied, you can use that instead:

services.xserver.windowManager.dwm.package = pkgs.dwm.overrideAttrs {
  src = ./path/to/dwm/source/tree;
};

Alternatively, you can set src to the output of a fetcher, if you have the source tree stored online.

Troubleshooting

If your change does not appear to take effect:

  • You must not have dwm listed anywhere in your environment.systemPackages or home.packages.
  • Remove any packages installed via nix-env or nix profile.
  • After rebuilding and switching, reboot and check again.

See also