make DerivationOutput explicitely generic

It is already parametrized, but `name` field is too specific
to accommodate i.e. `DerivationOutput StorePath` which is
used by `Derivation` type. So we call it `output` instead
and turn the type variable to just `a`.

So
* for `Realisation`s this is `DerivationOutput OutputName`
* for `Derivation`s this is `DerivatonOutput StorePath`
* for content addressed derivations this might be `DerivationOutput Void` as the path isn't known ahead of time.

So only its shape is important.

Related to https://github.com/Gabriella439/Haskell-Nix-Derivation-Library/pull/24
This commit is contained in:
sorki 2023-12-06 18:36:22 +01:00
parent e6d21c15bc
commit 496fb3284e
2 changed files with 5 additions and 5 deletions

View File

@ -28,11 +28,11 @@ import qualified Data.Text.Lazy.Builder
import qualified System.Nix.Hash
-- | Output of the derivation
data DerivationOutput outputName = DerivationOutput
data DerivationOutput a = DerivationOutput
{ derivationOutputHash :: DSum HashAlgo Digest
-- ^ Hash modulo of the derivation
, derivationOutputName :: outputName
-- ^ Name of the output
, derivationOutputOutput :: a
-- ^ Output (either a OutputName or StorePatH)
} deriving (Eq, Generic, Ord, Show)
data DerivationOutputError
@ -74,7 +74,7 @@ derivationOutputBuilder
derivationOutputBuilder outputName DerivationOutput{..} =
System.Nix.Hash.algoDigestBuilder derivationOutputHash
<> Data.Text.Lazy.Builder.singleton '!'
<> Data.Text.Lazy.Builder.fromText (outputName derivationOutputName)
<> Data.Text.Lazy.Builder.fromText (outputName derivationOutputOutput)
-- | Build realisation context
--

View File

@ -38,7 +38,7 @@ sampleDerivationOutput = DerivationOutput
$ System.Nix.Hash.mkNamedDigest
"sha256"
"1b4sb93wp679q4zx9k1ignby1yna3z7c4c2ri3wphylbc2dwsys0"
, derivationOutputName =
, derivationOutputOutput =
forceRight
$ System.Nix.OutputName.mkOutputName "foo"
}