nix-tree 0.1.3.0 → 0.1.3.1
raw patch · 3 files changed
+35/−2 lines, 3 filesdep +bytestring
Dependencies added: bytestring
Files
- README.md +19/−0
- nix-tree.cabal +2/−1
- src/StorePath.hs +14/−1
README.md view
@@ -39,6 +39,25 @@ [home-manager]: https://github.com/rycee/home-manager +### Tips++`nix-build` prints built paths to stdout, which can be piped conveniently+with `| xargs -o nix-tree`. Examples:++```bash+# Output of a local derivation+nix-build . --no-out-link | xargs -o nix-tree++# Build time dependencies (passing a `.drv` path)+nix-instantiate --no-out-link | xargs -o nix-tree++# Dependencies from shell.nix+nix-build shell.nix -A inputDerivation | xargs -o nix-tree++# All outputs of a derivation in nixpkgs:+nix-build '<nixpkgs>' -A openssl.all --no-out-link | xargs -o nix-tree+```+ ## Hacking All contributions, issues and feature requests are welcome.
nix-tree.cabal view
@@ -1,7 +1,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.3.0+version: 0.1.3.1 homepage: https://github.com/utdemir/nix-tree license: BSD3 license-file: LICENSE@@ -27,6 +27,7 @@ , aeson , async , brick+ , bytestring , containers , deepseq , directory
src/StorePath.hs view
@@ -28,6 +28,7 @@ import Control.Monad (fail) import Data.Aeson (FromJSON (..), Value (..), decode, (.:))+import qualified Data.ByteString.Lazy as BL import Data.HashMap.Strict (HashMap) import qualified Data.HashMap.Strict as HM import qualified Data.HashSet as HS@@ -72,14 +73,26 @@ mkStorePaths :: NonEmpty (StoreName s) -> IO [StorePath s (StoreName s) ()] mkStorePaths names = do+ -- See: https://github.com/utdemir/nix-tree/issues/12+ --+ -- > In Nix < 2.4, when you pass a .drv to path-info, it returns information about the store+ -- > derivation. However, when you do the same in 2.4, it "resolves" it and works on+ -- > 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 False) (NE.nonEmpty outputs)- <*> maybe (return []) (getPathInfo True) (NE.nonEmpty derivations)+ <*> maybe (return []) (getPathInfo (True && isAtLeastNix24)) (NE.nonEmpty derivations) where+ getNixVersion :: IO (Maybe Text)+ getNixVersion = do+ out <- decodeUtf8 . BL.toStrict <$> readProcessStdout_ (proc "nix" ["--version"])+ return . lastMay $ T.splitOn " " out+ getPathInfo :: Bool -> NonEmpty (StoreName s) -> IO [StorePath s (StoreName s) ()] getPathInfo isDrv names = do infos <-