We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
instance EnvVarReader PortNumber
Dumping Config.hs code here, and later I'll move code to core, and add the docs.
Config.hs
-- Config/Config.hs import IHP.EnvVar -- @todo: Move to IHP core import Network.Socket (PortNumber) import Data.Word (Word16) config :: ConfigBuilder config = do -- See https://ihp.digitallyinduced.com/Guide/config.html -- for what you can do here option customTailwind envName :: Maybe Text <- envOrNothing "ENV_NAME" case envName of Just "qa" -> initS3Storage "eu-west-1" "your-s3-storage" -- Static directory. _ -> initStaticDirStorage smtpHost <- env @Text "SMTP_HOST" smtpPort <- env @PortNumber "SMTP_PORT" smtpUserMaybe <- envOrNothing "SMTP_USER" smtpPasswordMaybe <- envOrNothing "SMTP_PASSWORD" -- Determine if credentials are available and set SMTP configuration accordingly. let (smtpCredentials, smtpEncryption) = case (smtpUserMaybe, smtpPasswordMaybe) of (Just user, Just password) -> (Just (user, password), STARTTLS) _ -> (Nothing, Unencrypted) liftIO $ putStrLn $ "SMTP HOST: " <> show smtpHost liftIO $ putStrLn $ "SMTP PORT: " <> show smtpPort -- SMTP to work with MailHog or other SMTP services. option $ SMTP { host = cs smtpHost , port = smtpPort , credentials = smtpCredentials , encryption = smtpEncryption } instance EnvVarReader PortNumber where envStringToValue string = case textToInt (cs string) of Just integer -> Right $ convertIntToPortNumber integer Nothing -> Left "Got a String instead of an Int for PortNumber." convertIntToPortNumber :: Int -> PortNumber convertIntToPortNumber int = fromIntegral (int :: Int) :: PortNumber
On .envrc
.envrc
# Add your env vars here export SMTP_HOST="127.0.0.1" # On some computers may need `127.0.1.1` instead. export SMTP_PORT="1025"
And on flake.nix we have
flake.nix
services.ihp = { domain = "..."; migrations = ./Application/Migration; schema = ./Application/Schema.sql; fixtures = ./Application/Fixtures.sql; sessionSecret = "..."; additionalEnvVars = { SMTP_HOST = "email-smtp.eu-west-1.amazonaws.com"; SMTP_PORT = "587"; SMTP_USER = "your-user-name"; SMTP_PASSWORD = "your-password"; ENV_NAME = "qa"; AWS_ACCESS_KEY_ID = "your key ID"; AWS_SECRET_ACCESS_KEY = "your secret"; }; };
The text was updated successfully, but these errors were encountered:
amitaibu
Successfully merging a pull request may close this issue.
Dumping
Config.hs
code here, and later I'll move code to core, and add the docs.On
.envrc
And on
flake.nix
we haveThe text was updated successfully, but these errors were encountered: