in pkgs.mkShell {
nativeBuildInputs = [
- (haskellPackages.ghcWithPackages
- (p: with p; [ aeson dir-traverse relude typed-process ]))
+ (haskellPackages.ghcWithPackages (p:
+ with p; [
+ aeson
+ dir-traverse
+ relude
+ terminal-progress-bar
+ typed-process
+ ]))
haskellPackages.ghcid
haskellPackages.haskell-language-server
import Data.Aeson.Types (prependFailure, typeMismatch)
import Data.Text (Text)
import GHC.Base (quotInt)
-import Relude (catMaybes, foldMapM)
+import Relude (catMaybes, foldMapM, stderr)
import System.Directory (doesDirectoryExist, listDirectory, pathIsSymbolicLink)
+import System.IO (stderr, hPutStrLn)
import System.Posix.Files qualified as Posix
import System.Process.Typed (readProcess_, proc)
+import System.ProgressBar (hNewProgressBar)
+import System.ProgressBar qualified as ProgressBar
main :: IO ()
main = do
gcrootPaths <- findRoots "/nix/var/nix/gcroots"
- gcroots <- catMaybes <$> mapM collectGcroot gcrootPaths
+ hPutStrLn stderr "Scanning gcroots..."
+ pb <- hNewProgressBar stderr ProgressBar.defStyle 10 (ProgressBar.Progress 0 (length gcrootPaths) ())
+ gcroots <- catMaybes <$> mapM (collectAndLog pb) gcrootPaths
mapM_ printGcroot gcroots
+ where
+ collectAndLog pb root =
+ collectGcroot root
+ <* ProgressBar.incProgress pb 1
findRoots :: FilePath -> IO [FilePath]
findRoots path = do