nixos/dwl: init module

Gurjaka be1545fc b94166b8

+151
+2
nixos/doc/manual/release-notes/rl-2511.section.md
··· 19 19 20 20 - [SuiteNumérique Docs](https://github.com/suitenumerique/docs), a collaborative note taking, wiki and documentation web platform and alternative to Notion or Outline. Available as [services.lasuite-docs](#opt-services.lasuite-docs.enable). 21 21 22 + [dwl](https://codeberg.org/dwl/dwl), a compact, hackable compositor for Wayland based on wlroots. Available as [programs.dwl](#opt-programs.dwl.enable). 23 + 22 24 ## Backward Incompatibilities {#sec-release-25.11-incompatibilities} 23 25 24 26 <!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
+1
nixos/modules/module-list.nix
··· 330 330 ./programs/vivid.nix 331 331 ./programs/wavemon.nix 332 332 ./programs/wayland/cardboard.nix 333 + ./programs/wayland/dwl.nix 333 334 ./programs/wayland/gtklock.nix 334 335 ./programs/wayland/hyprland.nix 335 336 ./programs/wayland/hyprlock.nix
+104
nixos/modules/programs/wayland/dwl.nix
··· 1 + { 2 + config, 3 + lib, 4 + pkgs, 5 + ... 6 + }: 7 + let 8 + cfg = config.programs.dwl; 9 + in 10 + { 11 + options.programs.dwl = { 12 + enable = lib.mkEnableOption '' 13 + Dwl is a compact, hackable compositor for Wayland based on wlroots. 14 + You can manually launch Dwl by executing "exec dwl" on a TTY. 15 + ''; 16 + 17 + package = lib.mkPackageOption pkgs "dwl" { 18 + example = '' 19 + # Lets apply bar patch from: 20 + # https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/bar 21 + (pkgs.dwl.override { 22 + configH = ./dwl-config.h; 23 + }).overrideAttrs (oldAttrs: { 24 + buildInputs = 25 + oldAttrs.buildInputs or [] 26 + ++ [ 27 + pkgs.libdrm 28 + pkgs.fcft 29 + ]; 30 + patches = oldAttrs.patches or [] ++ [ 31 + ./bar-0.7.patch 32 + ]; 33 + }); 34 + ''; 35 + }; 36 + 37 + extraSessionCommands = lib.mkOption { 38 + default = ""; 39 + type = lib.types.lines; 40 + description = '' 41 + Shell commands executed just before dwl is started. 42 + ''; 43 + }; 44 + }; 45 + 46 + config = lib.mkIf cfg.enable { 47 + environment.systemPackages = [ cfg.package ]; 48 + 49 + # Create systemd target for dwl session 50 + systemd.user.targets.dwl-session = { 51 + description = "dwl compositor session"; 52 + documentation = [ "man:systemd.special(7)" ]; 53 + bindsTo = [ "graphical-session.target" ]; 54 + wants = [ "graphical-session-pre.target" ]; 55 + after = [ "graphical-session-pre.target" ]; 56 + }; 57 + 58 + # Create wrapper script for dwl 59 + environment.etc."xdg/dwl-session" = { 60 + text = '' 61 + #!${pkgs.runtimeShell} 62 + # Import environment variables 63 + ${cfg.extraSessionCommands} 64 + # Setup systemd user environment 65 + systemctl --user import-environment DISPLAY WAYLAND_DISPLAY 66 + systemctl --user start dwl-session.target 67 + # Start dwl 68 + exec ${lib.getExe cfg.package} 69 + ''; 70 + mode = "0755"; # Make it executable 71 + }; 72 + 73 + # Create desktop entry for display managers 74 + services.displayManager.sessionPackages = 75 + let 76 + dwlDesktopFile = pkgs.writeTextFile { 77 + name = "dwl-desktop-entry"; 78 + destination = "/share/wayland-sessions/dwl.desktop"; 79 + text = '' 80 + [Desktop Entry] 81 + Name=dwl 82 + Comment=Dynamic window manager for Wayland 83 + Exec=/etc/xdg/dwl-session 84 + Type=Application 85 + ''; 86 + }; 87 + 88 + dwlSession = pkgs.symlinkJoin { 89 + name = "dwl-session"; 90 + paths = [ dwlDesktopFile ]; 91 + passthru.providedSessions = [ "dwl" ]; 92 + }; 93 + in 94 + [ dwlSession ]; 95 + 96 + # Configure XDG portal for dwl (minimal configuration) 97 + xdg.portal.config.dwl.default = lib.mkDefault [ 98 + "wlr" 99 + "gtk" 100 + ]; 101 + }; 102 + 103 + meta.maintainers = with lib.maintainers; [ gurjaka ]; 104 + }
+1
nixos/tests/all-tests.nix
··· 412 412 druid = handleTestOn [ "x86_64-linux" ] ./druid { }; 413 413 drbd-driver = runTest ./drbd-driver.nix; 414 414 dublin-traceroute = runTest ./dublin-traceroute.nix; 415 + dwl = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./dwl.nix; 415 416 earlyoom = handleTestOn [ "x86_64-linux" ] ./earlyoom.nix { }; 416 417 early-mount-options = handleTest ./early-mount-options.nix { }; 417 418 ec2-config = (handleTestOn [ "x86_64-linux" ] ./ec2.nix { }).boot-ec2-config or { };
+43
nixos/tests/dwl.nix
··· 1 + { lib, ... }: 2 + { 3 + name = "dwl_test_vm"; 4 + 5 + meta = { 6 + maintainers = with lib.maintainers; [ gurjaka ]; 7 + }; 8 + 9 + nodes.machine = 10 + { 11 + pkgs, 12 + lib, 13 + ... 14 + }: 15 + { 16 + imports = [ 17 + ./common/user-account.nix 18 + ./common/wayland-cage.nix 19 + ]; 20 + 21 + environment.systemPackages = [ pkgs.foot ]; 22 + 23 + services.displayManager.defaultSession = lib.mkForce "dwl"; 24 + 25 + programs.dwl.enable = true; 26 + }; 27 + 28 + testScript = '' 29 + with subtest("ensure dwl starts"): 30 + machine.wait_for_file("/run/user/1000/wayland-0") 31 + 32 + with subtest("ensure foot is installed"): 33 + machine.succeed("which foot") 34 + 35 + with subtest("ensure we can open a new terminal"): 36 + # sleep 3 is required to make sure dwl has started 37 + # TODO: find better way to identify dwl session 38 + machine.sleep(3) 39 + machine.send_key("alt-shift-ret") 40 + machine.sleep(3) 41 + machine.screenshot("terminal") 42 + ''; 43 + }