XMonad

From NixOS Wiki
Revision as of 15:59, 2 October 2022 by imported>Zach-hill (Added to "Window managers" and "Applications" categories)

xmonad is a tiling window manager for X. Windows are arranged automatically to tile the screen without gaps or overlap, maximizing screen use. Window manager features are accessible from the keyboard: a mouse is optional.

xmonad is written, configured and extensible in Haskell. Custom layout algorithms, key bindings and other extensions may be written by the user in configuration files.

Layouts are applied dynamically, and different layouts may be used on each workspace. Xinerama is fully supported, allowing windows to be tiled on several physical screens.

Installation

/etc/nixos/configuration.nix
services.xserver.windowManager.xmonad.enable = true;

Configuration

Configuring XMonad with IDE support

To edit XMonad configuration with IDE support, see https://www.srid.ca/xmonad-conf-ide

Another way to set up lsp support

Previous way to set up lsp support didn't work for me. This post helped:


if setting up xmonad with extra packages:

~/.config/home-config.nix
e.g:
windowManager = {
  xmonad = {
    enable = true;
    enableContribAndExtras = true;
    extraPackages = haskellPackages: [
      haskellPackages.dbus
      haskellPackages.List
      haskellPackages.monad-logger
      haskellPackages.xmonad
    ];
  };
};

having ghc and other things for the lsp server in the system:

~/.config/home-config.nix
    home.packages = with pkgs; [
      haskellPackages.haskell-language-server
      haskellPackages.hoogle
      cabal-install
      stack
    ]

(but I'm not sure whether all of those are required, maybe only one of cabal \ stack?)

creating project around `xmonad.hs` file

~/.config/xmonad/hie-bios.sh
echo "xmonad" >> $HIE_BIOS_OUTPUT
~/.config/xmonad/hie.yaml
cradle:
  bios:
    program: "./hie-bios.sh"
    with-ghc: "/nix/store/waa0dlvlszwbplrz5c7j674ab6v1n5wi-ghc-8.8.4-with-packages/bin/ghc"

The "with-ghc" should be ghc that's in the "ghc-with-packages" dependency of the "xmonad-with-packages" It can be easily found with "nix-tree" utili, get with "nix-shell -p nix-tree" this shows dependencies between packages on the machine, "/" is for searching for "with-packages" see the store path in the bottom of the screen

to check what are the problems

I try to manually run "haskell-language-server" in the directory with `xmonad.hs`, `hie.yaml` and `hie-bios.sh` when there are no errors, my editor also successfully starts lsp