Merge pull request #5025 from abbradar/xmonad-wrapper
nixos/xmonad: make a wrapper
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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 ]; })
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user