XMonad: Difference between revisions
Add a few links |
m →Adding Haskell Modules: fix typo |
||
(One intermediate revision by the same user not shown) | |||
Line 11: | Line 11: | ||
You probably also want to activate the <code>enableContribAndExtras</code> option. | You probably also want to activate the <code>enableContribAndExtras</code> option. | ||
{{file|/etc/nixos/configuration.nix|nix| | |||
<nowiki> | |||
services.xserver.windowManager.xmonad = { | services.xserver.windowManager.xmonad = { | ||
enable = true; | enable = true; | ||
enableContribAndExtras = true; | enableContribAndExtras = true; | ||
}; | }; | ||
</nowiki> | |||
}} | |||
The second options automatically adds the <code>xmonad-contrib</code> and <code>xmonad-extras</code> packages. | The second options automatically adds the <code>xmonad-contrib</code> and <code>xmonad-extras</code> packages. | ||
They are required to use the [https://hackage.haskell.org/package/xmonad-contrib Xmonad Contrib] extensions. | They are required to use the [https://hackage.haskell.org/package/xmonad-contrib Xmonad Contrib] extensions. | ||
=== Adding Haskell Modules === | |||
< | To add additional Haskell modules beyond xmonad-contrib and xmonad-extras, use the <code>extraPackages</code> option | ||
{{file|/etc/nixos/configuration.nix|nix| | |||
<nowiki> | |||
... | |||
services.xserver.windowManager.xmonad = { | |||
... | |||
extraPackages = haskellPackages: [ | |||
haskellPackages.monad-logger | |||
]; | |||
}; | |||
</nowiki> | |||
}} | |||
To add Haskell modules that are not in the Haskell Nix package set, you have to tell ghc where to find them. | |||
For example, you can use the following to add the [https://github.com/Procrat/xmonad-contexts xmonad-contexts] module. | |||
{{file|/etc/nixos/configuration.nix|nix| | |||
<nowiki> | |||
{ config, pkgs, ... }: | |||
let | |||
xmonad-contexts = pkgs.fetchFromGitHub { | |||
owner = "Procrat"; | |||
repo = "xmonad-contexts"; | |||
rev = "SOME_COMMIT_HASH"; # replace with an actual commit for reproducibility | |||
sha256 = "sha256-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; | |||
}; | |||
in { | |||
... | |||
services.xserver.windowManager.xmonad = { | |||
... | |||
ghcArgs = [ | |||
"-hidir /tmp" # place interface files in /tmp, otherwise ghc tries to write them to the nix store | |||
"-odir /tmp" # place object files in /tmp, otherwise ghc tries to write them to the nix store | |||
"-i${xmonad-contexts}" # tell ghc to search in the respective nix store path for the module | |||
]; | |||
}; | |||
} | |||
</nowiki> | |||
}} | |||
or if you are using Flakes | |||
{{file|/etc/nixos/configuration.nix|nix| | |||
<nowiki> | |||
{ xmonad-contexts, ... }: | { xmonad-contexts, ... }: | ||
{ | { | ||
... | ... | ||
services.xserver.windowManager.xmonad = { | services.xserver.windowManager.xmonad = { | ||
... | ... | ||
Line 35: | Line 82: | ||
}; | }; | ||
} | } | ||
</ | </nowiki> | ||
}} | |||
Don't forget to add the module to your inputs: | Don't forget to add the module to your flake inputs: | ||
< | {{file|/etc/nixos/flake.nix|nix| | ||
<nowiki> | |||
inputs.xmonad-contexts = { | inputs.xmonad-contexts = { | ||
url = "github:Procrat/xmonad-contexts"; | url = "github:Procrat/xmonad-contexts"; | ||
flake = false; | flake = false; | ||
}; | }; | ||
</ | </nowiki> | ||
}} | |||
== Configuration == | == Configuration == | ||
<code>$HOME/.xmonad</code> is the default path used for the configuration file. If your configuration is in a different location, give Nix your Xmonad config file like this: | |||
{{file|/etc/nixos/configuration.nix|nix| | |||
<nowiki> | |||
services.xserver.windowManager.xmonad = { | |||
... | |||
config = builtins.readFile ../path/to/xmonad.hs; | |||
}; | |||
</nowiki> | |||
}} | |||
See [https://search.nixos.org/options?query=services.xserver.windowManager.xmonad services.xserver.windowManager.xmonad] for a full list of available options and their descriptions. | |||
services.xserver.windowManager.xmonad. | |||
More information on how to configure Xmonad can be found in the [https://wiki.archlinux.org/title/Xmonad Arch Wiki], and a list of starter configs can be found in the [https://wiki.haskell.org/Xmonad/Config_archive Xmonad Config Archive]. | More information on how to configure Xmonad can be found in the [https://wiki.archlinux.org/title/Xmonad Arch Wiki], and a list of starter configs can be found in the [https://wiki.haskell.org/Xmonad/Config_archive Xmonad Config Archive]. | ||
Line 119: | Line 176: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Developer Environment for XMonad == | |||
When developing modules for XMonad, it can help to install the following packages | When developing modules for XMonad, it can help to install the following packages |