@@ -33,6 +33,7 @@ import Control.Lens
3333import Data.Bool (bool)
3434import Data.Default
3535import Data.List (intercalate)
36+import Data.Maybe
3637import Data.Monoid ((<>))
3738import qualified Data.Text as T
3839import System.Process (proc)
@@ -42,14 +43,14 @@ import Obelisk.CliApp
4243
4344-- | What to build
4445data Target = Target
45− { _target_path :: FilePath
46+ { _target_path :: Maybe FilePath
4647 , _target_attr :: Maybe String
4748 }
4849makeClassy ''Target
4950
5051instance Default Target where
5152 def = Target
52− { _target_path = "."
53+ { _target_path = Just "."
5354 , _target_attr = Nothing
5455 }
5556
@@ -83,7 +84,7 @@ instance Default NixCommonConfig where
8384 def = NixCommonConfig def mempty mempty
8485
8586runNixCommonConfig :: NixCommonConfig -> [FilePath]
86−runNixCommonConfig cfg = mconcat [[path], attrArg, args, buildersArg]
87+runNixCommonConfig cfg = mconcat [maybeToList path, attrArg, args, buildersArg]
8788 where
8889 path = _target_path $ _nixCmdConfig_target cfg
8990 attr = _target_attr $ _nixCmdConfig_target cfg
@@ -151,7 +152,7 @@ instance Default NixCmd where
151152 def = NixCmd_Build def
152153
153154nixCmd :: MonadObelisk m => NixCmd -> m FilePath
154−nixCmd cmdCfg = withSpinner' ("Running " <> cmd <> " on " <> desc) (Just $ const $ "Built " <> desc) $ do
155+nixCmd cmdCfg = withSpinner' ("Running " <> cmd <> desc) (Just $ const $ "Built " <> desc) $ do
155156 output <- readProcessAndLogStderr Debug $ proc (T.unpack cmd) $ options
156157 -- Remove final newline that Nix appends
157158 Just (outPath, '\n') <- pure $ T.unsnoc output
@@ -169,6 +170,7 @@ nixCmd cmdCfg = withSpinner' ("Running " <> cmd <> " on " <> desc) (Just $ const
169170 , cfg' ^. nixCommonConfig
170171 )
171172 path = commonCfg ^. nixCmdConfig_target . target_path
172− desc = T.pack $ path <> maybe ""
173− (\a -> " [" <> a <> "]")
174− (commonCfg ^. nixCmdConfig_target . target_attr)
173+ desc = T.pack $ mconcat $ catMaybes
174+ [ (" on " <>) <$> path
175+ , (\a -> " [" <> a <> "]") <$> (commonCfg ^. nixCmdConfig_target . target_attr)
176+ ]