clean up environment set-up

This commit is contained in:
Jan Tojnar 2018-04-03 01:12:55 +02:00
parent be679a5bd6
commit f7fe3a4e7c
No known key found for this signature in database
GPG Key ID: 7FAB2A15F7A607A4
2 changed files with 10 additions and 3 deletions

View File

@ -21,7 +21,13 @@ makeOptions :: Sh Options
makeOptions = do makeOptions = do
dryRun <- isJust <$> get_env "DRY_RUN" dryRun <- isJust <$> get_env "DRY_RUN"
workingDir <- (</> ".nix-update") <$> get_env_text "HOME" workingDir <- (</> ".nix-update") <$> get_env_text "HOME"
return $ Options dryRun workingDir githubToken <- cmd "cat" "github_token.txt"
return $ Options dryRun workingDir githubToken
setUpEnvironment :: Options -> Sh ()
setUpEnvironment options = do
setenv "PAGER" ""
setenv "GITHUB_TOKEN" (githubToken options)
main :: IO () main :: IO ()
main = shelly $ do main = shelly $ do
@ -32,7 +38,7 @@ main = shelly $ do
mkdir_p (workingDir options) mkdir_p (workingDir options)
touchfile logFile touchfile logFile
githubToken <- cmd "cat" "github_token.txt" setUpEnvironment options
updates <- cmd "cat" "packages-to-update.txt" updates <- cmd "cat" "packages-to-update.txt"

View File

@ -15,7 +15,8 @@ type Version = Text
data Options = Options { data Options = Options {
dryRun :: Bool, dryRun :: Bool,
workingDir :: FilePath workingDir :: FilePath,
githubToken :: Text
} }
setupNixpkgs :: Sh FilePath setupNixpkgs :: Sh FilePath