maybe module

This commit is contained in:
2026-03-31 01:05:21 +02:00
parent e5cf8e2e3e
commit 56fa8435c7
5 changed files with 131 additions and 26 deletions

1
.gitignore vendored
View File

@@ -5,3 +5,4 @@ dwl
.ccls-cache
config.h
result
result-man

View File

@@ -103,7 +103,7 @@ LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right
static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
#define MODKEY WLR_MODIFIER_ALT
#define MODKEY WLR_MODIFIER_LOGO
#define TAGKEYS(KEY,SKEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \

View File

@@ -12,20 +12,21 @@
}:
let
system = "x86_64-linux";
patches = [];
pkgs = nixpkgs.legacyPackages.${system};
nativeBuildInputs = with pkgs; [
tinycc
gnumake
installShellFiles
pkg-config
wayland-protocols
wayland-scanner
];
buildInputs = with pkgs; [
wayland-scanner
wlroots
libinput
wayland
libxcb
libxkbcommon
pixman
wayland
wayland-protocols
wlroots_0_19
];
inherit (pkgs) lib;
in
@@ -55,14 +56,19 @@
};
in
{
default = pkgs.callPackage ./package.nix { inherit src buildInputs nativeBuildInputs; };
default = pkgs.callPackage ./package.nix { inherit src buildInputs nativeBuildInputs patches; };
};
overlays = {
default = self.overlays.dwl;
dwl = final: prev: {
inherit (self.packages.${prev.stdenv.hostPlatform.system}) default;
};
default = self.overlays.dwl;
dwl = final: prev: {
inherit (self.packages.${prev.stdenv.hostPlatform.system}) default;
};
};
nixosModules = {
default = self.nixosModules.dwl;
dwl = ./module.nix;
};
};
}

38
module.nix Normal file
View File

@@ -0,0 +1,38 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.dwl;
in
{
options.programs.dwl = {
enable = lib.mkEnableOption "dwl, a simple and hackable wayland compositor";
package = lib.mkPackageOption pkgs "dwl" { };
patches = lib.mkOption {
type = lib.types.array;
default = [ ];
description = "patches for dwl";
};
enableXwayland = lib.mkOption {
type = lib.types.bool;
default = false;
description = "compile with or without xwayland support";
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [
pkgs.callPackage
./package.nix
{
inherit (cfg) patches enableXwayland;
}
];
};
}

View File

@@ -4,24 +4,84 @@
stdenv,
buildInputs,
nativeBuildInputs,
wayland,
testers,
nixosTests,
writeText,
enableXWayland ? false,
withCustomConfigH ? (configH != null),
configH ? "config.h",
patches,
}:
stdenv.mkDerivation {
stdenv.mkDerivation (finalAttrs: {
pname = "dwl";
version = "0.1.0";
inherit src buildInputs nativeBuildInputs;
version = "0.8-dev";
inherit
src
buildInputs
nativeBuildInputs
patches
;
makeFlags = [
outputs = [
"out"
"man"
];
meta = {
description = "dwm for Wayland";
homepage = "https://codeberg.org/dwl/dwl";
platforms = lib.platforms.linux;
mainProgram = "dwl";
postPatch =
let
configFile =
if lib.isDerivation configH || builtins.isPath configH then
configH
else
writeText "config.h" configH;
in
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"
]
++ lib.optionals enableXWayland [
''XWAYLAND="-DXWAYLAND"''
''XLIBS="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";
};
basic = nixosTests.dwl;
};
};
installPhase = ''
mkdir -p $out/
cp dwl $out/
'';
}
meta = {
homepage = "https://codeberg.org/dwl/dwl";
changelog = "https://codeberg.org/dwl/dwl/src/branch/${finalAttrs.version}/CHANGELOG.md";
description = "Dynamic window manager for Wayland";
longDescription = ''
dwl is a compact, hackable compositor for Wayland based on wlroots. It is
intended to fill the same space in the Wayland world that dwm does in X11,
primarily in terms of philosophy, and secondarily in terms of
functionality. Like dwm, dwl is:
- Easy to understand, hack on, and extend with patches
- One C source file (or a very small number) configurable via config.h
- Tied to as few external dependencies as possible
'';
license = lib.licenses.gpl3Only;
maintainers = [ ];
inherit (wayland.meta) platforms;
mainProgram = "dwl";
};
})