diff --git a/app/utf8-troubleshoot/Main.hs b/app/utf8-troubleshoot/Main.hs index b79009f..4463dc4 100644 --- a/app/utf8-troubleshoot/Main.hs +++ b/app/utf8-troubleshoot/Main.hs @@ -4,6 +4,8 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeApplications #-} #include @@ -12,13 +14,15 @@ module Main (main) where import Prelude hiding (print, putStr, putStrLn) import Control.Exception.Safe (catchIO, tryIO) -import Control.Monad (filterM, forM_) +import Control.Monad (filterM, forM_, when) import Data.List (sort) +import Data.Maybe (isJust) import Data.Version (showVersion) import Foreign.C.String (CString, peekCAString) import GHC.IO.Encoding (getLocaleEncoding, initLocaleEncoding) import GHC.IO.Encoding.Iconv (localeEncodingName) import GHC.Show (showLitString) +import Language.Haskell.TH.Env (envQ) import System.Directory (doesDirectoryExist, doesPathExist, listDirectory) import System.Environment (lookupEnv) import System.FilePath (()) @@ -57,6 +61,21 @@ showSystem = do <> compilerName <> " " <> showVersion compilerVersion showEnvVar "TERM" + -- Nix stuff + let builtNix = isJust ($$(envQ @String "NIX_BUILD_TOP")) + when builtNix $ do + putStrLn " * Built with Nix" + let builtNixShell = isJust ($$(envQ @String "IN_NIX_SHELL")) + when builtNixShell $ do + putStrLn " * Built in nix-shell" + inNixShell <- isJust <$> lookupEnv "IN_NIX_SHELL" + when inNixShell $ do + putStrLn " * Running in nix-shell" + + when (builtNix || builtNixShell) $ do + showEnvVar "LOCALE_ARCHIVE" + + showGhc :: IO () showGhc = do putStrLn "# GHC" diff --git a/package.yaml b/package.yaml index 36d4d48..a9e32c4 100644 --- a/package.yaml +++ b/package.yaml @@ -57,6 +57,7 @@ executables: - filepath - process - safe-exceptions + - th-env tests: with-utf8-test: diff --git a/stack.yaml b/stack.yaml index ddf5079..d3c745c 100644 --- a/stack.yaml +++ b/stack.yaml @@ -4,3 +4,6 @@ resolver: lts-14.25 packages: [.] + +extra-deps: + - th-env-0.1.0.1 diff --git a/stack.yaml.lock b/stack.yaml.lock index 8d605d9..1a32c87 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -3,7 +3,14 @@ # For more information, please see the documentation at: # https://docs.haskellstack.org/en/stable/lock_files -packages: [] +packages: +- completed: + hackage: th-env-0.1.0.1@sha256:960423c1951e3c36ba62d5286c7fa859095d41a309c4ea13c2d90abfe5d35bca,1171 + pantry-tree: + size: 370 + sha256: bfbb41d856bdb5c678f678a4af9ee4a96ad9aa73460444f12d952e9901df2940 + original: + hackage: th-env-0.1.0.1 snapshots: - completed: size: 524163