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 CPP #-}
|
||||||
{-# LANGUAGE LambdaCase #-}
|
{-# LANGUAGE LambdaCase #-}
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
{-# LANGUAGE TypeApplications #-}
|
||||||
|
|
||||||
#include <HsBaseConfig.h>
|
#include <HsBaseConfig.h>
|
||||||
|
|
||||||
@ -12,13 +14,15 @@ module Main (main) where
|
|||||||
import Prelude hiding (print, putStr, putStrLn)
|
import Prelude hiding (print, putStr, putStrLn)
|
||||||
|
|
||||||
import Control.Exception.Safe (catchIO, tryIO)
|
import Control.Exception.Safe (catchIO, tryIO)
|
||||||
import Control.Monad (filterM, forM_)
|
import Control.Monad (filterM, forM_, when)
|
||||||
import Data.List (sort)
|
import Data.List (sort)
|
||||||
|
import Data.Maybe (isJust)
|
||||||
import Data.Version (showVersion)
|
import Data.Version (showVersion)
|
||||||
import Foreign.C.String (CString, peekCAString)
|
import Foreign.C.String (CString, peekCAString)
|
||||||
import GHC.IO.Encoding (getLocaleEncoding, initLocaleEncoding)
|
import GHC.IO.Encoding (getLocaleEncoding, initLocaleEncoding)
|
||||||
import GHC.IO.Encoding.Iconv (localeEncodingName)
|
import GHC.IO.Encoding.Iconv (localeEncodingName)
|
||||||
import GHC.Show (showLitString)
|
import GHC.Show (showLitString)
|
||||||
|
import Language.Haskell.TH.Env (envQ)
|
||||||
import System.Directory (doesDirectoryExist, doesPathExist, listDirectory)
|
import System.Directory (doesDirectoryExist, doesPathExist, listDirectory)
|
||||||
import System.Environment (lookupEnv)
|
import System.Environment (lookupEnv)
|
||||||
import System.FilePath ((</>))
|
import System.FilePath ((</>))
|
||||||
@ -57,6 +61,21 @@ showSystem = do
|
|||||||
<> compilerName <> " " <> showVersion compilerVersion
|
<> compilerName <> " " <> showVersion compilerVersion
|
||||||
showEnvVar "TERM"
|
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 :: IO ()
|
||||||
showGhc = do
|
showGhc = do
|
||||||
putStrLn "# GHC"
|
putStrLn "# GHC"
|
||||||
|
@ -57,6 +57,7 @@ executables:
|
|||||||
- filepath
|
- filepath
|
||||||
- process
|
- process
|
||||||
- safe-exceptions
|
- safe-exceptions
|
||||||
|
- th-env
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
with-utf8-test:
|
with-utf8-test:
|
||||||
|
@ -4,3 +4,6 @@
|
|||||||
|
|
||||||
resolver: lts-14.25
|
resolver: lts-14.25
|
||||||
packages: [.]
|
packages: [.]
|
||||||
|
|
||||||
|
extra-deps:
|
||||||
|
- th-env-0.1.0.1
|
||||||
|
@ -3,7 +3,14 @@
|
|||||||
# For more information, please see the documentation at:
|
# For more information, please see the documentation at:
|
||||||
# https://docs.haskellstack.org/en/stable/lock_files
|
# 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:
|
snapshots:
|
||||||
- completed:
|
- completed:
|
||||||
size: 524163
|
size: 524163
|
||||||
|
Loading…
Reference in New Issue
Block a user