packages feed

nix-tree 0.1.8 → 0.1.9

raw patch · 5 files changed

+34/−18 lines, 5 filesdep ~brick

Dependency ranges changed: brick

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Changelog +## 0.1.9 - 2021-11-08:++* fix: Automatically enable the required 'nix-command' experimental feature on Nix >= 2.4+* fix: Do not refresh screen periodically unless necessary+ ## 0.1.8 - 2021-09-06:  * fix: Reduce idle CPU use
nix-tree.cabal view
@@ -3,7 +3,7 @@ name:                nix-tree synopsis:            Interactively browse a Nix store paths dependencies description:         A terminal curses application to browse a Nix store paths dependencies-version:             0.1.8+version:             0.1.9 homepage:            https://github.com/utdemir/nix-tree license:             BSD-3-Clause license-file:        LICENSE@@ -41,14 +41,12 @@                       NixTree.App                       Data.InvertedIndex                       NixTree.Clipboard-                      Paths_nix_tree-  autogen-modules:    Paths_nix_tree   mixins:             base hiding (Prelude)                     , relude (Relude as Prelude)   build-depends:      base                     , relude                     , aeson-                    , brick+                    , brick >= 0.64                     , bytestring                     , containers                     , clock
src/NixTree/App.hs view
@@ -18,6 +18,9 @@ import qualified System.Clock as Clock import qualified System.HrfSize as HRF +sortOrderChangeHighlightPeriod :: Clock.TimeSpec+sortOrderChangeHighlightPeriod = Clock.TimeSpec 0 (500 * 1_000_000)+ data Event   = EventTick Clock.TimeSpec @@ -297,8 +300,11 @@             | k `elem` [V.KChar 'q', V.KEsc] ->               B.continue s {aeOpenModal = Nothing}           -- handle our events-          (B.AppEvent (EventTick t), Nothing) ->-            B.continue $ s {aeCurrTime = t}+          (B.AppEvent (EventTick t), _) ->+            let new = s {aeCurrTime = t}+             in if timePassedSinceSortOrderChange new <= sum (replicate 2 sortOrderChangeHighlightPeriod)+                  then B.continue new+                  else B.continueWithoutRedraw new           -- ignore otherwise           _ ->             B.continue s,@@ -338,6 +344,9 @@                   ++ ["Please report this as a bug."]             ) +timePassedSinceSortOrderChange :: AppEnv s -> Clock.TimeSpec+timePassedSinceSortOrderChange env = Clock.diffTimeSpec (aeCurrTime env) (aeSortOrderLastChanged env)+ renderMainScreen :: AppEnv s -> B.Widget Widgets renderMainScreen env@AppEnv {aePrevPane, aeCurrPane, aeNextPane} =   (B.joinBorders . B.border)@@ -352,10 +361,9 @@     B.<=> renderInfoPane env   where     shouldHighlightSortOrder =-      let timePassed = Clock.diffTimeSpec (aeCurrTime env) (aeSortOrderLastChanged env)-       in if timePassed < Clock.TimeSpec 0 (500 * 1_000_000)-            then Just (aeSortOrder env)-            else Nothing+      if timePassedSinceSortOrderChange env < sortOrderChangeHighlightPeriod+        then Just (aeSortOrder env)+        else Nothing  renderInfoPane :: AppEnv s -> B.Widget Widgets renderInfoPane env =
src/NixTree/Main.hs view
@@ -1,11 +1,11 @@+{-# LANGUAGE CPP #-}+ module Main where  import Control.Concurrent.Async import Control.Exception (evaluate)-import Data.Version (showVersion) import NixTree.App import NixTree.PathStats-import Paths_nix_tree (version) import System.Directory (canonicalizePath, doesDirectoryExist, getHomeDirectory) import System.Environment (getArgs) import System.Exit (ExitCode (..))@@ -13,6 +13,9 @@ import System.IO (hPutStr, hPutStrLn) import System.ProgressBar hiding (msg) +version :: Text+version = VERSION_nix_tree+ usage :: Text usage =   unlines@@ -36,7 +39,7 @@     exitWith ExitSuccess    when ("--version" `elem` args) $ do-    putStrLn $ "nix-tree " ++ showVersion version+    putTextLn $ "nix-tree " <> version     exitWith ExitSuccess    paths <- case args of
src/NixTree/StorePath.hs view
@@ -106,28 +106,30 @@   -- > the output of given derivation; to actually work on the derivation you need to pass   -- > --derivation.   isAtLeastNix24 <- (>= Just "2.4") <$> getNixVersion+   let (derivations, outputs) =         partition           (\i -> ".drv" `T.isSuffixOf` storeNameToText i)           (NE.toList names)   (++)-    <$> maybe (return []) (getPathInfo nixStore False) (NE.nonEmpty outputs)-    <*> maybe (return []) (getPathInfo nixStore (True && isAtLeastNix24)) (NE.nonEmpty derivations)+    <$> maybe (return []) (getPathInfo nixStore isAtLeastNix24 False) (NE.nonEmpty outputs)+    <*> maybe (return []) (getPathInfo nixStore isAtLeastNix24 True) (NE.nonEmpty derivations)   where     getNixVersion :: IO (Maybe Text)     getNixVersion = do       out <- decodeUtf8 . BL.toStrict <$> readProcessStdout_ (proc "nix" ["--version"])       return . viaNonEmpty last $ T.splitOn " " out -getPathInfo :: NixStore -> Bool -> NonEmpty (StoreName s) -> IO [StorePath s (StoreName s) ()]-getPathInfo nixStore isDrv names = do+getPathInfo :: NixStore -> Bool -> Bool -> NonEmpty (StoreName s) -> IO [StorePath s (StoreName s) ()]+getPathInfo nixStore isAtLeastNix24 isDrv names = do   infos <-     decode @[NixPathInfoResult]       <$> readProcessStdout_         ( proc             "nix"             ( ["path-info", "--recursive", "--json"]-                ++ (if isDrv then ["--derivation"] else [])+                ++ (if isAtLeastNix24 then ["--extra-experimental-features", "nix-command"] else [])+                ++ (if isDrv && isAtLeastNix24 then ["--derivation"] else [])                 ++ map storeNameToPath (toList names)             )         )