Dwm: Difference between revisions

From NixOS Wiki
imported>Alexnortung
Created page.
 
fix links
 
(16 intermediate revisions by 6 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 apply patches to 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.
If you have a locally stored source tree for dwm with changes already applied, you can use that instead:
 
== Patching ==
 
Patches can be applied by using the patches array:


<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">
* You must '''not''' have <code>dwm</code> listed anywhere in your <code>environment.systemPackages</code> or <code>home.packages</code>.
nixpkgs.overlays = [
* Remove any packages installed via <code>nix-env</code> or <code>nix profile</code>.
  (self: super: {
* After rebuilding and switching, reboot and check again.
    dwn = super.dwm.overrideAttrs (oldAttrs: rec {
      patches = [
        ./path/to/local.diff
      ]
    })
  })
];
</syntaxhighlight>


=== patches using fetchpatch ===
== See also ==
 
* [[St]]
If you want to use fetchpatch you need to obtain the hash for the patch you want to apply .
* [https://tools.suckless.org/dmenu/ DMenu]
 
To obtain the hash of a patch you need to run the command <code>nix-prefetch-url <url></code> for example:


<syntaxhighlight lang="sh">
[[Category:Window managers]]
$ nix-prefetch-url https://dwm.suckless.org/patches/steam/dwm-steam-6.2.diff
[[Category:Applications]]
</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>
 
== See also ==
[https://nixos.wiki/wiki/St st]

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