Skip to content

Commit

Permalink
make DerivationOutput explicitely generic
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sorki committed Dec 6, 2023
1 parent 0415ded commit 641cd4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions hnix-store-core/src/System/Nix/Realisation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
--
Expand Down
2 changes: 1 addition & 1 deletion hnix-store-json/tests/JSONSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ sampleDerivationOutput = DerivationOutput
$ System.Nix.Hash.mkNamedDigest
"sha256"
"1b4sb93wp679q4zx9k1ignby1yna3z7c4c2ri3wphylbc2dwsys0"
, derivationOutputName =
, derivationOutputOutput =
forceRight
$ System.Nix.OutputName.mkOutputName "foo"
}
Expand Down

0 comments on commit 641cd4f

Please sign in to comment.