Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Major changes:

Behavior changes:

* When Stack's Nix integration is enabled and a `shell-file` is not specified,
Stack sets `LANG=C.UTF-8` (rather than `en_US.UTF-8`, which may not be
available if Stack has been built from source).

Other enhancements:

Bug fixes:
Expand Down
7 changes: 4 additions & 3 deletions src/Stack/Nix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ runShellAndExit = do
-- LD_LIBRARY_PATH is set because for now it's needed by
-- builds using Template Haskell
, "STACK_IN_NIX_EXTRA_ARGS = stackExtraArgs; "
-- overriding default locale so Unicode output using base
-- won't be broken
, "LANG=\"en_US.UTF-8\";"
-- Overriding default locale so Unicode output using base
-- won't be broken (including on systems that do not provide
-- locale en_US.UTF-8):
, "LANG=\"C.UTF-8\";"
, "} \"\""
]
]
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/tests/4095-utf8-pure-nix/Main.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- Stack supports Unicode code points in a Nix environment.
--
-- See: https://github.com/commercialhaskell/stack/issues/4095
-- See: https://github.com/commercialhaskell/stack/pull/6945

import Control.Monad ( unless )
import Data.Maybe ( isJust )
Expand All @@ -20,7 +21,9 @@ main
| otherwise = do
isInContainer <- getInContainer
unless isInContainer $ do
-- Building causes GHC to emit Unicode:
stack ["build", "--nix-pure"]
-- Running causes the executable to output Unicode:
stack ["exec", "--nix-pure", "myExe"]

-- | 'True' if we are currently running inside a Docker container.
Expand Down
5 changes: 2 additions & 3 deletions tests/integration/tests/4095-utf8-pure-nix/files/app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import System.IO ( stdout )
import Text.Printf ( hPrintf )
import Lib ( unicode )

main :: IO ()
main = hPrintf stdout "平和"
main = unicode
5 changes: 5 additions & 0 deletions tests/integration/tests/4095-utf8-pure-nix/files/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ name: myPackage
dependencies:
- base

library:
source-dirs: src

executables:
myExe:
source-dirs: app
main: Main.hs
dependencies:
- myPackage
7 changes: 7 additions & 0 deletions tests/integration/tests/4095-utf8-pure-nix/files/src/Lib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Lib
( unicode
) where

{-# WARNING unicode "Warning itself emits unicode: 😊" #-}
unicode :: IO ()
unicode = putStrLn "Function outputs unicode: 😊"
Loading