这是示例(仅从已安装的应用程序凭据页面复制):
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Proxy (Proxy (..))
import Data.Text as T
import Data.Text.IO as T
import System.Exit (exitFailure)
import System.Info (os)
import System.Process (rawSystem)
redirectPrompt :: AllowScopes (s :: [Symbol]) => OAuthClient -> proxy s -> IO (OAuthCode s)
redirectPrompt c p = do
let url = formURL c p
T.putStrLn $ "Opening URL " `T.append` url
_ <- case os of
"darwin" -> rawSystem "open" [unpack url]
"linux" -> …Run Code Online (Sandbox Code Playgroud) 我在 nix 中使用堆栈。我需要将环境变量作为数据库密码传递以在运行时连接到 Postgres。目前,我在 YAML 中启用了 nix 并自定义了自己.nix的密码以将密码放入.nix.
堆栈.yaml:
nix:
enable: true
pure: true
shell-file: shell.nix
Run Code Online (Sandbox Code Playgroud)
shell.nix:
{ghc}:
with (import <nixpkgs> {});
haskell.lib.buildStackProject {
inherit ghc;
name = "myenv";
buildInputs = [ postgresql_10 ];
PGPASSWORD = "pw";
}
Run Code Online (Sandbox Code Playgroud)
但是当我想将代码提交到 GitHub/Gitlab 并转到 CI/CD 管道时,显式输入密码.nix似乎不太好。我想知道有什么好的方法可以解决这个问题吗?