Use latest version of Xmonad (0.17.0)?

A recent release of the window manager, xmonad, was added to nixpkgs. The haskellPackage is called ’ xmonad_0_17_0’. There is also a popular companion package that was updated, called ‘xmonad-contrib_0_17_0’. The problem is I am not sure how to configure my NixOS system to use the new version instead of the vanilla ‘xmonad’. As for the time being, I am using the vanilla version of xmonad (0.15.0) and the ‘xmonad-contrib’ without issue.

Some of the things I tried:

  • Using home-manager, I tried to to reference the updated companion package, hoping it would magically pull in the updated xmonad. The relevant section of my home-manager configuration is:

{
enable = true;
extraPackages = haskellPackages: [
haskellPackages.xmonad-contrib_0_17_0
];
enableContribAndExtras = true;
config = ./xmonad.hs;
}

This resulted in the error stating that I do not have the correct dependency version:

Setup: Encountered missing or private dependencies:
xmonad >=0.16.99999 && <0.18

I also attempted to make an overlay, thinking that I can somehow mask the vanilla ‘xmonad’ package with the new one. So I put this in my home-manager config:

nixpkgs.overlays = [
(self: super: {
xmonad = pkgs.haskellPackages.xmonad_0_17_0;
})
];

This did not change the error or outcome in any way.

I am new to nix/NixOS, so I am not sure how to correctly leverage the overlay system or the home-manager module to inject the new version of xmonad. I am also willing to move the xmonad out of home-manager and into the system NixOS module if that is what it takes to upgrade.

It also seems like a relevant question was asked in the nixpkgs github but there was no answer: Xmonad is out of date · Issue #145730 · NixOS/nixpkgs · GitHub

Thanks in advance for any insight this community can provide.

1 Like

I don’t use home-manager, so I simply edited my NixOS config like so:

    # XMonad
    windowManager.xmonad = {
      enable = true;
      enableContribAndExtras = true;
      extraPackages = haskellPackages: [
        haskellPackages.xmonad_0_17_0
        haskellPackages.xmonad-contrib_0_17_0
        haskellPackages.xmonad-extras_0_17_0
      ];
    };

and unfortunately I got a similar error. Without the _0_17_0, everything works just fine. I would expect the changes I made to work, so I think there’s a problem. I see that someone just posted a workaround on Xmonad is out of date · Issue #145730 · NixOS/nixpkgs · GitHub, but I haven’t tried it yet.

Preprocessing library for xmonad-extras-0.17.0..
Using Parsec parser
Configuring xmonad-contrib-0.17.0...
CallStack (from HasCallStack):
  $, called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:1024:20 in Cabal-3.2.1.0:Distribution.Simple.Configure
  configureFinalizedPackage, called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:477:12 in Cabal-3.2.1.0:Distribution.Simple.Configure
  configure, called at libraries/Cabal/Cabal/Distribution/Simple.hs:625:20 in Cabal-3.2.1.0:Distribution.Simple
  confHook, called at libraries/Cabal/Cabal/Distribution/Simple/UserHooks.hs:65:5 in Cabal-3.2.1.0:Distribution.Simple.UserHooks
  configureAction, called at libraries/Cabal/Cabal/Distribution/Simple.hs:180:19 in Cabal-3.2.1.0:Distribution.Simple
  defaultMainHelper, called at libraries/Cabal/Cabal/Distribution/Simple.hs:116:27 in Cabal-3.2.1.0:Distribution.Simple
  defaultMain, called at Setup.lhs:3:10 in main:Main
Setup: Encountered missing or private dependencies:
xmonad >=0.16.99999 && <0.18

error: builder for '/nix/store/n0fy67liark5i3gfps1ws7qfn5wabjf6-xmonad-contrib-0.17.0.drv' failed with exit code 1
error (ignored): error: cannot unlink '/tmp/nix-build-xmonad-extras-0.17.0.drv-0': Directory not empty
error: 1 dependencies of derivation '/nix/store/y22g17g7gyf6ar6gj258vbf6fzbwh5fh-ghc-8.10.7-with-packages.drv' failed to build
error: 1 dependencies of derivation '/nix/store/39v6f7hgnixpqgk2vv1z718rdng8m70g-xmonad-with-packages-8.10.7.drv' failed to build
error: 1 dependencies of derivation '/nix/store/wdcq0v7iw70gz6z137lpny4rbhv89w9y-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/85gh1m8q5c0ymyc5697s5pramay22hij-xsession.drv' failed to build
error: 1 dependencies of derivation '/nix/store/3nzrvlvga65fd8qwf612sj6b63zp8mfp-nixos-system-wombat11k-21.11pre332033.715f6341195.drv' failed to build
1 Like

xmonad-contrib_0_17_0 and xmonad-extras_0_17_0 currently don’t work in nixpkgs, but should be fixed in a few days or so.

Still, your approach with extraPackages won’t work, I’m pretty sure. As the name indicates, this is intended to add extra packages to the build environment for an XMonad configuration and the xmonad package itself will be added unconditionally, so with your configuration snippet, conflicting xmonad versions would be included likely causing some kind of trouble.

The module will need to be changed to make it easier changing the xmonad package used (i. e. without an overlay). For now using an overlay is the only robust solution, is my estimate.

2 Likes

Thanks for the responses. I think I will wait until the module in NixOS or home-manager is modified to accommodate. The reason being is that even with the following overlays, I get further along but there is an xmonad configuration compilation issue that the home-manager xmonad module may have to take into account.

Overlays:

nixpkgs.overlays = [
  (self: super: {
    haskellPackages = super.haskellPackages.override {
      overrides = hself: hsuper: {
        xmonad = hsuper.xmonad_0_17_0;
        xmonad-contrib = hsuper.xmonad-contrib_0_17_0;
        xmonad-extras = hsuper.xmonad-extras_0_17_0;
      };
    };
  })
];

New Error:

XMonad will use ghc to recompile, because neither “/build/xmonad-config/build” nor “/build/xmonad-config/stack.yaml” exists.
XMonad recompiling (forced).
xmonad: ghc: runProc: exec: does not exist (No such file or directory)

I will revisit this once Stackage adds the new xmonad version into LTS as the github issue mentioned.

1 Like

I got around this error by applying a patch that makes xmonad use the ghc executable pointed to by NIX_GHC, more or less an equivalent of nixpkgs/pkgs/development/haskell-modules/patches/xmonad-nix.patch but not sure how proper Haskell this is.

diff --git a/src/XMonad/Core.hs b/src/XMonad/Core.hs
index 46a0939..92af53d 100644
--- a/src/XMonad/Core.hs
+++ b/src/XMonad/Core.hs
@@ -46,6 +46,7 @@ import Data.Traversable (for)
 import Data.Time.Clock (UTCTime)
 import Data.Default.Class
 import Data.List (isInfixOf)
+import System.Environment (lookupEnv)
 import System.FilePath
 import System.IO
 import System.Info
@@ -458,7 +459,8 @@ xfork x = io . forkProcess . finally nullStdin $ do
 -- | Use @xmessage@ to show information to the user.
 xmessage :: MonadIO m => String -> m ()
 xmessage msg = void . xfork $ do
-    executeFile "xmessage" True
+    xmessageBin <- fromMaybe "xmessage" <$> liftIO (lookupEnv "XMONAD_XMESSAGE")
+    executeFile xmessageBin True
         [ "-default", "okay"
         , "-xrm", "*international:true"
         , "-xrm", "*fontSet:-*-fixed-medium-r-normal-*-18-*-*-*-*-*-*-*,-*-fixed-*-*-*-*-18-*-*-*-*-*-*-*,-*-*-*-*-*-*-18-*-*-*-*-*-*-*"
@@ -654,8 +656,9 @@ compile dirs method =
         bracket (openFile (errFileName dirs) WriteMode) hClose $ \err -> do
             let run = runProc (cfgDir dirs) err
             case method of
-                CompileGhc ->
-                    run "ghc" ghcArgs
+                CompileGhc -> do
+                    ghc <- fromMaybe "ghc" <$> (lookupEnv "NIX_GHC")
+                    run ghc ghcArgs
                 CompileStackGhc stackYaml ->
                     run "stack" ["build", "--silent", "--stack-yaml", stackYaml] .&&.
                     run "stack" ("ghc" : "--stack-yaml" : stackYaml : "--" : ghcArgs)

Overlay:

self: super:
{
  haskellPackages = super.haskellPackages.override (old: {
    overrides = self.lib.composeExtensions (old.overrides or (_: _: {}))
      (
        hself: hsuper: {
          xmonad = super.haskell.lib.appendPatch hsuper.xmonad_0_17_0 ./xmonad-nix.patch;
          xmonad-contrib = hsuper.xmonad-contrib_0_17_0;
          xmonad-extras = hsuper.xmonad-extras_0_17_0;
        }
      );
  });
}
1 Like

Thanks. I will consider this option if I become too impatient waiting for the module to be refactored. Good to know that there are options.

When does th

When does this error occur? When starting XMonad?

I believe the error occurs when the home-manager module tries to run the recompile of the xmonad configuration: home-manager/xmonad.nix at 3ec7f6fb43ff77cff429aba1a2541d28cc44d37c · nix-community/home-manager · GitHub

Indeed, seems like the newer xmonad attribute is not patched to know about NIX_GHC which is used by the xmonad wrapper. This patch currently lives at pkgs/development/haskell-modules/patches/xmonad-nix.patch in nixpkgs.

pkgs/development/haskell-modules/patches/xmonad-nix.patch should be updated for 0.17.0.

Excellent, much better than my workaround here: xmonad: add libFiles option by markusscherer · Pull Request #1765 · nix-community/home-manager · GitHub

1 Like

There is nothing to change (1) in the NixOS/home-manager module. The reason it doesn’t work is that it relies on behaviour that gets patched into the xmonad derivation in nixpkgs, which is missing when you use xmonad_0_17_0/an upstream version.

(1): Ok, this is not entirely true, seeing as they changed the output location of the recompile binary upstream, but my point still stands.

1 Like

@ento I took the liberty of submitting your patch for PR into nixpkgs: xmonad_0_17_0: add @ento's updated xmonad nix compatibility patch by NickHu · Pull Request #148135 · NixOS/nixpkgs · GitHub. I hope you don’t mind!

Combined with xmonad: add support for v0.17.0 by NickHu · Pull Request #2522 · nix-community/home-manager · GitHub this will make using the new version of xmonad as simple as overlaying the *_0_17_0 attributes over the existing ones, and everything ought to more-or-less just work.

Appreciated! Fewer home-grown patches in my home-manager config the better.

Fixes for the 0.17.0 packages plus @ento’s patch have been merged as part of #148075 and will hit channels soon hopefully.

As such a trivial overlay such as

self: super: {
  xmonad = self.xmonad_0_17_0;
  xmonad-contrib = self.xmonad_0_17_0;
  xmonad-extras = self.xmonad-extras_0_17_0;
}

would be expected to work fine. This still leaves some convenience to be desired, but I’d leave improving this to the NixOS modules’ authors, since I’m not involved with that at all (and don’t even use XMonad for that matter).

Hosted by Flying Circus.