2017-10-31 14:05:54 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2017-09-29 00:15:57 +02:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2017-10-31 14:05:54 +01:00
|
|
|
cfg = config.xsession.windowManager.xmonad;
|
2017-09-29 00:15:57 +02:00
|
|
|
|
2017-12-02 19:15:13 +01:00
|
|
|
dag = config.lib.dag;
|
|
|
|
|
2017-09-29 00:15:57 +02:00
|
|
|
xmonad = pkgs.xmonad-with-packages.override {
|
|
|
|
ghcWithPackages = cfg.haskellPackages.ghcWithPackages;
|
|
|
|
packages = self:
|
|
|
|
cfg.extraPackages self
|
|
|
|
++ optionals cfg.enableContribAndExtras [
|
|
|
|
self.xmonad-contrib self.xmonad-extras
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
2017-10-31 14:05:54 +01:00
|
|
|
xsession.windowManager.xmonad = {
|
2017-09-29 00:15:57 +02:00
|
|
|
enable = mkEnableOption "xmonad window manager";
|
|
|
|
|
|
|
|
haskellPackages = mkOption {
|
|
|
|
default = pkgs.haskellPackages;
|
|
|
|
defaultText = "pkgs.haskellPackages";
|
|
|
|
example = literalExample "pkgs.haskell.packages.ghc784";
|
|
|
|
description = ''
|
|
|
|
The <varname>haskellPackages</varname> used to build xmonad
|
|
|
|
and other packages. This can be used to change the GHC
|
|
|
|
version used to build xmonad and the packages listed in
|
|
|
|
<varname>extraPackages</varname>.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraPackages = mkOption {
|
|
|
|
default = self: [];
|
|
|
|
defaultText = "self: []";
|
|
|
|
example = literalExample ''
|
|
|
|
haskellPackages: [
|
|
|
|
haskellPackages.xmonad-contrib
|
|
|
|
haskellPackages.monad-logger
|
|
|
|
]
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Extra packages available to GHC when rebuilding xmonad. The
|
|
|
|
value must be a function which receives the attribute set
|
|
|
|
defined in <varname>haskellPackages</varname> as the sole
|
|
|
|
argument.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enableContribAndExtras = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
description = "Enable xmonad-{contrib,extras} in xmonad.";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
|
|
|
example = literalExample ''
|
|
|
|
pkgs.writeText "xmonad.hs" '''
|
|
|
|
import XMonad
|
|
|
|
main = xmonad defaultConfig
|
|
|
|
{ terminal = "urxvt"
|
|
|
|
, modMask = mod4Mask
|
|
|
|
, borderWidth = 3
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
The configuration file to be used for xmonad. This must be
|
|
|
|
an absolute path or <literal>null</literal> in which case
|
|
|
|
<filename>~/.xmonad/xmonad.hs</filename> will not be managed
|
|
|
|
by Home Manager.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-10-31 14:05:54 +01:00
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
|
|
{
|
2017-12-08 00:01:50 +01:00
|
|
|
home.packages = [ (lowPrio xmonad) ];
|
2017-10-31 14:05:54 +01:00
|
|
|
xsession.windowManager.command = "${xmonad}/bin/xmonad";
|
|
|
|
}
|
|
|
|
|
|
|
|
(mkIf (cfg.config != null) {
|
|
|
|
home.file.".xmonad/xmonad.hs".source = cfg.config;
|
2018-02-17 00:32:29 +01:00
|
|
|
home.file.".xmonad/xmonad.hs".onChange = ''
|
|
|
|
echo "Recompiling xmonad"
|
|
|
|
$DRY_RUN_CMD ${config.xsession.windowManager.command} --recompile
|
|
|
|
|
|
|
|
# Attempt to restart xmonad if X is running.
|
|
|
|
if [[ -v DISPLAY ]] ; then
|
|
|
|
echo "Restarting xmonad"
|
|
|
|
$DRY_RUN_CMD ${config.xsession.windowManager.command} --restart
|
2017-10-31 14:05:54 +01:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
]);
|
2017-09-29 00:15:57 +02:00
|
|
|
}
|