@@ -42,6 +42,7 @@ import Stack.Types.Nix
4242import Stack.Types.Compiler
4343import Stack.Types.Internal
4444import System.Environment (lookupEnv ,getArgs ,getExecutablePath )
45+ import qualified System.FilePath as F
4546import System.Process.Read (getEnvOverride )
4647
4748-- | If Nix is enabled, re-runs the currently running OS command in a Nix container.
@@ -87,6 +88,7 @@ runShellAndExit mprojectRoot getCompilerVersion getCmdArgs = do
8788 pkgs = pkgsInConfig ++ [ghc]
8889 pkgsStr = " [" <> T. intercalate " " pkgs <> " ]"
8990 pureShell = nixPureShell (configNix config)
91+ addGCRoots = nixAddGCRoots (configNix config)
9092 nixopts = case mshellFile of
9193 Just fp -> [toFilePath fp, " --arg" , " ghc"
9294 ," with (import <nixpkgs> {}); " ++ T. unpack ghc]
@@ -109,8 +111,11 @@ runShellAndExit mprojectRoot getCompilerVersion getCmdArgs = do
109111 ," STACK_IN_NIX_EXTRA_ARGS = stackExtraArgs; "
110112 ," } \"\" " ]]
111113 -- glibcLocales is necessary on Linux to avoid warnings about GHC being incapable to set the locale.
112- fullArgs = concat [if pureShell then [" --pure" ] else [] ,
113- map T. unpack (nixShellOptions (configNix config))
114+ fullArgs = concat [if pureShell then [" --pure" ] else []
115+ ,if addGCRoots then [" --indirect" , " --add-root"
116+ ,toFilePath (configWorkDir config)
117+ F. </> " nix-gc-symlinks" F. </> " gc-root" ] else []
118+ ,map T. unpack (nixShellOptions (configNix config))
114119 ,nixopts
115120 ,[" --run" , intercalate " " (cmnd: " $STACK_IN_NIX_EXTRA_ARGS" : args)]
116121 ]
0 commit comments