nixpkgs/pkgs/development/haskell-modules/patches/xmonad_0_17_0-nix.patch
sternenseemann 531ff521d4 nixos/xmonad: rename NIX_GHC env var to XMONAD_GHC
Upstream XMonad was using our xmonad patch file for their flake build to
support our nixos module. This would of course break the build upstream
if the version we patched and their master branch diverged. We
[discussed] that it'd make sense to upstream the environment var code.
In the process it seemed sensible to rename the NIX_GHC variable as
well, since it isn't really Nix-specific – it's just a way to set the
GHC binary to execute. This change has been [implemented] upstream in an
unreleased version of xmonad now – meaning we'll be able to drop the
xmonad patch soon!

This also clarifies the situation in nixpkgs a bit: NIX_GHC is easy to
confuse with the environment variable used in the ghcWithPackages
wrapper where it is used to set an alternative prefix for a GHC-wrapper
for applications trying to discover it via e.g. ghc-paths. It is an
implementation detail in this context, as it is in the case of the
xmonad module. Since they are different implementations doing different
things, different names also make sense.

[discussed]: 36d5761b3e
[implemented]: 23f36d7e23
2022-08-04 14:29:05 +02:00

35 lines
1.5 KiB
Diff

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 "XMONAD_GHC")
+ run ghc ghcArgs
CompileStackGhc stackYaml ->
run "stack" ["build", "--silent", "--stack-yaml", stackYaml] .&&.
run "stack" ("ghc" : "--stack-yaml" : stackYaml : "--" : ghcArgs)