mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 07:13:23 +01:00
nixos/xmonad: enableConfiguredRecompile
Commit9a5b5d9fe8
added Haskell dependencies (GHC and packages) to the xmonad binary's environment even if xmonad had been preconfigured (via the "config" option). The intent was to enable one-off recompiling using a local config file (e.g. ~/.config/xmonad/xmonad.hs), so the user can get quick feedback while developing their config. While this works, it may not be a common use-case, and it requires some careful crafting in xmonad.hs itself. On top of that, it significantly increases the size of the closure. Given all that, commitb69d9d3c23
removed GHC and packages from the binary's environment. But there are still those among us who want to be able to recompile from a preconfigured xmonad, so let's provide a way to opt-into configured recompilation.
This commit is contained in:
parent
71358dd070
commit
a3ea1bc599
1 changed files with 21 additions and 6 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
with lib;
|
||||
let
|
||||
inherit (lib) mkOption mkIf optionals literalExpression;
|
||||
inherit (lib) mkOption mkIf optionals literalExpression optionalString;
|
||||
cfg = config.services.xserver.windowManager.xmonad;
|
||||
|
||||
ghcWithPackages = cfg.haskellPackages.ghcWithPackages;
|
||||
|
@ -26,11 +26,14 @@ let
|
|||
in
|
||||
pkgs.runCommandLocal "xmonad" {
|
||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||
} ''
|
||||
} (''
|
||||
install -D ${xmonadEnv}/share/man/man1/xmonad.1.gz $out/share/man/man1/xmonad.1.gz
|
||||
makeWrapper ${configured}/bin/xmonad $out/bin/xmonad \
|
||||
'' + optionalString cfg.enableConfiguredRecompile ''
|
||||
--set NIX_GHC "${xmonadEnv}/bin/ghc" \
|
||||
'' + ''
|
||||
--set XMONAD_XMESSAGE "${pkgs.xorg.xmessage}/bin/xmessage"
|
||||
'';
|
||||
'');
|
||||
|
||||
xmonad = if (cfg.config != null) then xmonad-config else xmonad-vanilla;
|
||||
in {
|
||||
|
@ -95,12 +98,14 @@ in {
|
|||
xmonad from PATH. This allows e.g. switching to the new xmonad binary
|
||||
after rebuilding your system with nixos-rebuild.
|
||||
For the same reason, ghc is not added to the environment when this
|
||||
option is set.
|
||||
option is set, unless <option>enableConfiguredRecompile</option> is
|
||||
set to <literal>true</literal>.
|
||||
|
||||
If you actually want to run xmonad with a config specified here, but
|
||||
also be able to recompile and restart it from a copy of that source in
|
||||
$HOME/.xmonad on the fly, you will have to implement that yourself
|
||||
using something like "compileRestart" from the example.
|
||||
$HOME/.xmonad on the fly, set <option>enableConfiguredRecompile</option>
|
||||
to <literal>true</literal> and implement something like "compileRestart"
|
||||
from the example.
|
||||
This should allow you to switch at will between the local xmonad and
|
||||
the one NixOS puts in your PATH.
|
||||
'';
|
||||
|
@ -135,6 +140,16 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
enableConfiguredRecompile = mkOption {
|
||||
default = false;
|
||||
type = lib.types.bool;
|
||||
description = ''
|
||||
Enable recompilation even if <option>config</option> is set to a
|
||||
non-null value. This adds the necessary Haskell dependencies (GHC with
|
||||
packages) to the xmonad binary's environment.
|
||||
'';
|
||||
};
|
||||
|
||||
xmonadCliArgs = mkOption {
|
||||
default = [];
|
||||
type = with lib.types; listOf str;
|
||||
|
|
Loading…
Reference in a new issue