|
| 1 | +{-# LANGUAGE OverloadedStrings #-} |
| 2 | +import qualified Data.ByteString.Lazy as LBS |
| 3 | +import qualified Data.HashSet as HS |
| 4 | +import qualified System.Nix.GC as GC |
| 5 | +import System.Nix.Store.Remote |
| 6 | +import System.Nix.Store.Remote.Util |
| 7 | +import Data.Maybe |
| 8 | +import Control.Monad.Reader |
| 9 | + |
| 10 | +import Text.Pretty.Simple |
| 11 | + |
| 12 | +noSuchPath = fromJust $ mkPath "blah" |
| 13 | + |
| 14 | +main = do |
| 15 | + x <- runStore $ do |
| 16 | + syncWithGC |
| 17 | + |
| 18 | + verifyStore False False |
| 19 | + |
| 20 | + (Just path) <- addTextToStore "hnix-store" "test" (HS.fromList []) False |
| 21 | + |
| 22 | + valid <- isValidPathUncached path |
| 23 | + case valid of |
| 24 | + True -> do |
| 25 | + info <- queryPathInfoUncached path |
| 26 | + return (path, info) |
| 27 | + _ -> error "shouldn't happen" |
| 28 | + |
| 29 | + pPrint x |
| 30 | + case x of |
| 31 | + (Left err, log) -> putStrLn err >> print log |
| 32 | + (Right (path, pathinfo), log) -> do |
| 33 | + gcres <- runStore $ do |
| 34 | + collectGarbage $ GC.Options |
| 35 | + { GC.operation = GC.DeleteSpecific |
| 36 | + , GC.pathsToDelete = HS.fromList [path] |
| 37 | + , GC.ignoreLiveness = False |
| 38 | + -- XXX: this breaks stuff - we don't get Last, |
| 39 | + -- only a message with limit reached, stopping.. |
| 40 | + -- |
| 41 | + -- gcDeleteSpecific and options.maxFreed |
| 42 | + -- are two distinct branches in |
| 43 | + -- nix/src/libstore.gc |
| 44 | + -- so maybe this combination is not supported |
| 45 | + --, GC.maxFreed = 1000 |
| 46 | + , GC.maxFreed = -1 |
| 47 | + } |
| 48 | + |
| 49 | + pPrint gcres |
| 50 | + |
| 51 | + -- test ExceptT |
| 52 | + e <- runStore $ do |
| 53 | + isValidPathUncached $ noSuchPath |
| 54 | + |
| 55 | + pPrint e |
| 56 | + |
| 57 | + {- |
| 58 | + e <- runStore $ do |
| 59 | + queryPathInfoUncached $ noSuchPath |
| 60 | +
|
| 61 | + pPrint e |
| 62 | + -} |
| 63 | + |
| 64 | + --res <- queryDerivationOutputs drvP |
| 65 | + --liftIO $ print res |
| 66 | + --res <- findRoots |
| 67 | + --liftIO $ pPrint res |
0 commit comments