@@ -30,6 +30,7 @@ import System.Console.ANSI qualified as Terminal
3030import System.Console.Terminal.Size (Window )
3131import System.Environment qualified as Environment
3232import System.IO.Error qualified as IOError
33+ import System.Posix qualified as System
3334import System.Posix.Signals qualified as Signals
3435import System.Process.Typed (proc , runProcess )
3536import System.Process.Typed qualified as Process
@@ -81,18 +82,22 @@ runApp = \cases
8182 _ [" --version" ] -> do
8283 hPutStrLn stderr (" nix-output-monitor " <> fromString (showVersion version))
8384 exitWith =<< runProcess (proc " nix" [" --version" ])
85+ " nom-build" args | " --help" `elem` args -> runNixHelpCommand " nix-build" args
8486 " nom-build" args -> exitWith =<< runMonitoredCommand defaultConfig (proc " nix-build" (withJSON args))
8587 " nom-shell" args -> do
8688 exitOnFailure =<< runMonitoredCommand defaultConfig{silent = True } (proc " nix-shell" (withJSON args <> [" --run" , " exit" ]))
8789 exitWith =<< runProcess (proc " nix-shell" args)
90+ " nom" (" build" : args) | " --help" `elem` args -> runNixHelpCommand " nix" (" build" : args)
8891 " nom" (" build" : args) -> exitWith =<< runMonitoredCommand defaultConfig (proc " nix" (" build" : withJSON args))
92+ " nom" (" copy" : args) | " --help" `elem` args -> runNixHelpCommand " nix" (" copy" : args)
8993 " nom" (" copy" : args) -> exitWith =<< runMonitoredCommand defaultConfig (proc " nix" (" copy" : withJSON args))
9094 " nom" (" shell" : args) -> do
9195 exitOnFailure =<< runMonitoredCommand defaultConfig{silent = True } (proc " nix" (" shell" : withJSON (replaceCommandWithExit args)))
9296 exitWith =<< runProcess (proc " nix" (" shell" : args))
9397 " nom" (" develop" : args) -> do
9498 exitOnFailure =<< runMonitoredCommand defaultConfig{silent = True } (proc " nix" (" develop" : withJSON (replaceCommandWithExit args)))
9599 exitWith =<< runProcess (proc " nix" (" develop" : args))
100+ " nom" (" flake" : args) | " --help" `elem` args -> runNixHelpCommand " nix" (" flake" : args)
96101 " nom" (" flake" : args) -> exitWith =<< runMonitoredCommand defaultConfig (proc " nix" (" flake" : withJSON args))
97102 " nom" [] -> do
98103 finalState <- monitorHandle OldStyleInput defaultConfig{piping = True } stdin
@@ -153,6 +158,9 @@ printIOException io_exception = do
153158 _ -> show io_exception
154159 hPutStrLn stderr $ markup red (" nix-output-monitor: " <> error_msg)
155160
161+ runNixHelpCommand :: String -> [String ] -> IO Void
162+ runNixHelpCommand cmd args = System. executeFile cmd True args Nothing
163+
156164runMonitoredCommand :: Config -> Process. ProcessConfig () () () -> IO Process. ExitCode
157165runMonitoredCommand config process_config = do
158166 let process_config_with_handles =
0 commit comments