|
| 1 | +{-| |
| 2 | +Description : Garbage collection actions / options |
| 3 | +Maintainer : srk <[email protected]> |
| 4 | +|-} |
| 5 | +module System.Nix.Store.Remote.Types.GC ( |
| 6 | + GCAction(..) |
| 7 | + , GCOptions(..) |
| 8 | + , GCResult(..) |
| 9 | + ) where |
| 10 | + |
| 11 | +import Data.HashSet (HashSet) |
| 12 | +import Data.Word (Word64) |
| 13 | +import GHC.Generics (Generic) |
| 14 | +import System.Nix.StorePath (StorePath) |
| 15 | + |
| 16 | +data GCAction |
| 17 | + = GCAction_ReturnLive -- ^ Return the set of paths reachable from roots (closure) |
| 18 | + | GCAction_ReturnDead -- ^ Return unreachable paths |
| 19 | + | GCAction_DeleteDead -- ^ Delete unreachable paths |
| 20 | + | GCAction_DeleteSpecific -- ^ Delete specified paths |
| 21 | + deriving (Bounded, Eq, Enum, Generic, Ord, Show) |
| 22 | + |
| 23 | + -- | Garbage collector operation options |
| 24 | +data GCOptions = GCOptions |
| 25 | + { -- | Operation |
| 26 | + gcOptions_operation :: GCAction |
| 27 | + -- | If set, then reachability from the roots is ignored (unused) |
| 28 | + , gcOptions_ignoreLiveness :: Bool |
| 29 | + -- | Paths to delete for @GCAction_DeleteSpecific@ |
| 30 | + , gcOptions_pathsToDelete :: HashSet StorePath |
| 31 | + -- | Stop after `gcOptions_maxFreed` bytes have been freed |
| 32 | + , gcOptions_maxFreed :: Integer |
| 33 | + } deriving (Eq, Generic, Ord, Show) |
| 34 | + |
| 35 | +data GCResult = GCResult |
| 36 | + { -- | Depending on the action, the GC roots, |
| 37 | + -- or the paths that would be or have been deleted |
| 38 | + gcResult_deletedPaths :: HashSet StorePath |
| 39 | + -- | The number of bytes that would be or was freed for |
| 40 | + -- |
| 41 | + -- - @GCAction_ReturnDead@ |
| 42 | + -- - @GCAction_DeleteDead@ |
| 43 | + -- - @GCAction_DeleteSpecific@ |
| 44 | + , gcResult_bytesFreed :: Word64 |
| 45 | + } deriving (Eq, Generic, Ord, Show) |
0 commit comments