From 02c0f80b022641e46430db25d86a0eeaa3988ef0 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sat, 28 Sep 2019 00:51:16 +0200 Subject: [PATCH] Implement uid parameter --- arion-compose.cabal | 1 + src/haskell/exe/Main.hs | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/arion-compose.cabal b/arion-compose.cabal index ade58de..40a45be 100644 --- a/arion-compose.cabal +++ b/arion-compose.cabal @@ -38,6 +38,7 @@ common deps , temporary , text , protolude + , unix flag ghci default: False diff --git a/src/haskell/exe/Main.hs b/src/haskell/exe/Main.hs index f7c4035..fb29f89 100644 --- a/src/haskell/exe/Main.hs +++ b/src/haskell/exe/Main.hs @@ -22,9 +22,10 @@ import qualified Data.Text.Lazy.Builder as TB import qualified Data.List.NonEmpty as NE import Data.List.NonEmpty (NonEmpty(..)) - import Control.Arrow ((>>>)) +import System.Posix.User (getRealUserID) + data CommonOptions = CommonOptions { files :: NonEmpty FilePath @@ -159,14 +160,16 @@ runEvalAndDC cmd dopts opts = do } defaultEvaluationArgs :: CommonOptions -> IO EvaluationArgs -defaultEvaluationArgs co = pure EvaluationArgs - { evalUid = 0 -- TODO - , evalModules = files co - , evalPkgs = pkgs co - , evalWorkDir = Nothing - , evalMode = ReadWrite - , evalUserArgs = nixArgs co - } +defaultEvaluationArgs co = do + uid <- getRealUserID + pure EvaluationArgs + { evalUid = fromIntegral uid + , evalModules = files co + , evalPkgs = pkgs co + , evalWorkDir = Nothing + , evalMode = ReadWrite + , evalUserArgs = nixArgs co + } runCat :: CommonOptions -> IO () runCat co = do