Skip to content

Even more parametric Derivation#24

Draft
sorki wants to merge 5 commits into
Gabriella439:mainfrom
sorki:srk/parametricV2
Draft

Even more parametric Derivation#24
sorki wants to merge 5 commits into
Gabriella439:mainfrom
sorki:srk/parametricV2

Conversation

@sorki
Copy link
Copy Markdown
Collaborator

@sorki sorki commented Dec 5, 2023

Parametrized on

  • outputName
  • drvOutput
  • drvInputs

Normalizes Derivation inputs and makes it accept different types for all these, which is required to tie some loose ends on hnix/hnix-store side.

I've also removed the (now) useless Functor and Bifunctor instances and passed the lib thru hlint, which doesn't produce any warnings now.

DeriviationOutput is no longer parametrized with text as we replace it completely on our side with

-- | Output of the derivation
data DerivationOutput a = DerivationOutput
  { derivationOutputHash :: DSum HashAlgo Digest
  -- ^ Hash modulo of the derivation
  , derivationOutputOutput :: a
  -- ^ Name of the output
  } deriving (Eq, Generic, Ord, Show)

I've realised this when I've tried to implement Nixes Realisation type 🙃, which also uses DerivationOutput

I hope this accommodates all our needs, and is parametric enough for now - we might want to differentiate between the other txt types in the future though, using some simple newtype wrappers.

I'm tempted to add a type alias to make this look less awkward for downstream users that don't need this level of parametrization (nix-diff, nix-graph), but I'm not sure if it's worth it because then you need to import both Derivation(..) for the fields and the type alias.

I'll try to actually use this first, to see if really fits and then I would add a version bump (possibly CHANGELOG as well), ask you for a release and do the downstream PRs.

sorki added 4 commits December 5, 2023 09:43
Allows to use custom types for both sides of the map.

The main reason for this is `hnix-store` which now uses
`DSum HashAlgo Digest` which combines `hashAlgo` and `hash` fields
of the `DerivationOutput` and `OutputName` type for the keys,
which is similar to how the newtype is done in the mainline Nix.
Normalizes `inputsSrcs` and `inputsDrvs` into `inputs`.

Similar reasons as the previous commit. Allows to embed
mainline Nixes `BasicDerivation` into `Derivation` by using
`inputs` type that only provides source inputs.
sorki added a commit to haskell-nix/hnix-store that referenced this pull request Dec 7, 2023
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 Gabriella439/Haskell-Nix-Derivation-Library#24
sorki added a commit to haskell-nix/hnix-store that referenced this pull request Dec 7, 2023
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 Gabriella439/Haskell-Nix-Derivation-Library#24
ConnorBaker added a commit to ConnorBaker/nix-output-monitor that referenced this pull request Jan 25, 2024
…rary fork

All credit goes to @sorki and @rickynils for their work on:

- Gabriella439/Haskell-Nix-Derivation-Library#26
- Gabriella439/Haskell-Nix-Derivation-Library#24

This commit takes the changes relevant to `Nix.Derivation` and vendors them in-tree.

Co-Authored-By: sorki <srk@48.io>
Co-Authored-By: Rickard Nilsson <rickynils@gmail.com>
ConnorBaker added a commit to ConnorBaker/nix-output-monitor that referenced this pull request Jan 25, 2024
…rary fork

All credit goes to @sorki and @rickynils for their work on:

- Gabriella439/Haskell-Nix-Derivation-Library#26
- Gabriella439/Haskell-Nix-Derivation-Library#24

and of course to @Gabriella439 for the entire library!

This commit takes the changes relevant to `Nix.Derivation` and vendors them in-tree.

Co-Authored-By: Gabriella Gonzalez <Gabriel439@gmail.com>
Co-Authored-By: sorki <srk@48.io>
Co-Authored-By: Rickard Nilsson <rickynils@gmail.com>
ConnorBaker added a commit to ConnorBaker/nix-output-monitor that referenced this pull request Jan 25, 2024
…rary fork

All credit goes to @sorki and @rickynils for their work on:

- Gabriella439/Haskell-Nix-Derivation-Library#26
- Gabriella439/Haskell-Nix-Derivation-Library#24

and of course to @Gabriella439 for the entire library!

This commit takes the changes relevant to `Nix.Derivation` and vendors them in-tree.

Co-Authored-By: Gabriella Gonzalez <Gabriel439@gmail.com>
Co-Authored-By: sorki <srk@48.io>
Co-Authored-By: Rickard Nilsson <rickynils@gmail.com>
ConnorBaker added a commit to ConnorBaker/nix-output-monitor that referenced this pull request Jan 25, 2024
…rary fork

All credit goes to @sorki and @rickynils for their work on:

- Gabriella439/Haskell-Nix-Derivation-Library#26
- Gabriella439/Haskell-Nix-Derivation-Library#24

and of course to @Gabriella439 for the entire library!

This commit takes the changes relevant to `Nix.Derivation` and vendors them in-tree.

Co-Authored-By: Gabriella Gonzalez <Gabriel439@gmail.com>
Co-Authored-By: sorki <srk@48.io>
Co-Authored-By: Rickard Nilsson <rickynils@gmail.com>
@Ericson2314
Copy link
Copy Markdown

#26 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants