From b7bb524f04c9e31c19d19086d1af0eda7d2f4ca8 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Tue, 3 Feb 2015 01:05:23 +0300 Subject: nixos/xmonad: move to haskell-ng and make a wrapper --- .../window-managers/xmonad/default.nix | 2 +- .../window-managers/xmonad/wrapper.nix | 22 +++++++++++ .../xmonad/xmonad_ghc_var_0.11.patch | 44 ---------------------- .../haskell-modules/configuration-common.nix | 3 ++ pkgs/development/haskell-modules/xmonad-nix.patch | 44 ++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 5 +++ 6 files changed, 75 insertions(+), 45 deletions(-) create mode 100644 pkgs/applications/window-managers/xmonad/wrapper.nix delete mode 100644 pkgs/applications/window-managers/xmonad/xmonad_ghc_var_0.11.patch create mode 100644 pkgs/development/haskell-modules/xmonad-nix.patch (limited to 'pkgs') 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/applications/window-managers/xmonad/xmonad_ghc_var_0.11.patch b/pkgs/applications/window-managers/xmonad/xmonad_ghc_var_0.11.patch deleted file mode 100644 index f0785773cc1..00000000000 --- a/pkgs/applications/window-managers/xmonad/xmonad_ghc_var_0.11.patch +++ /dev/null @@ -1,44 +0,0 @@ ---- xmonad-0.11/XMonad/Core.hs 2013-01-01 01:31:47.000000000 +0000 -+++ new-xmonad/XMonad/Core.hs 2013-12-23 17:36:40.862146910 +0000 -@@ -47,6 +47,7 @@ - import System.Process - import System.Directory - import System.Exit -+import System.Environment (lookupEnv) - import Graphics.X11.Xlib - import Graphics.X11.Xlib.Extras (Event) - import Data.Typeable -@@ -452,6 +453,7 @@ - err = base ++ ".errors" - src = base ++ ".hs" - lib = dir "lib" -+ ghc <- fromMaybe "ghc" <$> liftIO (lookupEnv "XMONAD_GHC") - libTs <- mapM getModTime . Prelude.filter isSource =<< allFiles lib - srcT <- getModTime src - binT <- getModTime bin -@@ -460,7 +462,7 @@ - -- temporarily disable SIGCHLD ignoring: - uninstallSignalHandlers - status <- bracket (openFile err WriteMode) hClose $ \h -> -- waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-ilib", "-fforce-recomp", "-v0", "-o",binn] (Just dir) -+ waitForProcess =<< runProcess ghc ["--make", "xmonad.hs", "-i", "-ilib", "-fforce-recomp", "-v0", "-o",binn] (Just dir) - Nothing Nothing Nothing (Just h) - - -- re-enable SIGCHLD: -@@ -469,6 +471,7 @@ - -- now, if it fails, run xmessage to let the user know: - when (status /= ExitSuccess) $ do - ghcErr <- readFile err -+ xmessage <- fromMaybe "xmessage" <$> liftIO (lookupEnv "XMONAD_XMESSAGE") - let msg = unlines $ - ["Error detected while loading xmonad configuration file: " ++ src] - ++ lines (if null ghcErr then show status else ghcErr) -@@ -476,7 +479,7 @@ - -- nb, the ordering of printing, then forking, is crucial due to - -- lazy evaluation - hPutStrLn stderr msg -- forkProcess $ executeFile "xmessage" True ["-default", "okay", msg] Nothing -+ forkProcess $ executeFile xmessage True ["-default", "okay", msg] Nothing - return () - return (status == ExitSuccess) - else return True 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/development/haskell-modules/xmonad-nix.patch b/pkgs/development/haskell-modules/xmonad-nix.patch new file mode 100644 index 00000000000..f0785773cc1 --- /dev/null +++ b/pkgs/development/haskell-modules/xmonad-nix.patch @@ -0,0 +1,44 @@ +--- xmonad-0.11/XMonad/Core.hs 2013-01-01 01:31:47.000000000 +0000 ++++ new-xmonad/XMonad/Core.hs 2013-12-23 17:36:40.862146910 +0000 +@@ -47,6 +47,7 @@ + import System.Process + import System.Directory + import System.Exit ++import System.Environment (lookupEnv) + import Graphics.X11.Xlib + import Graphics.X11.Xlib.Extras (Event) + import Data.Typeable +@@ -452,6 +453,7 @@ + err = base ++ ".errors" + src = base ++ ".hs" + lib = dir "lib" ++ ghc <- fromMaybe "ghc" <$> liftIO (lookupEnv "XMONAD_GHC") + libTs <- mapM getModTime . Prelude.filter isSource =<< allFiles lib + srcT <- getModTime src + binT <- getModTime bin +@@ -460,7 +462,7 @@ + -- temporarily disable SIGCHLD ignoring: + uninstallSignalHandlers + status <- bracket (openFile err WriteMode) hClose $ \h -> +- waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-ilib", "-fforce-recomp", "-v0", "-o",binn] (Just dir) ++ waitForProcess =<< runProcess ghc ["--make", "xmonad.hs", "-i", "-ilib", "-fforce-recomp", "-v0", "-o",binn] (Just dir) + Nothing Nothing Nothing (Just h) + + -- re-enable SIGCHLD: +@@ -469,6 +471,7 @@ + -- now, if it fails, run xmessage to let the user know: + when (status /= ExitSuccess) $ do + ghcErr <- readFile err ++ xmessage <- fromMaybe "xmessage" <$> liftIO (lookupEnv "XMONAD_XMESSAGE") + let msg = unlines $ + ["Error detected while loading xmonad configuration file: " ++ src] + ++ lines (if null ghcErr then show status else ghcErr) +@@ -476,7 +479,7 @@ + -- nb, the ordering of printing, then forking, is crucial due to + -- lazy evaluation + hPutStrLn stderr msg +- forkProcess $ executeFile "xmessage" True ["-default", "okay", msg] Nothing ++ forkProcess $ executeFile xmessage True ["-default", "okay", msg] Nothing + return () + return (status == ExitSuccess) + else return True diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 04a592a7e56..1fea8b56ade 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11805,6 +11805,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; -- cgit 1.4.1