mirror of
https://github.com/serokell/haskell-with-utf8.git
synced 2024-10-26 07:51:16 +03:00
troubleshoot: Detect Nix builds and show LOCALE_ARCHIVE
This commit is contained in:
parent
f9aea084bb
commit
c5221f4f1c
@ -4,6 +4,8 @@
|
||||
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE TypeApplications #-}
|
||||
|
||||
#include <HsBaseConfig.h>
|
||||
|
||||
@ -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"
|
||||
|
@ -57,6 +57,7 @@ executables:
|
||||
- filepath
|
||||
- process
|
||||
- safe-exceptions
|
||||
- th-env
|
||||
|
||||
tests:
|
||||
with-utf8-test:
|
||||
|
@ -4,3 +4,6 @@
|
||||
|
||||
resolver: lts-14.25
|
||||
packages: [.]
|
||||
|
||||
extra-deps:
|
||||
- th-env-0.1.0.1
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user