diff --git a/nixos/modules/services/x11/window-managers/xmonad.nix b/nixos/modules/services/x11/window-managers/xmonad.nix index 74acfc21975..c922ca7848d 100644 --- a/nixos/modules/services/x11/window-managers/xmonad.nix +++ b/nixos/modules/services/x11/window-managers/xmonad.nix @@ -3,11 +3,12 @@ let inherit (lib) mkOption mkIf optionals literalExample; cfg = config.services.xserver.windowManager.xmonad; - xmonadEnv = cfg.haskellPackages.ghcWithPackages(self: [ - self.xmonad - ] ++ optionals cfg.enableContribAndExtras [ self.xmonadContrib self.xmonadExtras] - ++ optionals (cfg.extraPackages != null) (cfg.extraPackages self)); - xmessage = pkgs.xlibs.xmessage; + xmonad = pkgs.xmonad-with-packages.override { + ghcWithPackages = cfg.haskellPackages.ghcWithPackages; + packages = self: cfg.extraPackages self ++ + optionals cfg.enableContribAndExtras + [ self.xmonad-contrib self.xmonad-extras ]; + }; in { options = { @@ -19,9 +20,9 @@ in }; haskellPackages = mkOption { - default = pkgs.haskellPackages; - defaultText = "pkgs.haskellPackages"; - example = literalExample "pkgs.haskellPackages_ghc701"; + default = pkgs.haskellngPackages; + defaultText = "pkgs.haskellngPackages"; + example = literalExample "pkgs.haskell-ng.packages.ghc784"; description = '' haskellPackages used to build Xmonad and other packages. This can be used to change the GHC version used to build @@ -31,17 +32,17 @@ in }; extraPackages = mkOption { - default = null; + default = self: []; example = literalExample '' haskellPackages: [ - haskellPackages.xmonadContrib - haskellPackages.monadLogger + haskellPackages.xmonad-contrib + haskellPackages.monad-logger ] ''; description = '' Extra packages available to ghc when rebuilding Xmonad. The value must be a function which receives the attrset defined - in haskellpackages as the sole argument. + in haskellPackages as the sole argument. ''; }; @@ -58,12 +59,12 @@ in session = [{ name = "xmonad"; start = '' - XMONAD_GHC=${xmonadEnv}/bin/ghc XMONAD_XMESSAGE=${xmessage}/bin/xmessage xmonad & + ${xmonad}/bin/xmonad & waitPID=$! ''; }]; }; - environment.systemPackages = [ cfg.haskellPackages.xmonad ]; + environment.systemPackages = [ xmonad ]; }; } diff --git a/pkgs/applications/window-managers/xmonad/default.nix b/pkgs/applications/window-managers/xmonad/default.nix index 08b85a5530f..16b0ac365a2 100644 --- a/pkgs/applications/window-managers/xmonad/default.nix +++ b/pkgs/applications/window-managers/xmonad/default.nix @@ -18,7 +18,7 @@ cabal.mkDerivation (self: { ''; patches = [ # Patch to make xmonad use XMONAD_{GHC,XMESSAGE} (if available). - ./xmonad_ghc_var_0.11.patch + ../../../development/haskell-modules/xmonad-nix.patch ]; meta = { homepage = "http://xmonad.org"; diff --git a/pkgs/applications/window-managers/xmonad/wrapper.nix b/pkgs/applications/window-managers/xmonad/wrapper.nix new file mode 100644 index 00000000000..cddaeb5f799 --- /dev/null +++ b/pkgs/applications/window-managers/xmonad/wrapper.nix @@ -0,0 +1,22 @@ +{ stdenv, buildEnv, ghcWithPackages, xmessage, makeWrapper, packages }: + +let +xmonadEnv = ghcWithPackages (self: [ self.xmonad ] ++ packages self); +drv = buildEnv { + name = "xmonad-with-packages"; + + paths = [ xmonadEnv ]; + + postBuild = '' + # TODO: This could be avoided if buildEnv could be forced to create all directories + rm $out/bin + mkdir $out/bin + for i in ${xmonadEnv}/bin/*; do + ln -s $i $out/bin + done + wrapProgram $out/bin/xmonad \ + --set XMONAD_GHC "${xmonadEnv}/bin/ghc" \ + --set XMONAD_XMESSAGE "${xmessage}/bin/xmessage" + ''; + }; +in stdenv.lib.overrideDerivation drv (x : { buildInputs = x.buildInputs ++ [ makeWrapper ]; }) diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index ff4d163519a..67384e321d5 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -409,6 +409,9 @@ self: super: { # https://github.com/seagreen/hjsonschema/issues/4 hjsonschema = dontCheck super.hjsonschema; + # Nix-specific workaround + xmonad = appendPatch super.xmonad ./xmonad-nix.patch; + } // { # Not on Hackage. diff --git a/pkgs/applications/window-managers/xmonad/xmonad_ghc_var_0.11.patch b/pkgs/development/haskell-modules/xmonad-nix.patch similarity index 100% rename from pkgs/applications/window-managers/xmonad/xmonad_ghc_var_0.11.patch rename to pkgs/development/haskell-modules/xmonad-nix.patch diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d9a388f7425..7a5be2a849d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11812,6 +11812,11 @@ let xkb_switch = callPackage ../tools/X11/xkb-switch { }; + xmonad-with-packages = callPackage ../applications/window-managers/xmonad/wrapper.nix { + ghcWithPackages = haskellngPackages.ghcWithPackages; + packages = self: []; + }; + xmonad_log_applet_gnome2 = callPackage ../applications/window-managers/xmonad-log-applet { desktopSupport = "gnome2"; inherit (xfce) libxfce4util xfce4panel;