{ config, lib, pkgs, ... }: let cfg = config.programs.crywl; in { options.programs.crywl = with lib; { enable = mkEnableOption "CryWL"; xwayland.enable = mkEnableOption "XWayland"; defaultSession = mkEnableOption "CryWL as the default login session"; # currently DWL 0.7 (also beware I'll barely ever update the original DWL refs) useUnmodifiedDWL = mkOption { type = types.bool; default = false; description = "Whether to use unmodified DWL source code (latest stable release)"; }; }; config = lib.mkIf cfg.enable (let xwaylandEnabled = cfg.xwayland.enable; defaultSession = cfg.defaultSession; useUnmodifiedDWL = cfg.useUnmodifiedDWL; in { services.displayManager = { sessionPackages = [ pkgs.crywl ]; defaultSession = lib.mkIf defaultSession "crywl"; }; environment.systemPackages = [ pkgs.crywl ]; nixpkgs.overlays = [ (self: super: { crywl = super.dwl.overrideAttrs (oldAttrs: rec { pname = "crywl"; version = "0.1-unstable"; src = let dwl_0_70 = { rev = "74e45c4014ae7048ecbb76eb6f54034b8b479480"; hash = "sha256-7SoCITrbMrlfL4Z4hVyPpjB9RrrjLXHP9C5t1DVXBBA="; }; crywl_unstable = { rev = "dc1260d3cfd14e8e5b243ec1d3d56e4b08c8c517"; hash = "sha256-61R+xBYMzeEn93gLofcj8Y3VbJqW6g7GzCTujpAco90="; }; in pkgs.fetchFromGitea ({ domain = "forge.imbored.dev"; owner = "emileclarkb"; repo = pname; } // ( if useUnmodifiedDWL then dwl_0_70 else crywl_unstable )); buildInputs = with pkgs; [ libinput xorg.libxcb libxkbcommon pixman wayland wayland-protocols wlroots_0_19 ] ++ lib.optionals xwaylandEnabled [ xorg.libX11 xorg.xcbutilwm xwayland ]; makeFlags = [ "PKG_CONFIG=${pkgs.stdenv.cc.targetPrefix}pkg-config" "WAYLAND_SCANNER=wayland-scanner" "PREFIX=$(out)" "MANDIR=$(man)/share/man" ] ++ lib.optionals xwaylandEnabled [ ''XWAYLAND="-DXWAYLAND"'' ''XLIBS="xcb xcb-icccm.pc"'' ]; # Ensure `crywl.desktop` entry is registered passthru = { providedSessions = [pname]; tests.version = pkgs.testers.testVersion { package = oldAttrs.finalPackage; # `dwl -v` emits its version string to stderr and returns 1 command = "crywl -v 2>&1; return 0"; }; }; meta = { homepage = "https://forge.imbored.dev/emileclarkb/crywl"; description = "Personal fork of DWL"; license = lib.licenses.gpl3Only; maintainers = [lib.maintainers.emileclarkb]; inherit (pkgs.wayland.meta) platforms; mainProgram = "crywl"; }; }); }) ]; }); }