packages feed

nix-tree 0.1.2.0 → 0.1.3.0

raw patch · 4 files changed

+40/−16 lines, 4 files

Files

+ LICENSE view
@@ -0,0 +1,11 @@+Copyright 2020 Utku Demir++Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.++3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
README.md view
@@ -43,8 +43,7 @@  All contributions, issues and feature requests are welcome. -To hack on it, simply run `nix develop` (which requires a Nix version-with flakes support) and use `cabal` as usual.+To hack on it, simply run `nix-shell` (or `nix develop`) and use `cabal` as usual.  # Related tools 
nix-tree.cabal view
@@ -1,9 +1,10 @@ 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.2.0+version:             0.1.3.0 homepage:            https://github.com/utdemir/nix-tree license:             BSD3+license-file:        LICENSE author:              Utku Demir maintainer:          Utku Demir copyright:           Utku Demir@@ -21,7 +22,7 @@                       App                       InvertedIndex                       Paths_nix_tree-  ghc-options:        -Wall -fno-warn-name-shadowing -threaded -O2 -threaded+  ghc-options:        -Wall -fno-warn-name-shadowing -threaded -threaded   build-depends:      base >= 4.11 && < 5                     , aeson                     , async
src/StorePath.hs view
@@ -31,6 +31,8 @@ import Data.HashMap.Strict (HashMap) import qualified Data.HashMap.Strict as HM import qualified Data.HashSet as HS+import Data.List (partition)+import qualified Data.List.NonEmpty as NE import qualified Data.Text as T import Protolude import System.FilePath.Posix (splitDirectories)@@ -70,19 +72,30 @@  mkStorePaths :: NonEmpty (StoreName s) -> IO [StorePath s (StoreName s) ()] mkStorePaths names = do-  infos <--    decode @[NixPathInfoResult]-      <$> readProcessStdout_-        ( proc-            "nix"-            ( ["path-info", "--recursive", "--json"]-                ++ map storeNameToPath (toList names)-            )-        )-      >>= maybe (fail "Failed parsing nix path-info output.") return-      >>= mapM assertValidInfo-  mapM infoToStorePath infos+  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)   where+    getPathInfo :: Bool -> NonEmpty (StoreName s) -> IO [StorePath s (StoreName s) ()]+    getPathInfo isDrv names = do+      infos <-+        decode @[NixPathInfoResult]+          <$> readProcessStdout_+            ( proc+                "nix"+                ( ["path-info", "--recursive", "--json"]+                    ++ (if isDrv then ["--derivation"] else [])+                    ++ map storeNameToPath (toList names)+                )+            )+          >>= maybe (fail "Failed parsing nix path-info output.") return+          >>= mapM assertValidInfo+      mapM infoToStorePath infos+     infoToStorePath NixPathInfo {npiPath, npiNarSize, npiReferences} = do       name <- mkStoreNameIO npiPath       refs <- filter (/= name) <$> mapM mkStoreNameIO npiReferences