From b3d40c2a5d1049b9e6395323d1e3356e078aeb6d Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sat, 27 Jul 2024 11:52:44 -0300 Subject: [PATCH 1/4] dwl: migrate to by-name --- .../dwl/default.nix => by-name/dw/dwl/package.nix} | 0 pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename pkgs/{applications/window-managers/dwl/default.nix => by-name/dw/dwl/package.nix} (100%) diff --git a/pkgs/applications/window-managers/dwl/default.nix b/pkgs/by-name/dw/dwl/package.nix similarity index 100% rename from pkgs/applications/window-managers/dwl/default.nix rename to pkgs/by-name/dw/dwl/package.nix diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b3bb6922779c..8cc53c2529cf 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -29925,7 +29925,7 @@ with pkgs; dyff = callPackage ../development/tools/dyff { }; - dwl = callPackage ../applications/window-managers/dwl { + dwl = callPackage ../by-name/dw/dwl/package.nix { wlroots = wlroots_0_17; }; From cd9bb3a278c33115ebbcaf14e7ceb8e3a57e6b64 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sat, 27 Jul 2024 11:57:02 -0300 Subject: [PATCH 2/4] dwl: nixfmt-rfc-style --- pkgs/by-name/dw/dwl/package.nix | 83 ++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/pkgs/by-name/dw/dwl/package.nix b/pkgs/by-name/dw/dwl/package.nix index 65ea637d6de1..8f2a178aa263 100644 --- a/pkgs/by-name/dw/dwl/package.nix +++ b/pkgs/by-name/dw/dwl/package.nix @@ -1,22 +1,23 @@ -{ lib -, stdenv -, fetchFromGitea -, installShellFiles -, libX11 -, libinput -, libxcb -, libxkbcommon -, pixman -, pkg-config -, wayland-scanner -, wayland -, wayland-protocols -, wlroots -, writeText -, xcbutilwm -, xwayland -, enableXWayland ? true -, conf ? null +{ + lib, + stdenv, + fetchFromGitea, + installShellFiles, + libX11, + libinput, + libxcb, + libxkbcommon, + pixman, + pkg-config, + wayland-scanner, + wayland, + wayland-protocols, + wlroots, + writeText, + xcbutilwm, + xwayland, + enableXWayland ? true, + conf ? null, }: stdenv.mkDerivation (finalAttrs: { @@ -37,28 +38,34 @@ stdenv.mkDerivation (finalAttrs: { wayland-scanner ]; - buildInputs = [ - libinput - libxcb - libxkbcommon - pixman - wayland - wayland-protocols - wlroots - ] ++ lib.optionals enableXWayland [ - libX11 - xcbutilwm - xwayland + buildInputs = + [ + libinput + libxcb + libxkbcommon + pixman + wayland + wayland-protocols + wlroots + ] + ++ lib.optionals enableXWayland [ + libX11 + xcbutilwm + xwayland + ]; + + outputs = [ + "out" + "man" ]; - outputs = [ "out" "man" ]; - # Allow users to set an alternative config.def.h - postPatch = let - configFile = if lib.isDerivation conf || builtins.isPath conf - then conf - else writeText "config.def.h" conf; - in lib.optionalString (conf != null) "cp ${configFile} config.def.h"; + postPatch = + let + configFile = + if lib.isDerivation conf || builtins.isPath conf then conf else writeText "config.def.h" conf; + in + lib.optionalString (conf != null) "cp ${configFile} config.def.h"; makeFlags = [ "PKG_CONFIG=${stdenv.cc.targetPrefix}pkg-config" From b05aeee70448657b6bbae70e23bff2277a7f2d57 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sat, 27 Jul 2024 14:18:23 -0300 Subject: [PATCH 3/4] dwl: rework - reorder input set - new options - withCustomConfigH - deprecate conf; promote configH - strictDeps - __structuredAttrs - add passthru.tests - update meta.homepage - update meta.longDescription - remove meta.changelog (because a parameterized changelog is fragile) --- pkgs/by-name/dw/dwl/package.nix | 67 +++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/pkgs/by-name/dw/dwl/package.nix b/pkgs/by-name/dw/dwl/package.nix index 8f2a178aa263..cbeea643d2a6 100644 --- a/pkgs/by-name/dw/dwl/package.nix +++ b/pkgs/by-name/dw/dwl/package.nix @@ -1,6 +1,5 @@ { lib, - stdenv, fetchFromGitea, installShellFiles, libX11, @@ -9,17 +8,34 @@ libxkbcommon, pixman, pkg-config, - wayland-scanner, + stdenv, + testers, wayland, wayland-protocols, + wayland-scanner, wlroots, writeText, xcbutilwm, xwayland, + # Boolean flags enableXWayland ? true, + withCustomConfigH ? (configH != null), + # Configurable options + configH ? + if conf != null then + lib.warn '' + conf parameter is deprecated; + use configH instead + '' conf + else + null, + # Deprecated options + # Remove them before next version of either Nixpkgs or dwl itself conf ? null, }: +# If we set withCustomConfigH, let's not forget configH +assert withCustomConfigH -> (configH != null); stdenv.mkDerivation (finalAttrs: { pname = "dwl"; version = "0.5"; @@ -59,30 +75,43 @@ stdenv.mkDerivation (finalAttrs: { "man" ]; - # Allow users to set an alternative config.def.h postPatch = let configFile = - if lib.isDerivation conf || builtins.isPath conf then conf else writeText "config.def.h" conf; + if lib.isDerivation configH || builtins.isPath configH then + configH + else + writeText "config.h" configH; in - lib.optionalString (conf != null) "cp ${configFile} config.def.h"; + lib.optionalString withCustomConfigH "cp ${configFile} config.h"; - makeFlags = [ - "PKG_CONFIG=${stdenv.cc.targetPrefix}pkg-config" - "WAYLAND_SCANNER=wayland-scanner" - "PREFIX=$(out)" - "MANDIR=$(man)/share/man" - ]; + makeFlags = + [ + "PKG_CONFIG=${stdenv.cc.targetPrefix}pkg-config" + "WAYLAND_SCANNER=wayland-scanner" + "PREFIX=$(out)" + "MANDIR=$(man)/share/man" + ] + ++ lib.optionals enableXWayland [ + ''XWAYLAND="-DXWAYLAND"'' + ''XLIBS="xcb xcb-icccm"'' + ]; - preBuild = '' - makeFlagsArray+=( - XWAYLAND=${lib.optionalString enableXWayland "-DXWAYLAND"} - XLIBS=${lib.optionalString enableXWayland "xcb\\ xcb-icccm"} - ) - ''; + strictDeps = true; + + # required for whitespaces in makeFlags + __structuredAttrs = true; + + passthru = { + tests.version = testers.testVersion { + package = finalAttrs.finalPackage; + # `dwl -v` emits its version string to stderr and returns 1 + command = "dwl -v 2>&1; return 0"; + }; + }; meta = { - homepage = "https://github.com/djpohly/dwl/"; + homepage = "https://codeberg.org/dwl/dwl"; description = "Dynamic window manager for Wayland"; longDescription = '' dwl is a compact, hackable compositor for Wayland based on wlroots. It is @@ -92,10 +121,8 @@ stdenv.mkDerivation (finalAttrs: { - Easy to understand, hack on, and extend with patches - One C source file (or a very small number) configurable via config.h - - Limited to 2000 SLOC to promote hackability - Tied to as few external dependencies as possible ''; - changelog = "https://github.com/djpohly/dwl/releases/tag/v${finalAttrs.version}"; license = lib.licenses.gpl3Only; maintainers = [ lib.maintainers.AndersonTorres ]; inherit (wayland.meta) platforms; From 37014e4ccf5739861a233dbef8d40c31ac086fd2 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sat, 27 Jul 2024 14:37:41 -0300 Subject: [PATCH 4/4] dwl: 0.5 -> 0.6 --- pkgs/by-name/dw/dwl/package.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/dw/dwl/package.nix b/pkgs/by-name/dw/dwl/package.nix index cbeea643d2a6..152d5000c22d 100644 --- a/pkgs/by-name/dw/dwl/package.nix +++ b/pkgs/by-name/dw/dwl/package.nix @@ -38,14 +38,14 @@ assert withCustomConfigH -> (configH != null); stdenv.mkDerivation (finalAttrs: { pname = "dwl"; - version = "0.5"; + version = "0.6"; src = fetchFromGitea { domain = "codeberg.org"; owner = "dwl"; repo = "dwl"; rev = "v${finalAttrs.version}"; - hash = "sha256-U/vqGE1dJKgEGTfPMw02z5KJbZLWY1vwDJWnJxT8urM="; + hash = "sha256-fygUzEi4bgopesvHByfpatkLFYI98qozJOUBNM2t9Mg="; }; nativeBuildInputs = [