Using DWL on NixOS

Hi there, for anyone with experience with DWL on NixOS, how did you do it? I’m currently running KDE but I would also like to run DWL sometimes. My display-manager is SDDM, I got as far as including DWL in the systemPackages, but dwl didn’t show up as an option to boot in, in my display-manager.

Any help is appreciated!

You should set programs.dwl.enable in NixOS instead of adding to environment.systemPackages. If you want a customized dwl, set programs.dwl.package to the customized package.

Thank you! Will give this a shot and let you know. Would you know by any chance as well if there exists a way to manage dwl from a flake?

Don’t think there is any particular module on top of dwl.override and dwl.overrideAttrs as described in the option docs for programs.dwl.package:

# Lets apply bar patch from:
# https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/bar
(pkgs.dwl.override {
  configH = ./dwl-config.h;
}).overrideAttrs (oldAttrs: {
  buildInputs =
    oldAttrs.buildInputs or []
    ++ [
      pkgs.libdrm
      pkgs.fcft
    ];
  patches = oldAttrs.patches or [] ++ [
    ./bar-0.7.patch
  ];
});
1 Like

I think manually adding a desktop file this way works, no matter how you install dwl.

{ pkgs, ... }:
let
  mkDesktopEntry =
    name: text:
    pkgs.writeTextFile {
      inherit name text;
      destination = "/share/wayland-sessions/${name}.desktop";
      derivationArgs = {
        passthru.providedSessions = [ name ];
      };
    };
in
{
  services.displayManager.sessionPackages = [
    (mkDesktopEntry "dwl" ''
      [Desktop Entry]
      Name=dwl
      Comment=dwl
      Exec=/run/current-system/sw/bin/dwl
      Type=Application
    '')
  ];
}

I don’t see any reason to use this. the dwl package provides this file:

❯ cat result/share/wayland-sessions/dwl.desktop
[Desktop Entry]
Name=dwl
Comment=dwm for Wayland
Exec=dwl
Type=Application

So if your “no matter how you install dwl” means through HM, I would just do that. Or do that but keep the wrapper but replace exec ${lib.getExe cfg.package} with exec dwl.