diff options
author | ivanbrennan <ivan.brennan@gmail.com> | 2022-01-18 00:04:15 -0500 |
---|---|---|
committer | ivanbrennan <ivan.brennan@gmail.com> | 2022-01-18 00:04:15 -0500 |
commit | a3ea1bc599f5c7dcea950b40c05f1abd3e5cd191 (patch) | |
tree | c8240de31224db226ba37e002d19e86d31383f1d /nixos/modules/services/x11 | |
parent | 71358dd07098a8f51cde54be4baa06125c9c0d80 (diff) | |
download | nixpkgs-a3ea1bc599f5c7dcea950b40c05f1abd3e5cd191.tar nixpkgs-a3ea1bc599f5c7dcea950b40c05f1abd3e5cd191.tar.gz nixpkgs-a3ea1bc599f5c7dcea950b40c05f1abd3e5cd191.tar.bz2 nixpkgs-a3ea1bc599f5c7dcea950b40c05f1abd3e5cd191.tar.lz nixpkgs-a3ea1bc599f5c7dcea950b40c05f1abd3e5cd191.tar.xz nixpkgs-a3ea1bc599f5c7dcea950b40c05f1abd3e5cd191.tar.zst nixpkgs-a3ea1bc599f5c7dcea950b40c05f1abd3e5cd191.zip |
nixos/xmonad: enableConfiguredRecompile
Commit 9a5b5d9fe858f33f7f5ce0870be2b8a38516a1d4 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, commit b69d9d3c23311ce8b8512a7032600a5f8d1595ca 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.
Diffstat (limited to 'nixos/modules/services/x11')
-rw-r--r-- | nixos/modules/services/x11/window-managers/xmonad.nix | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/nixos/modules/services/x11/window-managers/xmonad.nix b/nixos/modules/services/x11/window-managers/xmonad.nix index ecad411ff68..4ac11541bea 100644 --- a/nixos/modules/services/x11/window-managers/xmonad.nix +++ b/nixos/modules/services/x11/window-managers/xmonad.nix @@ -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; |