From 039046e3558553ee96936f9c637cc50a72b532fd Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Wed, 15 Mar 2017 06:42:00 +0200 Subject: [PATCH] Another Nix workaround (fixes #1359) --- yesod-bin/ChangeLog.md | 4 ++++ yesod-bin/Devel.hs | 29 +++++++++++++++++++++++++---- yesod-bin/yesod-bin.cabal | 2 +- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/yesod-bin/ChangeLog.md b/yesod-bin/ChangeLog.md index 029f8857..9a8c6990 100644 --- a/yesod-bin/ChangeLog.md +++ b/yesod-bin/ChangeLog.md @@ -1,3 +1,7 @@ +## 1.5.2.2 + +* I guess `--no-nix-pure` implies Nix... sigh [#1359](https://github.com/yesodweb/yesod/issues/1359) + ## 1.5.2.1 * Use `--no-nix-pure` [#1357](https://github.com/yesodweb/yesod/issues/1357) diff --git a/yesod-bin/Devel.hs b/yesod-bin/Devel.hs index 0795fa2e..4289317b 100644 --- a/yesod-bin/Devel.hs +++ b/yesod-bin/Devel.hs @@ -21,6 +21,7 @@ import qualified Data.Conduit.List as CL import Data.Default.Class (def) import Data.FileEmbed (embedFile) import qualified Data.Map as Map +import Data.Maybe (isJust) import qualified Data.Set as Set import Data.Streaming.Network (bindPortTCP, bindRandomPortTCP) @@ -362,9 +363,11 @@ devel opts passThroughArgs = do sayV "First successful build complete, running app" - -- We're going to set the PORT and DISPLAY_PORT variables - -- for the child below + -- We're going to set the PORT and DISPLAY_PORT variables for + -- the child below. Also need to know if the env program + -- exists. env <- fmap Map.fromList getEnvironment + hasEnv <- fmap isJust $ findExecutable "env" -- Keep looping forever, print any synchronous exceptions, -- and eventually die from an async exception from one of @@ -405,9 +408,27 @@ devel opts passThroughArgs = do , "Main.main" ] -} - let procDef = setStdin closed $ setEnv env' $ proc "stack" - [ "--no-nix-pure" -- https://github.com/yesodweb/yesod/issues/1357 + + -- Nix support in Stack doesn't pass along env vars by + -- default, so we use the env command. But if the command + -- isn't available, just set the env var. I'm sure this + -- will break _some_ combination of systems, but we'll + -- deal with that later. Previous issues: + -- + -- https://github.com/yesodweb/yesod/issues/1357 + -- https://github.com/yesodweb/yesod/issues/1359 + let procDef + | hasEnv = setStdin closed $ proc "stack" + [ "exec" + , "--" + , "env" + , "PORT=" ++ show newPort + , "DISPLAY_PORT=" ++ show (develPort opts) , "runghc" + , develHsPath + ] + | otherwise = setStdin closed $ setEnv env' $ proc "stack" + [ "runghc" , "--" , develHsPath ] diff --git a/yesod-bin/yesod-bin.cabal b/yesod-bin/yesod-bin.cabal index 5779fd45..54eb1805 100644 --- a/yesod-bin/yesod-bin.cabal +++ b/yesod-bin/yesod-bin.cabal @@ -1,5 +1,5 @@ name: yesod-bin -version: 1.5.2.1 +version: 1.5.2.2 license: MIT license-file: LICENSE author: Michael Snoyman