mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-09-11 18:05:56 +03:00
core: add System.Nix.Realisation
This commit is contained in:
parent
2f73cd9aef
commit
25778c1dcd
@ -66,6 +66,7 @@ library
|
||||
, System.Nix.Hash
|
||||
, System.Nix.Hash.Truncation
|
||||
, System.Nix.OutputName
|
||||
, System.Nix.Realisation
|
||||
, System.Nix.Signature
|
||||
, System.Nix.Store.Types
|
||||
, System.Nix.StorePath
|
||||
|
41
hnix-store-core/src/System/Nix/Realisation.hs
Normal file
41
hnix-store-core/src/System/Nix/Realisation.hs
Normal file
@ -0,0 +1,41 @@
|
||||
{-|
|
||||
Description : Derivation realisations
|
||||
-}
|
||||
|
||||
module System.Nix.Realisation (
|
||||
DerivationOutput(..)
|
||||
, Realisation(..)
|
||||
) where
|
||||
|
||||
import Crypto.Hash (Digest)
|
||||
import Data.Map (Map)
|
||||
import Data.Set (Set)
|
||||
import Data.Dependent.Sum (DSum)
|
||||
import GHC.Generics (Generic)
|
||||
import System.Nix.Hash (HashAlgo)
|
||||
import System.Nix.OutputName (OutputName)
|
||||
import System.Nix.Signature (Signature)
|
||||
import System.Nix.StorePath (StorePath)
|
||||
|
||||
-- | Output of the derivation
|
||||
data DerivationOutput outputName = DerivationOutput
|
||||
{ derivationOutputHash :: DSum HashAlgo Digest
|
||||
-- ^ Hash modulo of the derivation
|
||||
, derivationOutputName :: outputName
|
||||
-- ^ Name of the output
|
||||
} deriving (Eq, Generic, Ord, Show)
|
||||
|
||||
-- | Build realisation context
|
||||
--
|
||||
-- realisationId is ommited since it is a key
|
||||
-- of type @DerivationOutput OutputName@ so
|
||||
-- we will use a tuple like @(DerivationOutput OutputName, Realisation)@
|
||||
-- instead.
|
||||
data Realisation = Realisation
|
||||
{ realisationOutPath :: StorePath
|
||||
-- ^ Output path
|
||||
, realisationSignatures :: Set Signature
|
||||
-- ^ Signatures
|
||||
, realisationDependencies :: Map (DerivationOutput OutputName) StorePath
|
||||
-- ^ Dependent realisations required for this one to be valid
|
||||
} deriving (Eq, Generic, Ord, Show)
|
@ -47,6 +47,7 @@ library
|
||||
, System.Nix.Arbitrary.DerivedPath
|
||||
, System.Nix.Arbitrary.Hash
|
||||
, System.Nix.Arbitrary.OutputName
|
||||
, System.Nix.Arbitrary.Realisation
|
||||
, System.Nix.Arbitrary.Signature
|
||||
, System.Nix.Arbitrary.Store.Types
|
||||
, System.Nix.Arbitrary.StorePath
|
||||
|
@ -12,6 +12,7 @@ import System.Nix.Arbitrary.Derivation ()
|
||||
import System.Nix.Arbitrary.DerivedPath ()
|
||||
import System.Nix.Arbitrary.Hash ()
|
||||
import System.Nix.Arbitrary.OutputName ()
|
||||
import System.Nix.Arbitrary.Realisation ()
|
||||
import System.Nix.Arbitrary.Signature ()
|
||||
import System.Nix.Arbitrary.Store.Types ()
|
||||
import System.Nix.Arbitrary.StorePath ()
|
||||
|
25
hnix-store-tests/src/System/Nix/Arbitrary/Realisation.hs
Normal file
25
hnix-store-tests/src/System/Nix/Arbitrary/Realisation.hs
Normal file
@ -0,0 +1,25 @@
|
||||
-- due to recent generic-arbitrary
|
||||
{-# OPTIONS_GHC -fconstraint-solver-iterations=0 #-}
|
||||
{-# OPTIONS_GHC -Wno-orphans #-}
|
||||
module System.Nix.Arbitrary.Realisation where
|
||||
|
||||
import System.Nix.Arbitrary.Hash ()
|
||||
import System.Nix.Arbitrary.OutputName ()
|
||||
import System.Nix.Arbitrary.Signature ()
|
||||
import System.Nix.Arbitrary.StorePath ()
|
||||
import System.Nix.Realisation (DerivationOutput, Realisation)
|
||||
|
||||
import Test.QuickCheck (Arbitrary(..))
|
||||
import Test.QuickCheck.Arbitrary.Generic (Arg, GenericArbitrary(..), genericArbitrary, genericShrink)
|
||||
|
||||
instance
|
||||
( Arg (DerivationOutput outputName) outputName
|
||||
, Arbitrary outputName
|
||||
) =>
|
||||
Arbitrary (DerivationOutput outputName)
|
||||
where
|
||||
arbitrary = genericArbitrary
|
||||
shrink = genericShrink
|
||||
|
||||
deriving via GenericArbitrary Realisation
|
||||
instance Arbitrary Realisation
|
Loading…
Reference in New Issue
Block a user