xmonad: Added buildScript and buildScriptPackages

If you need to change ghc args, or maybe want to use cabal or stack to
build xmonad, a way of doing this is write a script called build which
overrides xmonad's default build behaviour.

This patch adds two extra (optional) config options to xmonad:
- buildScript, a path to said build script
- buildScriptPackages, any additional dependencies it may need
This commit is contained in:
James Hobson
2025-12-17 22:30:01 +01:00
committed by Matthieu Coudron
parent 4e8b7bef66
commit 0d3183953c

View File

@@ -19,6 +19,15 @@ let
self.xmonad-extras
];
};
ghc-builder = cfg.haskellPackages.ghcWithPackages (
self:
[ self.xmonad ]
++ (cfg.extraPackages self)
++ lib.optionals cfg.enableContribAndExtras [
self.xmonad-contrib
self.xmonad-extras
]
);
in
{
@@ -104,6 +113,20 @@ in
contents of the files.
'';
};
buildScript = mkOption {
type = types.nullOr types.path;
default = null;
description = ''
Build script for your xmonad configuration.
'';
};
buildScriptPackages = mkOption {
type = types.listOf types.package;
default = [ ];
description = ''
Extra packages needed to run the build script.
'';
};
};
};
@@ -119,7 +142,11 @@ in
xmonadBin = "${
pkgs.runCommandLocal "xmonad-compile"
{
nativeBuildInputs = [ xmonad ];
nativeBuildInputs = [
xmonad
ghc-builder
]
++ cfg.buildScriptPackages;
}
''
mkdir -p $out/bin
@@ -131,7 +158,9 @@ in
mkdir -p "$XMONAD_CONFIG_DIR/lib" "$XMONAD_CACHE_DIR" "$XMONAD_DATA_DIR"
cp ${cfg.config} xmonad-config/xmonad.hs
${lib.optionalString (cfg.buildScript != null) ''
cp ${cfg.buildScript} xmonad-config/build && chmod +x xmonad-config/build
''}
declare -A libFiles
libFiles=(${
lib.concatStringsSep " " (lib.mapAttrsToList (name: value: "['${name}']='${value}'") cfg.libFiles)