{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableSuperClasses #-}

-- | Copyright: (c) 2021-2022 berberman
-- SPDX-License-Identifier: MIT
-- Maintainer: berberman <[email protected]>
-- Stability: experimental
-- Portability: portable
--
-- Types used in this program.
module NvFetcher.Types
  ( -- * Common types
    Version (..),
    Checksum (..),
    ContainerDigest (..),
    Branch (..),
    NixExpr,
    VersionChange (..),
    WithPackageKey (..),

    -- * Nvchecker types
    VersionSortMethod (..),
    ListOptions (..),
    VersionSource (..),
    NvcheckerResult (..),
    NvcheckerRaw (..),
    CheckVersion (..),
    NvcheckerOptions (..),
    UseStaleVersion (..),

    -- * Nix fetcher types
    RunFetch (..),
    ForceFetch (..),
    NixFetcher (..),
    FetchResult,
    FetchStatus (..),

    -- * ExtractSrc Types
    ExtractSrcQ (..),

    -- * FetchRustGitDeps types
    FetchRustGitDepsQ (..),

    -- * GetGitCommitDate types
    DateFormat (..),
    GetGitCommitDate (..),

    -- * Core types
    Core (..),

    -- * Package types
    PackageName,
    PackageFetcher,
    PackageExtractSrc (..),
    PackageCargoLockFiles (..),
    PackagePassthru (..),
    Package (..),
    PackageKey (..),
    PackageResult (..),
  )
where

import qualified Data.Aeson as A
import Data.Coerce (coerce)
import Data.Default
import Data.HashMap.Strict (HashMap)
import qualified Data.List.NonEmpty as NE
import Data.Maybe (fromMaybe, isNothing)
import Data.String (IsString)
import Data.Text (Text)
import qualified Data.Text as T
import Development.Shake
import Development.Shake.Classes
import GHC.Generics (Generic)
import Prettyprinter

--------------------------------------------------------------------------------

-- | Package version
newtype Version = Version Text
  deriving newtype (Version -> Version -> Bool
(Version -> Version -> Bool)
-> (Version -> Version -> Bool) -> Eq Version
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Version -> Version -> Bool
== :: Version -> Version -> Bool
$c/= :: Version -> Version -> Bool
/= :: Version -> Version -> Bool
Eq, Int -> Version -> ShowS
[Version] -> ShowS
Version -> String
(Int -> Version -> ShowS)
-> (Version -> String) -> ([Version] -> ShowS) -> Show Version
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Version -> ShowS
showsPrec :: Int -> Version -> ShowS
$cshow :: Version -> String
show :: Version -> String
$cshowList :: [Version] -> ShowS
showList :: [Version] -> ShowS
Show, Eq Version
Eq Version =>
(Version -> Version -> Ordering)
-> (Version -> Version -> Bool)
-> (Version -> Version -> Bool)
-> (Version -> Version -> Bool)
-> (Version -> Version -> Bool)
-> (Version -> Version -> Version)
-> (Version -> Version -> Version)
-> Ord Version
Version -> Version -> Bool
Version -> Version -> Ordering
Version -> Version -> Version
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Version -> Version -> Ordering
compare :: Version -> Version -> Ordering
$c< :: Version -> Version -> Bool
< :: Version -> Version -> Bool
$c<= :: Version -> Version -> Bool
<= :: Version -> Version -> Bool
$c> :: Version -> Version -> Bool
> :: Version -> Version -> Bool
$c>= :: Version -> Version -> Bool
>= :: Version -> Version -> Bool
$cmax :: Version -> Version -> Version
max :: Version -> Version -> Version
$cmin :: Version -> Version -> Version
min :: Version -> Version -> Version
Ord, String -> Version
(String -> Version) -> IsString Version
forall a. (String -> a) -> IsString a
$cfromString :: String -> Version
fromString :: String -> Version
IsString, NonEmpty Version -> Version
Version -> Version -> Version
(Version -> Version -> Version)
-> (NonEmpty Version -> Version)
-> (forall b. Integral b => b -> Version -> Version)
-> Semigroup Version
forall b. Integral b => b -> Version -> Version
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
$c<> :: Version -> Version -> Version
<> :: Version -> Version -> Version
$csconcat :: NonEmpty Version -> Version
sconcat :: NonEmpty Version -> Version
$cstimes :: forall b. Integral b => b -> Version -> Version
stimes :: forall b. Integral b => b -> Version -> Version
Semigroup, Semigroup Version
Version
Semigroup Version =>
Version
-> (Version -> Version -> Version)
-> ([Version] -> Version)
-> Monoid Version
[Version] -> Version
Version -> Version -> Version
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
$cmempty :: Version
mempty :: Version
$cmappend :: Version -> Version -> Version
mappend :: Version -> Version -> Version
$cmconcat :: [Version] -> Version
mconcat :: [Version] -> Version
Monoid, Value -> Parser [Version]
Value -> Parser Version
(Value -> Parser Version)
-> (Value -> Parser [Version]) -> FromJSON Version
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser Version
parseJSON :: Value -> Parser Version
$cparseJSONList :: Value -> Parser [Version]
parseJSONList :: Value -> Parser [Version]
A.FromJSON, [Version] -> Value
[Version] -> Encoding
Version -> Value
Version -> Encoding
(Version -> Value)
-> (Version -> Encoding)
-> ([Version] -> Value)
-> ([Version] -> Encoding)
-> ToJSON Version
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: Version -> Value
toJSON :: Version -> Value
$ctoEncoding :: Version -> Encoding
toEncoding :: Version -> Encoding
$ctoJSONList :: [Version] -> Value
toJSONList :: [Version] -> Value
$ctoEncodingList :: [Version] -> Encoding
toEncodingList :: [Version] -> Encoding
A.ToJSON, (forall ann. Version -> Doc ann)
-> (forall ann. [Version] -> Doc ann) -> Pretty Version
forall ann. [Version] -> Doc ann
forall ann. Version -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. Version -> Doc ann
pretty :: forall ann. Version -> Doc ann
$cprettyList :: forall ann. [Version] -> Doc ann
prettyList :: forall ann. [Version] -> Doc ann
Pretty)
  deriving stock (Typeable, (forall x. Version -> Rep Version x)
-> (forall x. Rep Version x -> Version) -> Generic Version
forall x. Rep Version x -> Version
forall x. Version -> Rep Version x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Version -> Rep Version x
from :: forall x. Version -> Rep Version x
$cto :: forall x. Rep Version x -> Version
to :: forall x. Rep Version x -> Version
Generic)
  deriving anyclass (Eq Version
Eq Version =>
(Int -> Version -> Int) -> (Version -> Int) -> Hashable Version
Int -> Version -> Int
Version -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> Version -> Int
hashWithSalt :: Int -> Version -> Int
$chash :: Version -> Int
hash :: Version -> Int
Hashable, Get Version
[Version] -> Put
Version -> Put
(Version -> Put)
-> Get Version -> ([Version] -> Put) -> Binary Version
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: Version -> Put
put :: Version -> Put
$cget :: Get Version
get :: Get Version
$cputList :: [Version] -> Put
putList :: [Version] -> Put
Binary, Version -> ()
(Version -> ()) -> NFData Version
forall a. (a -> ()) -> NFData a
$crnf :: Version -> ()
rnf :: Version -> ()
NFData)

-- | Check sum, sha256, sri or base32, etc.
newtype Checksum = Checksum Text
  deriving newtype (Int -> Checksum -> ShowS
[Checksum] -> ShowS
Checksum -> String
(Int -> Checksum -> ShowS)
-> (Checksum -> String) -> ([Checksum] -> ShowS) -> Show Checksum
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Checksum -> ShowS
showsPrec :: Int -> Checksum -> ShowS
$cshow :: Checksum -> String
show :: Checksum -> String
$cshowList :: [Checksum] -> ShowS
showList :: [Checksum] -> ShowS
Show, Checksum -> Checksum -> Bool
(Checksum -> Checksum -> Bool)
-> (Checksum -> Checksum -> Bool) -> Eq Checksum
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Checksum -> Checksum -> Bool
== :: Checksum -> Checksum -> Bool
$c/= :: Checksum -> Checksum -> Bool
/= :: Checksum -> Checksum -> Bool
Eq, Eq Checksum
Eq Checksum =>
(Checksum -> Checksum -> Ordering)
-> (Checksum -> Checksum -> Bool)
-> (Checksum -> Checksum -> Bool)
-> (Checksum -> Checksum -> Bool)
-> (Checksum -> Checksum -> Bool)
-> (Checksum -> Checksum -> Checksum)
-> (Checksum -> Checksum -> Checksum)
-> Ord Checksum
Checksum -> Checksum -> Bool
Checksum -> Checksum -> Ordering
Checksum -> Checksum -> Checksum
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Checksum -> Checksum -> Ordering
compare :: Checksum -> Checksum -> Ordering
$c< :: Checksum -> Checksum -> Bool
< :: Checksum -> Checksum -> Bool
$c<= :: Checksum -> Checksum -> Bool
<= :: Checksum -> Checksum -> Bool
$c> :: Checksum -> Checksum -> Bool
> :: Checksum -> Checksum -> Bool
$c>= :: Checksum -> Checksum -> Bool
>= :: Checksum -> Checksum -> Bool
$cmax :: Checksum -> Checksum -> Checksum
max :: Checksum -> Checksum -> Checksum
$cmin :: Checksum -> Checksum -> Checksum
min :: Checksum -> Checksum -> Checksum
Ord, Value -> Parser [Checksum]
Value -> Parser Checksum
(Value -> Parser Checksum)
-> (Value -> Parser [Checksum]) -> FromJSON Checksum
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser Checksum
parseJSON :: Value -> Parser Checksum
$cparseJSONList :: Value -> Parser [Checksum]
parseJSONList :: Value -> Parser [Checksum]
A.FromJSON, [Checksum] -> Value
[Checksum] -> Encoding
Checksum -> Value
Checksum -> Encoding
(Checksum -> Value)
-> (Checksum -> Encoding)
-> ([Checksum] -> Value)
-> ([Checksum] -> Encoding)
-> ToJSON Checksum
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: Checksum -> Value
toJSON :: Checksum -> Value
$ctoEncoding :: Checksum -> Encoding
toEncoding :: Checksum -> Encoding
$ctoJSONList :: [Checksum] -> Value
toJSONList :: [Checksum] -> Value
$ctoEncodingList :: [Checksum] -> Encoding
toEncodingList :: [Checksum] -> Encoding
A.ToJSON, (forall ann. Checksum -> Doc ann)
-> (forall ann. [Checksum] -> Doc ann) -> Pretty Checksum
forall ann. [Checksum] -> Doc ann
forall ann. Checksum -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. Checksum -> Doc ann
pretty :: forall ann. Checksum -> Doc ann
$cprettyList :: forall ann. [Checksum] -> Doc ann
prettyList :: forall ann. [Checksum] -> Doc ann
Pretty)
  deriving stock (Typeable, (forall x. Checksum -> Rep Checksum x)
-> (forall x. Rep Checksum x -> Checksum) -> Generic Checksum
forall x. Rep Checksum x -> Checksum
forall x. Checksum -> Rep Checksum x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Checksum -> Rep Checksum x
from :: forall x. Checksum -> Rep Checksum x
$cto :: forall x. Rep Checksum x -> Checksum
to :: forall x. Rep Checksum x -> Checksum
Generic)
  deriving anyclass (Eq Checksum
Eq Checksum =>
(Int -> Checksum -> Int) -> (Checksum -> Int) -> Hashable Checksum
Int -> Checksum -> Int
Checksum -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> Checksum -> Int
hashWithSalt :: Int -> Checksum -> Int
$chash :: Checksum -> Int
hash :: Checksum -> Int
Hashable, Get Checksum
[Checksum] -> Put
Checksum -> Put
(Checksum -> Put)
-> Get Checksum -> ([Checksum] -> Put) -> Binary Checksum
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: Checksum -> Put
put :: Checksum -> Put
$cget :: Get Checksum
get :: Get Checksum
$cputList :: [Checksum] -> Put
putList :: [Checksum] -> Put
Binary, Checksum -> ()
(Checksum -> ()) -> NFData Checksum
forall a. (a -> ()) -> NFData a
$crnf :: Checksum -> ()
rnf :: Checksum -> ()
NFData)

-- | Digest of a (Docker) container
newtype ContainerDigest = ContainerDigest Text
  deriving newtype (Int -> ContainerDigest -> ShowS
[ContainerDigest] -> ShowS
ContainerDigest -> String
(Int -> ContainerDigest -> ShowS)
-> (ContainerDigest -> String)
-> ([ContainerDigest] -> ShowS)
-> Show ContainerDigest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ContainerDigest -> ShowS
showsPrec :: Int -> ContainerDigest -> ShowS
$cshow :: ContainerDigest -> String
show :: ContainerDigest -> String
$cshowList :: [ContainerDigest] -> ShowS
showList :: [ContainerDigest] -> ShowS
Show, ContainerDigest -> ContainerDigest -> Bool
(ContainerDigest -> ContainerDigest -> Bool)
-> (ContainerDigest -> ContainerDigest -> Bool)
-> Eq ContainerDigest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ContainerDigest -> ContainerDigest -> Bool
== :: ContainerDigest -> ContainerDigest -> Bool
$c/= :: ContainerDigest -> ContainerDigest -> Bool
/= :: ContainerDigest -> ContainerDigest -> Bool
Eq, Eq ContainerDigest
Eq ContainerDigest =>
(ContainerDigest -> ContainerDigest -> Ordering)
-> (ContainerDigest -> ContainerDigest -> Bool)
-> (ContainerDigest -> ContainerDigest -> Bool)
-> (ContainerDigest -> ContainerDigest -> Bool)
-> (ContainerDigest -> ContainerDigest -> Bool)
-> (ContainerDigest -> ContainerDigest -> ContainerDigest)
-> (ContainerDigest -> ContainerDigest -> ContainerDigest)
-> Ord ContainerDigest
ContainerDigest -> ContainerDigest -> Bool
ContainerDigest -> ContainerDigest -> Ordering
ContainerDigest -> ContainerDigest -> ContainerDigest
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ContainerDigest -> ContainerDigest -> Ordering
compare :: ContainerDigest -> ContainerDigest -> Ordering
$c< :: ContainerDigest -> ContainerDigest -> Bool
< :: ContainerDigest -> ContainerDigest -> Bool
$c<= :: ContainerDigest -> ContainerDigest -> Bool
<= :: ContainerDigest -> ContainerDigest -> Bool
$c> :: ContainerDigest -> ContainerDigest -> Bool
> :: ContainerDigest -> ContainerDigest -> Bool
$c>= :: ContainerDigest -> ContainerDigest -> Bool
>= :: ContainerDigest -> ContainerDigest -> Bool
$cmax :: ContainerDigest -> ContainerDigest -> ContainerDigest
max :: ContainerDigest -> ContainerDigest -> ContainerDigest
$cmin :: ContainerDigest -> ContainerDigest -> ContainerDigest
min :: ContainerDigest -> ContainerDigest -> ContainerDigest
Ord, Value -> Parser [ContainerDigest]
Value -> Parser ContainerDigest
(Value -> Parser ContainerDigest)
-> (Value -> Parser [ContainerDigest]) -> FromJSON ContainerDigest
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser ContainerDigest
parseJSON :: Value -> Parser ContainerDigest
$cparseJSONList :: Value -> Parser [ContainerDigest]
parseJSONList :: Value -> Parser [ContainerDigest]
A.FromJSON, [ContainerDigest] -> Value
[ContainerDigest] -> Encoding
ContainerDigest -> Value
ContainerDigest -> Encoding
(ContainerDigest -> Value)
-> (ContainerDigest -> Encoding)
-> ([ContainerDigest] -> Value)
-> ([ContainerDigest] -> Encoding)
-> ToJSON ContainerDigest
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: ContainerDigest -> Value
toJSON :: ContainerDigest -> Value
$ctoEncoding :: ContainerDigest -> Encoding
toEncoding :: ContainerDigest -> Encoding
$ctoJSONList :: [ContainerDigest] -> Value
toJSONList :: [ContainerDigest] -> Value
$ctoEncodingList :: [ContainerDigest] -> Encoding
toEncodingList :: [ContainerDigest] -> Encoding
A.ToJSON, (forall ann. ContainerDigest -> Doc ann)
-> (forall ann. [ContainerDigest] -> Doc ann)
-> Pretty ContainerDigest
forall ann. [ContainerDigest] -> Doc ann
forall ann. ContainerDigest -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. ContainerDigest -> Doc ann
pretty :: forall ann. ContainerDigest -> Doc ann
$cprettyList :: forall ann. [ContainerDigest] -> Doc ann
prettyList :: forall ann. [ContainerDigest] -> Doc ann
Pretty)
  deriving stock (Typeable, (forall x. ContainerDigest -> Rep ContainerDigest x)
-> (forall x. Rep ContainerDigest x -> ContainerDigest)
-> Generic ContainerDigest
forall x. Rep ContainerDigest x -> ContainerDigest
forall x. ContainerDigest -> Rep ContainerDigest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ContainerDigest -> Rep ContainerDigest x
from :: forall x. ContainerDigest -> Rep ContainerDigest x
$cto :: forall x. Rep ContainerDigest x -> ContainerDigest
to :: forall x. Rep ContainerDigest x -> ContainerDigest
Generic)
  deriving anyclass (Eq ContainerDigest
Eq ContainerDigest =>
(Int -> ContainerDigest -> Int)
-> (ContainerDigest -> Int) -> Hashable ContainerDigest
Int -> ContainerDigest -> Int
ContainerDigest -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> ContainerDigest -> Int
hashWithSalt :: Int -> ContainerDigest -> Int
$chash :: ContainerDigest -> Int
hash :: ContainerDigest -> Int
Hashable, Get ContainerDigest
[ContainerDigest] -> Put
ContainerDigest -> Put
(ContainerDigest -> Put)
-> Get ContainerDigest
-> ([ContainerDigest] -> Put)
-> Binary ContainerDigest
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: ContainerDigest -> Put
put :: ContainerDigest -> Put
$cget :: Get ContainerDigest
get :: Get ContainerDigest
$cputList :: [ContainerDigest] -> Put
putList :: [ContainerDigest] -> Put
Binary, ContainerDigest -> ()
(ContainerDigest -> ()) -> NFData ContainerDigest
forall a. (a -> ()) -> NFData a
$crnf :: ContainerDigest -> ()
rnf :: ContainerDigest -> ()
NFData)

-- | Git branch ('Nothing': master)
newtype Branch = Branch (Maybe Text)
  deriving newtype (Int -> Branch -> ShowS
[Branch] -> ShowS
Branch -> String
(Int -> Branch -> ShowS)
-> (Branch -> String) -> ([Branch] -> ShowS) -> Show Branch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Branch -> ShowS
showsPrec :: Int -> Branch -> ShowS
$cshow :: Branch -> String
show :: Branch -> String
$cshowList :: [Branch] -> ShowS
showList :: [Branch] -> ShowS
Show, Branch -> Branch -> Bool
(Branch -> Branch -> Bool)
-> (Branch -> Branch -> Bool) -> Eq Branch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Branch -> Branch -> Bool
== :: Branch -> Branch -> Bool
$c/= :: Branch -> Branch -> Bool
/= :: Branch -> Branch -> Bool
Eq, Eq Branch
Eq Branch =>
(Branch -> Branch -> Ordering)
-> (Branch -> Branch -> Bool)
-> (Branch -> Branch -> Bool)
-> (Branch -> Branch -> Bool)
-> (Branch -> Branch -> Bool)
-> (Branch -> Branch -> Branch)
-> (Branch -> Branch -> Branch)
-> Ord Branch
Branch -> Branch -> Bool
Branch -> Branch -> Ordering
Branch -> Branch -> Branch
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Branch -> Branch -> Ordering
compare :: Branch -> Branch -> Ordering
$c< :: Branch -> Branch -> Bool
< :: Branch -> Branch -> Bool
$c<= :: Branch -> Branch -> Bool
<= :: Branch -> Branch -> Bool
$c> :: Branch -> Branch -> Bool
> :: Branch -> Branch -> Bool
$c>= :: Branch -> Branch -> Bool
>= :: Branch -> Branch -> Bool
$cmax :: Branch -> Branch -> Branch
max :: Branch -> Branch -> Branch
$cmin :: Branch -> Branch -> Branch
min :: Branch -> Branch -> Branch
Ord, Branch
Branch -> Default Branch
forall a. a -> Default a
$cdef :: Branch
def :: Branch
Default, (forall ann. Branch -> Doc ann)
-> (forall ann. [Branch] -> Doc ann) -> Pretty Branch
forall ann. [Branch] -> Doc ann
forall ann. Branch -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. Branch -> Doc ann
pretty :: forall ann. Branch -> Doc ann
$cprettyList :: forall ann. [Branch] -> Doc ann
prettyList :: forall ann. [Branch] -> Doc ann
Pretty)
  deriving stock (Typeable, (forall x. Branch -> Rep Branch x)
-> (forall x. Rep Branch x -> Branch) -> Generic Branch
forall x. Rep Branch x -> Branch
forall x. Branch -> Rep Branch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Branch -> Rep Branch x
from :: forall x. Branch -> Rep Branch x
$cto :: forall x. Rep Branch x -> Branch
to :: forall x. Rep Branch x -> Branch
Generic)
  deriving anyclass (Eq Branch
Eq Branch =>
(Int -> Branch -> Int) -> (Branch -> Int) -> Hashable Branch
Int -> Branch -> Int
Branch -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> Branch -> Int
hashWithSalt :: Int -> Branch -> Int
$chash :: Branch -> Int
hash :: Branch -> Int
Hashable, Get Branch
[Branch] -> Put
Branch -> Put
(Branch -> Put) -> Get Branch -> ([Branch] -> Put) -> Binary Branch
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: Branch -> Put
put :: Branch -> Put
$cget :: Get Branch
get :: Get Branch
$cputList :: [Branch] -> Put
putList :: [Branch] -> Put
Binary, Branch -> ()
(Branch -> ()) -> NFData Branch
forall a. (a -> ()) -> NFData a
$crnf :: Branch -> ()
rnf :: Branch -> ()
NFData)

-- | Version change of a package
--
-- >>> VersionChange "foo" Nothing "2.3.3"
-- foo: ∅ → 2.3.3
--
-- >>> VersionChange "bar" (Just "2.2.2") "2.3.3"
-- bar: 2.2.2 → 2.3.3
data VersionChange = VersionChange
  { VersionChange -> Text
vcName :: PackageName,
    VersionChange -> Maybe Version
vcOld :: Maybe Version,
    VersionChange -> Version
vcNew :: Version
  }
  deriving (VersionChange -> VersionChange -> Bool
(VersionChange -> VersionChange -> Bool)
-> (VersionChange -> VersionChange -> Bool) -> Eq VersionChange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VersionChange -> VersionChange -> Bool
== :: VersionChange -> VersionChange -> Bool
$c/= :: VersionChange -> VersionChange -> Bool
/= :: VersionChange -> VersionChange -> Bool
Eq)

instance Show VersionChange where
  show :: VersionChange -> String
show VersionChange {Maybe Version
Text
Version
vcName :: VersionChange -> Text
vcOld :: VersionChange -> Maybe Version
vcNew :: VersionChange -> Version
vcName :: Text
vcOld :: Maybe Version
vcNew :: Version
..} =
    Text -> String
T.unpack (Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ Text
vcName Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
": " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"∅" (Maybe Version -> Maybe Text
forall a b. Coercible a b => a -> b
coerce Maybe Version
vcOld) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" → " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Version -> Text
forall a b. Coercible a b => a -> b
coerce Version
vcNew

-- | Nix expression
type NixExpr = Text

--------------------------------------------------------------------------------

data VersionSortMethod = ParseVersion | Vercmp
  deriving (Typeable, VersionSortMethod -> VersionSortMethod -> Bool
(VersionSortMethod -> VersionSortMethod -> Bool)
-> (VersionSortMethod -> VersionSortMethod -> Bool)
-> Eq VersionSortMethod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VersionSortMethod -> VersionSortMethod -> Bool
== :: VersionSortMethod -> VersionSortMethod -> Bool
$c/= :: VersionSortMethod -> VersionSortMethod -> Bool
/= :: VersionSortMethod -> VersionSortMethod -> Bool
Eq, Eq VersionSortMethod
Eq VersionSortMethod =>
(VersionSortMethod -> VersionSortMethod -> Ordering)
-> (VersionSortMethod -> VersionSortMethod -> Bool)
-> (VersionSortMethod -> VersionSortMethod -> Bool)
-> (VersionSortMethod -> VersionSortMethod -> Bool)
-> (VersionSortMethod -> VersionSortMethod -> Bool)
-> (VersionSortMethod -> VersionSortMethod -> VersionSortMethod)
-> (VersionSortMethod -> VersionSortMethod -> VersionSortMethod)
-> Ord VersionSortMethod
VersionSortMethod -> VersionSortMethod -> Bool
VersionSortMethod -> VersionSortMethod -> Ordering
VersionSortMethod -> VersionSortMethod -> VersionSortMethod
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: VersionSortMethod -> VersionSortMethod -> Ordering
compare :: VersionSortMethod -> VersionSortMethod -> Ordering
$c< :: VersionSortMethod -> VersionSortMethod -> Bool
< :: VersionSortMethod -> VersionSortMethod -> Bool
$c<= :: VersionSortMethod -> VersionSortMethod -> Bool
<= :: VersionSortMethod -> VersionSortMethod -> Bool
$c> :: VersionSortMethod -> VersionSortMethod -> Bool
> :: VersionSortMethod -> VersionSortMethod -> Bool
$c>= :: VersionSortMethod -> VersionSortMethod -> Bool
>= :: VersionSortMethod -> VersionSortMethod -> Bool
$cmax :: VersionSortMethod -> VersionSortMethod -> VersionSortMethod
max :: VersionSortMethod -> VersionSortMethod -> VersionSortMethod
$cmin :: VersionSortMethod -> VersionSortMethod -> VersionSortMethod
min :: VersionSortMethod -> VersionSortMethod -> VersionSortMethod
Ord, Int -> VersionSortMethod
VersionSortMethod -> Int
VersionSortMethod -> [VersionSortMethod]
VersionSortMethod -> VersionSortMethod
VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
VersionSortMethod
-> VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
(VersionSortMethod -> VersionSortMethod)
-> (VersionSortMethod -> VersionSortMethod)
-> (Int -> VersionSortMethod)
-> (VersionSortMethod -> Int)
-> (VersionSortMethod -> [VersionSortMethod])
-> (VersionSortMethod -> VersionSortMethod -> [VersionSortMethod])
-> (VersionSortMethod -> VersionSortMethod -> [VersionSortMethod])
-> (VersionSortMethod
    -> VersionSortMethod -> VersionSortMethod -> [VersionSortMethod])
-> Enum VersionSortMethod
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: VersionSortMethod -> VersionSortMethod
succ :: VersionSortMethod -> VersionSortMethod
$cpred :: VersionSortMethod -> VersionSortMethod
pred :: VersionSortMethod -> VersionSortMethod
$ctoEnum :: Int -> VersionSortMethod
toEnum :: Int -> VersionSortMethod
$cfromEnum :: VersionSortMethod -> Int
fromEnum :: VersionSortMethod -> Int
$cenumFrom :: VersionSortMethod -> [VersionSortMethod]
enumFrom :: VersionSortMethod -> [VersionSortMethod]
$cenumFromThen :: VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
enumFromThen :: VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
$cenumFromTo :: VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
enumFromTo :: VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
$cenumFromThenTo :: VersionSortMethod
-> VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
enumFromThenTo :: VersionSortMethod
-> VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
Enum, (forall x. VersionSortMethod -> Rep VersionSortMethod x)
-> (forall x. Rep VersionSortMethod x -> VersionSortMethod)
-> Generic VersionSortMethod
forall x. Rep VersionSortMethod x -> VersionSortMethod
forall x. VersionSortMethod -> Rep VersionSortMethod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. VersionSortMethod -> Rep VersionSortMethod x
from :: forall x. VersionSortMethod -> Rep VersionSortMethod x
$cto :: forall x. Rep VersionSortMethod x -> VersionSortMethod
to :: forall x. Rep VersionSortMethod x -> VersionSortMethod
Generic, Eq VersionSortMethod
Eq VersionSortMethod =>
(Int -> VersionSortMethod -> Int)
-> (VersionSortMethod -> Int) -> Hashable VersionSortMethod
Int -> VersionSortMethod -> Int
VersionSortMethod -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> VersionSortMethod -> Int
hashWithSalt :: Int -> VersionSortMethod -> Int
$chash :: VersionSortMethod -> Int
hash :: VersionSortMethod -> Int
Hashable, Get VersionSortMethod
[VersionSortMethod] -> Put
VersionSortMethod -> Put
(VersionSortMethod -> Put)
-> Get VersionSortMethod
-> ([VersionSortMethod] -> Put)
-> Binary VersionSortMethod
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: VersionSortMethod -> Put
put :: VersionSortMethod -> Put
$cget :: Get VersionSortMethod
get :: Get VersionSortMethod
$cputList :: [VersionSortMethod] -> Put
putList :: [VersionSortMethod] -> Put
Binary, VersionSortMethod -> ()
(VersionSortMethod -> ()) -> NFData VersionSortMethod
forall a. (a -> ()) -> NFData a
$crnf :: VersionSortMethod -> ()
rnf :: VersionSortMethod -> ()
NFData)

instance Show VersionSortMethod where
  show :: VersionSortMethod -> String
show = \case
    VersionSortMethod
ParseVersion -> String
"parse_version"
    VersionSortMethod
Vercmp -> String
"vercmp"

instance Pretty VersionSortMethod where
  pretty :: forall ann. VersionSortMethod -> Doc ann
pretty VersionSortMethod
ParseVersion = Doc ann
"ParseVersion"
  pretty VersionSortMethod
Vercmp = Doc ann
"Vercmp"

instance Default VersionSortMethod where
  def :: VersionSortMethod
def = VersionSortMethod
ParseVersion

-- | Filter-like configuration for some version sources.
-- See <https://nvchecker.readthedocs.io/en/latest/usage.html#list-options> for details.
data ListOptions = ListOptions
  { ListOptions -> Maybe Text
_includeRegex :: Maybe Text,
    ListOptions -> Maybe Text
_excludeRegex :: Maybe Text,
    ListOptions -> Maybe VersionSortMethod
_sortVersionKey :: Maybe VersionSortMethod,
    ListOptions -> Maybe Text
_ignored :: Maybe Text
  }
  deriving (Int -> ListOptions -> ShowS
[ListOptions] -> ShowS
ListOptions -> String
(Int -> ListOptions -> ShowS)
-> (ListOptions -> String)
-> ([ListOptions] -> ShowS)
-> Show ListOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ListOptions -> ShowS
showsPrec :: Int -> ListOptions -> ShowS
$cshow :: ListOptions -> String
show :: ListOptions -> String
$cshowList :: [ListOptions] -> ShowS
showList :: [ListOptions] -> ShowS
Show, Typeable, ListOptions -> ListOptions -> Bool
(ListOptions -> ListOptions -> Bool)
-> (ListOptions -> ListOptions -> Bool) -> Eq ListOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ListOptions -> ListOptions -> Bool
== :: ListOptions -> ListOptions -> Bool
$c/= :: ListOptions -> ListOptions -> Bool
/= :: ListOptions -> ListOptions -> Bool
Eq, Eq ListOptions
Eq ListOptions =>
(ListOptions -> ListOptions -> Ordering)
-> (ListOptions -> ListOptions -> Bool)
-> (ListOptions -> ListOptions -> Bool)
-> (ListOptions -> ListOptions -> Bool)
-> (ListOptions -> ListOptions -> Bool)
-> (ListOptions -> ListOptions -> ListOptions)
-> (ListOptions -> ListOptions -> ListOptions)
-> Ord ListOptions
ListOptions -> ListOptions -> Bool
ListOptions -> ListOptions -> Ordering
ListOptions -> ListOptions -> ListOptions
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ListOptions -> ListOptions -> Ordering
compare :: ListOptions -> ListOptions -> Ordering
$c< :: ListOptions -> ListOptions -> Bool
< :: ListOptions -> ListOptions -> Bool
$c<= :: ListOptions -> ListOptions -> Bool
<= :: ListOptions -> ListOptions -> Bool
$c> :: ListOptions -> ListOptions -> Bool
> :: ListOptions -> ListOptions -> Bool
$c>= :: ListOptions -> ListOptions -> Bool
>= :: ListOptions -> ListOptions -> Bool
$cmax :: ListOptions -> ListOptions -> ListOptions
max :: ListOptions -> ListOptions -> ListOptions
$cmin :: ListOptions -> ListOptions -> ListOptions
min :: ListOptions -> ListOptions -> ListOptions
Ord, (forall x. ListOptions -> Rep ListOptions x)
-> (forall x. Rep ListOptions x -> ListOptions)
-> Generic ListOptions
forall x. Rep ListOptions x -> ListOptions
forall x. ListOptions -> Rep ListOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ListOptions -> Rep ListOptions x
from :: forall x. ListOptions -> Rep ListOptions x
$cto :: forall x. Rep ListOptions x -> ListOptions
to :: forall x. Rep ListOptions x -> ListOptions
Generic, Eq ListOptions
Eq ListOptions =>
(Int -> ListOptions -> Int)
-> (ListOptions -> Int) -> Hashable ListOptions
Int -> ListOptions -> Int
ListOptions -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> ListOptions -> Int
hashWithSalt :: Int -> ListOptions -> Int
$chash :: ListOptions -> Int
hash :: ListOptions -> Int
Hashable, Get ListOptions
[ListOptions] -> Put
ListOptions -> Put
(ListOptions -> Put)
-> Get ListOptions -> ([ListOptions] -> Put) -> Binary ListOptions
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: ListOptions -> Put
put :: ListOptions -> Put
$cget :: Get ListOptions
get :: Get ListOptions
$cputList :: [ListOptions] -> Put
putList :: [ListOptions] -> Put
Binary, ListOptions -> ()
(ListOptions -> ()) -> NFData ListOptions
forall a. (a -> ()) -> NFData a
$crnf :: ListOptions -> ()
rnf :: ListOptions -> ()
NFData, ListOptions
ListOptions -> Default ListOptions
forall a. a -> Default a
$cdef :: ListOptions
def :: ListOptions
Default)

isEmptyListOptions :: ListOptions -> Bool
isEmptyListOptions :: ListOptions -> Bool
isEmptyListOptions ListOptions {Maybe Text
Maybe VersionSortMethod
_includeRegex :: ListOptions -> Maybe Text
_excludeRegex :: ListOptions -> Maybe Text
_sortVersionKey :: ListOptions -> Maybe VersionSortMethod
_ignored :: ListOptions -> Maybe Text
_includeRegex :: Maybe Text
_excludeRegex :: Maybe Text
_sortVersionKey :: Maybe VersionSortMethod
_ignored :: Maybe Text
..} =
  Maybe Text -> Bool
forall a. Maybe a -> Bool
isNothing Maybe Text
_includeRegex
    Bool -> Bool -> Bool
&& Maybe Text -> Bool
forall a. Maybe a -> Bool
isNothing Maybe Text
_excludeRegex
    Bool -> Bool -> Bool
&& Maybe VersionSortMethod -> Bool
forall a. Maybe a -> Bool
isNothing Maybe VersionSortMethod
_sortVersionKey
    Bool -> Bool -> Bool
&& Maybe Text -> Bool
forall a. Maybe a -> Bool
isNothing Maybe Text
_includeRegex

instance Pretty ListOptions where
  pretty :: forall ann. ListOptions -> Doc ann
pretty ListOptions {Maybe Text
Maybe VersionSortMethod
_includeRegex :: ListOptions -> Maybe Text
_excludeRegex :: ListOptions -> Maybe Text
_sortVersionKey :: ListOptions -> Maybe VersionSortMethod
_ignored :: ListOptions -> Maybe Text
_includeRegex :: Maybe Text
_excludeRegex :: Maybe Text
_sortVersionKey :: Maybe VersionSortMethod
_ignored :: Maybe Text
..} =
    Doc ann
"ListOptions"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
forall a b. (a -> b) -> a -> b
$
            [[Doc ann]] -> [Doc ann]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
              [ Doc ann -> Maybe Text -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"includeRegex" Maybe Text
_includeRegex,
                Doc ann -> Maybe Text -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"excludeRegex" Maybe Text
_excludeRegex,
                Doc ann -> Maybe VersionSortMethod -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"sortVersionKey" Maybe VersionSortMethod
_sortVersionKey,
                Doc ann -> Maybe Text -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"ignored" Maybe Text
_includeRegex
              ]
        )

-- | Configuration available for evey version sourece.
-- See <https://nvchecker.readthedocs.io/en/latest/usage.html#global-options> for details.
data NvcheckerOptions = NvcheckerOptions
  { NvcheckerOptions -> Maybe Text
_stripPrefix :: Maybe Text,
    NvcheckerOptions -> Maybe Text
_fromPattern :: Maybe Text,
    NvcheckerOptions -> Maybe Text
_toPattern :: Maybe Text
  }
  deriving (Int -> NvcheckerOptions -> ShowS
[NvcheckerOptions] -> ShowS
NvcheckerOptions -> String
(Int -> NvcheckerOptions -> ShowS)
-> (NvcheckerOptions -> String)
-> ([NvcheckerOptions] -> ShowS)
-> Show NvcheckerOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NvcheckerOptions -> ShowS
showsPrec :: Int -> NvcheckerOptions -> ShowS
$cshow :: NvcheckerOptions -> String
show :: NvcheckerOptions -> String
$cshowList :: [NvcheckerOptions] -> ShowS
showList :: [NvcheckerOptions] -> ShowS
Show, Typeable, NvcheckerOptions -> NvcheckerOptions -> Bool
(NvcheckerOptions -> NvcheckerOptions -> Bool)
-> (NvcheckerOptions -> NvcheckerOptions -> Bool)
-> Eq NvcheckerOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NvcheckerOptions -> NvcheckerOptions -> Bool
== :: NvcheckerOptions -> NvcheckerOptions -> Bool
$c/= :: NvcheckerOptions -> NvcheckerOptions -> Bool
/= :: NvcheckerOptions -> NvcheckerOptions -> Bool
Eq, Eq NvcheckerOptions
Eq NvcheckerOptions =>
(NvcheckerOptions -> NvcheckerOptions -> Ordering)
-> (NvcheckerOptions -> NvcheckerOptions -> Bool)
-> (NvcheckerOptions -> NvcheckerOptions -> Bool)
-> (NvcheckerOptions -> NvcheckerOptions -> Bool)
-> (NvcheckerOptions -> NvcheckerOptions -> Bool)
-> (NvcheckerOptions -> NvcheckerOptions -> NvcheckerOptions)
-> (NvcheckerOptions -> NvcheckerOptions -> NvcheckerOptions)
-> Ord NvcheckerOptions
NvcheckerOptions -> NvcheckerOptions -> Bool
NvcheckerOptions -> NvcheckerOptions -> Ordering
NvcheckerOptions -> NvcheckerOptions -> NvcheckerOptions
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: NvcheckerOptions -> NvcheckerOptions -> Ordering
compare :: NvcheckerOptions -> NvcheckerOptions -> Ordering
$c< :: NvcheckerOptions -> NvcheckerOptions -> Bool
< :: NvcheckerOptions -> NvcheckerOptions -> Bool
$c<= :: NvcheckerOptions -> NvcheckerOptions -> Bool
<= :: NvcheckerOptions -> NvcheckerOptions -> Bool
$c> :: NvcheckerOptions -> NvcheckerOptions -> Bool
> :: NvcheckerOptions -> NvcheckerOptions -> Bool
$c>= :: NvcheckerOptions -> NvcheckerOptions -> Bool
>= :: NvcheckerOptions -> NvcheckerOptions -> Bool
$cmax :: NvcheckerOptions -> NvcheckerOptions -> NvcheckerOptions
max :: NvcheckerOptions -> NvcheckerOptions -> NvcheckerOptions
$cmin :: NvcheckerOptions -> NvcheckerOptions -> NvcheckerOptions
min :: NvcheckerOptions -> NvcheckerOptions -> NvcheckerOptions
Ord, (forall x. NvcheckerOptions -> Rep NvcheckerOptions x)
-> (forall x. Rep NvcheckerOptions x -> NvcheckerOptions)
-> Generic NvcheckerOptions
forall x. Rep NvcheckerOptions x -> NvcheckerOptions
forall x. NvcheckerOptions -> Rep NvcheckerOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NvcheckerOptions -> Rep NvcheckerOptions x
from :: forall x. NvcheckerOptions -> Rep NvcheckerOptions x
$cto :: forall x. Rep NvcheckerOptions x -> NvcheckerOptions
to :: forall x. Rep NvcheckerOptions x -> NvcheckerOptions
Generic, Eq NvcheckerOptions
Eq NvcheckerOptions =>
(Int -> NvcheckerOptions -> Int)
-> (NvcheckerOptions -> Int) -> Hashable NvcheckerOptions
Int -> NvcheckerOptions -> Int
NvcheckerOptions -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> NvcheckerOptions -> Int
hashWithSalt :: Int -> NvcheckerOptions -> Int
$chash :: NvcheckerOptions -> Int
hash :: NvcheckerOptions -> Int
Hashable, Get NvcheckerOptions
[NvcheckerOptions] -> Put
NvcheckerOptions -> Put
(NvcheckerOptions -> Put)
-> Get NvcheckerOptions
-> ([NvcheckerOptions] -> Put)
-> Binary NvcheckerOptions
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: NvcheckerOptions -> Put
put :: NvcheckerOptions -> Put
$cget :: Get NvcheckerOptions
get :: Get NvcheckerOptions
$cputList :: [NvcheckerOptions] -> Put
putList :: [NvcheckerOptions] -> Put
Binary, NvcheckerOptions -> ()
(NvcheckerOptions -> ()) -> NFData NvcheckerOptions
forall a. (a -> ()) -> NFData a
$crnf :: NvcheckerOptions -> ()
rnf :: NvcheckerOptions -> ()
NFData, NvcheckerOptions
NvcheckerOptions -> Default NvcheckerOptions
forall a. a -> Default a
$cdef :: NvcheckerOptions
def :: NvcheckerOptions
Default)

isEmptyNvcheckerOptions :: NvcheckerOptions -> Bool
isEmptyNvcheckerOptions :: NvcheckerOptions -> Bool
isEmptyNvcheckerOptions NvcheckerOptions {Maybe Text
_stripPrefix :: NvcheckerOptions -> Maybe Text
_fromPattern :: NvcheckerOptions -> Maybe Text
_toPattern :: NvcheckerOptions -> Maybe Text
_stripPrefix :: Maybe Text
_fromPattern :: Maybe Text
_toPattern :: Maybe Text
..} =
  Maybe Text -> Bool
forall a. Maybe a -> Bool
isNothing Maybe Text
_stripPrefix
    Bool -> Bool -> Bool
&& Maybe Text -> Bool
forall a. Maybe a -> Bool
isNothing Maybe Text
_fromPattern
    Bool -> Bool -> Bool
&& Maybe Text -> Bool
forall a. Maybe a -> Bool
isNothing Maybe Text
_toPattern

instance Pretty NvcheckerOptions where
  pretty :: forall ann. NvcheckerOptions -> Doc ann
pretty NvcheckerOptions {Maybe Text
_stripPrefix :: NvcheckerOptions -> Maybe Text
_fromPattern :: NvcheckerOptions -> Maybe Text
_toPattern :: NvcheckerOptions -> Maybe Text
_stripPrefix :: Maybe Text
_fromPattern :: Maybe Text
_toPattern :: Maybe Text
..} =
    Doc ann
"NvcheckerOptions"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
forall a b. (a -> b) -> a -> b
$
            [[Doc ann]] -> [Doc ann]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
              [ Doc ann -> Maybe Text -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"stripPrefix" Maybe Text
_stripPrefix,
                Doc ann -> Maybe Text -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"fromPattern" Maybe Text
_fromPattern,
                Doc ann -> Maybe Text -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"toPattern" Maybe Text
_toPattern
              ]
        )

ppField :: Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField :: forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
_ Maybe a
Nothing = []
ppField Doc ann
s (Just a
x) = [Doc ann
s Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> a -> Doc ann
forall ann. a -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty a
x]

-- | Upstream version source for nvchecker to check
data VersionSource
  = GitHubRelease {VersionSource -> Text
_owner :: Text, VersionSource -> Text
_repo :: Text}
  | GitHubTag {_owner :: Text, _repo :: Text, VersionSource -> ListOptions
_listOptions :: ListOptions}
  | Git {VersionSource -> Text
_vurl :: Text, VersionSource -> Branch
_vbranch :: Branch}
  | Pypi {VersionSource -> Text
_pypi :: Text}
  | ArchLinux {VersionSource -> Text
_archpkg :: Text}
  | Aur {VersionSource -> Text
_aur :: Text}
  | Manual {VersionSource -> Text
_manual :: Text}
  | Repology {VersionSource -> Text
_repology :: Text, _repo :: Text}
  | Webpage {_vurl :: Text, VersionSource -> Text
_regex :: Text, _listOptions :: ListOptions}
  | HttpHeader {_vurl :: Text, _regex :: Text, _listOptions :: ListOptions}
  | OpenVsx {VersionSource -> Text
_ovPublisher :: Text, VersionSource -> Text
_ovExtName :: Text}
  | VscodeMarketplace {VersionSource -> Text
_vsmPublisher :: Text, VersionSource -> Text
_vsmExtName :: Text}
  | Cmd {VersionSource -> Text
_vcmd :: Text}
  | Container {VersionSource -> Text
_vcontainer :: Text, _listOptions :: ListOptions}
  deriving (Int -> VersionSource -> ShowS
[VersionSource] -> ShowS
VersionSource -> String
(Int -> VersionSource -> ShowS)
-> (VersionSource -> String)
-> ([VersionSource] -> ShowS)
-> Show VersionSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VersionSource -> ShowS
showsPrec :: Int -> VersionSource -> ShowS
$cshow :: VersionSource -> String
show :: VersionSource -> String
$cshowList :: [VersionSource] -> ShowS
showList :: [VersionSource] -> ShowS
Show, Typeable, VersionSource -> VersionSource -> Bool
(VersionSource -> VersionSource -> Bool)
-> (VersionSource -> VersionSource -> Bool) -> Eq VersionSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VersionSource -> VersionSource -> Bool
== :: VersionSource -> VersionSource -> Bool
$c/= :: VersionSource -> VersionSource -> Bool
/= :: VersionSource -> VersionSource -> Bool
Eq, Eq VersionSource
Eq VersionSource =>
(VersionSource -> VersionSource -> Ordering)
-> (VersionSource -> VersionSource -> Bool)
-> (VersionSource -> VersionSource -> Bool)
-> (VersionSource -> VersionSource -> Bool)
-> (VersionSource -> VersionSource -> Bool)
-> (VersionSource -> VersionSource -> VersionSource)
-> (VersionSource -> VersionSource -> VersionSource)
-> Ord VersionSource
VersionSource -> VersionSource -> Bool
VersionSource -> VersionSource -> Ordering
VersionSource -> VersionSource -> VersionSource
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: VersionSource -> VersionSource -> Ordering
compare :: VersionSource -> VersionSource -> Ordering
$c< :: VersionSource -> VersionSource -> Bool
< :: VersionSource -> VersionSource -> Bool
$c<= :: VersionSource -> VersionSource -> Bool
<= :: VersionSource -> VersionSource -> Bool
$c> :: VersionSource -> VersionSource -> Bool
> :: VersionSource -> VersionSource -> Bool
$c>= :: VersionSource -> VersionSource -> Bool
>= :: VersionSource -> VersionSource -> Bool
$cmax :: VersionSource -> VersionSource -> VersionSource
max :: VersionSource -> VersionSource -> VersionSource
$cmin :: VersionSource -> VersionSource -> VersionSource
min :: VersionSource -> VersionSource -> VersionSource
Ord, (forall x. VersionSource -> Rep VersionSource x)
-> (forall x. Rep VersionSource x -> VersionSource)
-> Generic VersionSource
forall x. Rep VersionSource x -> VersionSource
forall x. VersionSource -> Rep VersionSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. VersionSource -> Rep VersionSource x
from :: forall x. VersionSource -> Rep VersionSource x
$cto :: forall x. Rep VersionSource x -> VersionSource
to :: forall x. Rep VersionSource x -> VersionSource
Generic, Eq VersionSource
Eq VersionSource =>
(Int -> VersionSource -> Int)
-> (VersionSource -> Int) -> Hashable VersionSource
Int -> VersionSource -> Int
VersionSource -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> VersionSource -> Int
hashWithSalt :: Int -> VersionSource -> Int
$chash :: VersionSource -> Int
hash :: VersionSource -> Int
Hashable, Get VersionSource
[VersionSource] -> Put
VersionSource -> Put
(VersionSource -> Put)
-> Get VersionSource
-> ([VersionSource] -> Put)
-> Binary VersionSource
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: VersionSource -> Put
put :: VersionSource -> Put
$cget :: Get VersionSource
get :: Get VersionSource
$cputList :: [VersionSource] -> Put
putList :: [VersionSource] -> Put
Binary, VersionSource -> ()
(VersionSource -> ()) -> NFData VersionSource
forall a. (a -> ()) -> NFData a
$crnf :: VersionSource -> ()
rnf :: VersionSource -> ()
NFData)

instance Pretty VersionSource where
  pretty :: forall ann. VersionSource -> Doc ann
pretty GitHubRelease {Text
_owner :: VersionSource -> Text
_repo :: VersionSource -> Text
_owner :: Text
_repo :: Text
..} =
    Doc ann
"CheckGitHubRelease"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep
            [ Doc ann
"owner" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_owner,
              Doc ann
"repo" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_repo
            ]
        )
  pretty GitHubTag {Text
ListOptions
_owner :: VersionSource -> Text
_repo :: VersionSource -> Text
_listOptions :: VersionSource -> ListOptions
_owner :: Text
_repo :: Text
_listOptions :: ListOptions
..} =
    Doc ann
"CheckGitHubTag"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
forall a b. (a -> b) -> a -> b
$
            [ Doc ann
"owner" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_owner,
              Doc ann
"repo" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_repo
            ]
              [Doc ann] -> [Doc ann] -> [Doc ann]
forall a. Semigroup a => a -> a -> a
<> [Doc ann
"listOptions" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> ListOptions -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. ListOptions -> Doc ann
pretty ListOptions
_listOptions | Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ ListOptions -> Bool
isEmptyListOptions ListOptions
_listOptions]
        )
  pretty Git {Text
Branch
_vurl :: VersionSource -> Text
_vbranch :: VersionSource -> Branch
_vurl :: Text
_vbranch :: Branch
..} =
    Doc ann
"CheckGit"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep
            [ Doc ann
"url" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_vurl,
              Doc ann
"branch" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Branch -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. Branch -> Doc ann
pretty Branch
_vbranch
            ]
        )
  pretty Pypi {Text
_pypi :: VersionSource -> Text
_pypi :: Text
..} =
    Doc ann
"CheckPypi" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_pypi
  pretty ArchLinux {Text
_archpkg :: VersionSource -> Text
_archpkg :: Text
..} =
    Doc ann
"CheckArchLinux" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_archpkg
  pretty Aur {Text
_aur :: VersionSource -> Text
_aur :: Text
..} =
    Doc ann
"CheckAur" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_aur
  pretty Manual {Text
_manual :: VersionSource -> Text
_manual :: Text
..} =
    Doc ann
"CheckManual" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_manual
  pretty Repology {Text
_repo :: VersionSource -> Text
_repology :: VersionSource -> Text
_repology :: Text
_repo :: Text
..} =
    Doc ann
"CheckRepology"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep
            [ Doc ann
"repology" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_repology,
              Doc ann
"repo" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_repo
            ]
        )
  pretty Webpage {Text
ListOptions
_listOptions :: VersionSource -> ListOptions
_vurl :: VersionSource -> Text
_regex :: VersionSource -> Text
_vurl :: Text
_regex :: Text
_listOptions :: ListOptions
..} =
    Doc ann
"CheckWebpage"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
forall a b. (a -> b) -> a -> b
$
            [ Doc ann
"url" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_vurl,
              Doc ann
"regex" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_regex
            ]
              [Doc ann] -> [Doc ann] -> [Doc ann]
forall a. Semigroup a => a -> a -> a
<> [Doc ann
"listOptions" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> ListOptions -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. ListOptions -> Doc ann
pretty ListOptions
_listOptions | Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ ListOptions -> Bool
isEmptyListOptions ListOptions
_listOptions]
        )
  pretty HttpHeader {Text
ListOptions
_listOptions :: VersionSource -> ListOptions
_vurl :: VersionSource -> Text
_regex :: VersionSource -> Text
_vurl :: Text
_regex :: Text
_listOptions :: ListOptions
..} =
    Doc ann
"CheckHttpHeader"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
forall a b. (a -> b) -> a -> b
$
            [ Doc ann
"url" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_vurl,
              Doc ann
"regex" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_regex
            ]
              [Doc ann] -> [Doc ann] -> [Doc ann]
forall a. Semigroup a => a -> a -> a
<> [Doc ann
"listOptions" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> ListOptions -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. ListOptions -> Doc ann
pretty ListOptions
_listOptions | Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ ListOptions -> Bool
isEmptyListOptions ListOptions
_listOptions]
        )
  pretty OpenVsx {Text
_ovPublisher :: VersionSource -> Text
_ovExtName :: VersionSource -> Text
_ovPublisher :: Text
_ovExtName :: Text
..} =
    Doc ann
"CheckOpenVsx"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep
            [ Doc ann
"publisher" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_ovPublisher,
              Doc ann
"extName" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_ovExtName
            ]
        )
  pretty VscodeMarketplace {Text
_vsmPublisher :: VersionSource -> Text
_vsmExtName :: VersionSource -> Text
_vsmPublisher :: Text
_vsmExtName :: Text
..} =
    Doc ann
"CheckVscodeMarketplace"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep
            [ Doc ann
"publisher" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_vsmPublisher,
              Doc ann
"extName" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_vsmExtName
            ]
        )
  pretty Cmd {Text
_vcmd :: VersionSource -> Text
_vcmd :: Text
..} =
    Doc ann
"CheckCmd" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_vcmd
  pretty Container {Text
ListOptions
_listOptions :: VersionSource -> ListOptions
_vcontainer :: VersionSource -> Text
_vcontainer :: Text
_listOptions :: ListOptions
..} =
    Doc ann
"CheckContainer" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_vcontainer

-- | The input of nvchecker
data CheckVersion = CheckVersion VersionSource NvcheckerOptions
  deriving (Int -> CheckVersion -> ShowS
[CheckVersion] -> ShowS
CheckVersion -> String
(Int -> CheckVersion -> ShowS)
-> (CheckVersion -> String)
-> ([CheckVersion] -> ShowS)
-> Show CheckVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CheckVersion -> ShowS
showsPrec :: Int -> CheckVersion -> ShowS
$cshow :: CheckVersion -> String
show :: CheckVersion -> String
$cshowList :: [CheckVersion] -> ShowS
showList :: [CheckVersion] -> ShowS
Show, Typeable, CheckVersion -> CheckVersion -> Bool
(CheckVersion -> CheckVersion -> Bool)
-> (CheckVersion -> CheckVersion -> Bool) -> Eq CheckVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CheckVersion -> CheckVersion -> Bool
== :: CheckVersion -> CheckVersion -> Bool
$c/= :: CheckVersion -> CheckVersion -> Bool
/= :: CheckVersion -> CheckVersion -> Bool
Eq, Eq CheckVersion
Eq CheckVersion =>
(CheckVersion -> CheckVersion -> Ordering)
-> (CheckVersion -> CheckVersion -> Bool)
-> (CheckVersion -> CheckVersion -> Bool)
-> (CheckVersion -> CheckVersion -> Bool)
-> (CheckVersion -> CheckVersion -> Bool)
-> (CheckVersion -> CheckVersion -> CheckVersion)
-> (CheckVersion -> CheckVersion -> CheckVersion)
-> Ord CheckVersion
CheckVersion -> CheckVersion -> Bool
CheckVersion -> CheckVersion -> Ordering
CheckVersion -> CheckVersion -> CheckVersion
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: CheckVersion -> CheckVersion -> Ordering
compare :: CheckVersion -> CheckVersion -> Ordering
$c< :: CheckVersion -> CheckVersion -> Bool
< :: CheckVersion -> CheckVersion -> Bool
$c<= :: CheckVersion -> CheckVersion -> Bool
<= :: CheckVersion -> CheckVersion -> Bool
$c> :: CheckVersion -> CheckVersion -> Bool
> :: CheckVersion -> CheckVersion -> Bool
$c>= :: CheckVersion -> CheckVersion -> Bool
>= :: CheckVersion -> CheckVersion -> Bool
$cmax :: CheckVersion -> CheckVersion -> CheckVersion
max :: CheckVersion -> CheckVersion -> CheckVersion
$cmin :: CheckVersion -> CheckVersion -> CheckVersion
min :: CheckVersion -> CheckVersion -> CheckVersion
Ord, (forall x. CheckVersion -> Rep CheckVersion x)
-> (forall x. Rep CheckVersion x -> CheckVersion)
-> Generic CheckVersion
forall x. Rep CheckVersion x -> CheckVersion
forall x. CheckVersion -> Rep CheckVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CheckVersion -> Rep CheckVersion x
from :: forall x. CheckVersion -> Rep CheckVersion x
$cto :: forall x. Rep CheckVersion x -> CheckVersion
to :: forall x. Rep CheckVersion x -> CheckVersion
Generic, Eq CheckVersion
Eq CheckVersion =>
(Int -> CheckVersion -> Int)
-> (CheckVersion -> Int) -> Hashable CheckVersion
Int -> CheckVersion -> Int
CheckVersion -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> CheckVersion -> Int
hashWithSalt :: Int -> CheckVersion -> Int
$chash :: CheckVersion -> Int
hash :: CheckVersion -> Int
Hashable, Get CheckVersion
[CheckVersion] -> Put
CheckVersion -> Put
(CheckVersion -> Put)
-> Get CheckVersion
-> ([CheckVersion] -> Put)
-> Binary CheckVersion
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: CheckVersion -> Put
put :: CheckVersion -> Put
$cget :: Get CheckVersion
get :: Get CheckVersion
$cputList :: [CheckVersion] -> Put
putList :: [CheckVersion] -> Put
Binary, CheckVersion -> ()
(CheckVersion -> ()) -> NFData CheckVersion
forall a. (a -> ()) -> NFData a
$crnf :: CheckVersion -> ()
rnf :: CheckVersion -> ()
NFData)

instance Pretty CheckVersion where
  pretty :: forall ann. CheckVersion -> Doc ann
pretty (CheckVersion VersionSource
v NvcheckerOptions
n) = Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann
align ([Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
forall a b. (a -> b) -> a -> b
$ [VersionSource -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. VersionSource -> Doc ann
pretty VersionSource
v] [Doc ann] -> [Doc ann] -> [Doc ann]
forall a. Semigroup a => a -> a -> a
<> [NvcheckerOptions -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. NvcheckerOptions -> Doc ann
pretty NvcheckerOptions
n | Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ NvcheckerOptions -> Bool
isEmptyNvcheckerOptions NvcheckerOptions
n])

-- | The result of nvchecker rule
data NvcheckerResult = NvcheckerResult
  { NvcheckerResult -> Version
nvNow :: Version,
    -- | last result of this nvchecker rule
    -- TODO: consider removing this field
    NvcheckerResult -> Maybe Version
nvOld :: Maybe Version,
    -- | stale means even 'nvNow' comes from json file (last run)
    -- and we actually didn't run nvchecker this time. 'nvOld' will be 'Nothing' in this case.
    NvcheckerResult -> Bool
nvStale :: Bool
  }
  deriving (Int -> NvcheckerResult -> ShowS
[NvcheckerResult] -> ShowS
NvcheckerResult -> String
(Int -> NvcheckerResult -> ShowS)
-> (NvcheckerResult -> String)
-> ([NvcheckerResult] -> ShowS)
-> Show NvcheckerResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NvcheckerResult -> ShowS
showsPrec :: Int -> NvcheckerResult -> ShowS
$cshow :: NvcheckerResult -> String
show :: NvcheckerResult -> String
$cshowList :: [NvcheckerResult] -> ShowS
showList :: [NvcheckerResult] -> ShowS
Show, Typeable, NvcheckerResult -> NvcheckerResult -> Bool
(NvcheckerResult -> NvcheckerResult -> Bool)
-> (NvcheckerResult -> NvcheckerResult -> Bool)
-> Eq NvcheckerResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NvcheckerResult -> NvcheckerResult -> Bool
== :: NvcheckerResult -> NvcheckerResult -> Bool
$c/= :: NvcheckerResult -> NvcheckerResult -> Bool
/= :: NvcheckerResult -> NvcheckerResult -> Bool
Eq, (forall x. NvcheckerResult -> Rep NvcheckerResult x)
-> (forall x. Rep NvcheckerResult x -> NvcheckerResult)
-> Generic NvcheckerResult
forall x. Rep NvcheckerResult x -> NvcheckerResult
forall x. NvcheckerResult -> Rep NvcheckerResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NvcheckerResult -> Rep NvcheckerResult x
from :: forall x. NvcheckerResult -> Rep NvcheckerResult x
$cto :: forall x. Rep NvcheckerResult x -> NvcheckerResult
to :: forall x. Rep NvcheckerResult x -> NvcheckerResult
Generic, Eq NvcheckerResult
Eq NvcheckerResult =>
(Int -> NvcheckerResult -> Int)
-> (NvcheckerResult -> Int) -> Hashable NvcheckerResult
Int -> NvcheckerResult -> Int
NvcheckerResult -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> NvcheckerResult -> Int
hashWithSalt :: Int -> NvcheckerResult -> Int
$chash :: NvcheckerResult -> Int
hash :: NvcheckerResult -> Int
Hashable, Get NvcheckerResult
[NvcheckerResult] -> Put
NvcheckerResult -> Put
(NvcheckerResult -> Put)
-> Get NvcheckerResult
-> ([NvcheckerResult] -> Put)
-> Binary NvcheckerResult
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: NvcheckerResult -> Put
put :: NvcheckerResult -> Put
$cget :: Get NvcheckerResult
get :: Get NvcheckerResult
$cputList :: [NvcheckerResult] -> Put
putList :: [NvcheckerResult] -> Put
Binary, NvcheckerResult -> ()
(NvcheckerResult -> ()) -> NFData NvcheckerResult
forall a. (a -> ()) -> NFData a
$crnf :: NvcheckerResult -> ()
rnf :: NvcheckerResult -> ()
NFData)

-- | Parsed JSON output from nvchecker
data NvcheckerRaw = NvcheckerSuccess Version | NvcheckerError Text
  deriving (Int -> NvcheckerRaw -> ShowS
[NvcheckerRaw] -> ShowS
NvcheckerRaw -> String
(Int -> NvcheckerRaw -> ShowS)
-> (NvcheckerRaw -> String)
-> ([NvcheckerRaw] -> ShowS)
-> Show NvcheckerRaw
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NvcheckerRaw -> ShowS
showsPrec :: Int -> NvcheckerRaw -> ShowS
$cshow :: NvcheckerRaw -> String
show :: NvcheckerRaw -> String
$cshowList :: [NvcheckerRaw] -> ShowS
showList :: [NvcheckerRaw] -> ShowS
Show, Typeable, NvcheckerRaw -> NvcheckerRaw -> Bool
(NvcheckerRaw -> NvcheckerRaw -> Bool)
-> (NvcheckerRaw -> NvcheckerRaw -> Bool) -> Eq NvcheckerRaw
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NvcheckerRaw -> NvcheckerRaw -> Bool
== :: NvcheckerRaw -> NvcheckerRaw -> Bool
$c/= :: NvcheckerRaw -> NvcheckerRaw -> Bool
/= :: NvcheckerRaw -> NvcheckerRaw -> Bool
Eq, (forall x. NvcheckerRaw -> Rep NvcheckerRaw x)
-> (forall x. Rep NvcheckerRaw x -> NvcheckerRaw)
-> Generic NvcheckerRaw
forall x. Rep NvcheckerRaw x -> NvcheckerRaw
forall x. NvcheckerRaw -> Rep NvcheckerRaw x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NvcheckerRaw -> Rep NvcheckerRaw x
from :: forall x. NvcheckerRaw -> Rep NvcheckerRaw x
$cto :: forall x. Rep NvcheckerRaw x -> NvcheckerRaw
to :: forall x. Rep NvcheckerRaw x -> NvcheckerRaw
Generic)

instance A.FromJSON NvcheckerRaw where
  parseJSON :: Value -> Parser NvcheckerRaw
parseJSON = String
-> (Object -> Parser NvcheckerRaw) -> Value -> Parser NvcheckerRaw
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"NvcheckerRaw" ((Object -> Parser NvcheckerRaw) -> Value -> Parser NvcheckerRaw)
-> (Object -> Parser NvcheckerRaw) -> Value -> Parser NvcheckerRaw
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
    Maybe Version
mVersion <- Object
o Object -> Key -> Parser (Maybe Version)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"version"
    case Maybe Version
mVersion of
      Just Version
version -> NvcheckerRaw -> Parser NvcheckerRaw
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (NvcheckerRaw -> Parser NvcheckerRaw)
-> NvcheckerRaw -> Parser NvcheckerRaw
forall a b. (a -> b) -> a -> b
$ Version -> NvcheckerRaw
NvcheckerSuccess Version
version
      Maybe Version
_ -> Text -> NvcheckerRaw
NvcheckerError (Text -> NvcheckerRaw) -> Parser Text -> Parser NvcheckerRaw
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"error"

type instance RuleResult CheckVersion = NvcheckerResult

--------------------------------------------------------------------------------

-- | Whether to cache the fetched sha256
--
-- @ForceFetch@ indicates @alwaysRerun@ the fetcher rule
data ForceFetch = ForceFetch | NoForceFetch
  deriving (Int -> ForceFetch -> ShowS
[ForceFetch] -> ShowS
ForceFetch -> String
(Int -> ForceFetch -> ShowS)
-> (ForceFetch -> String)
-> ([ForceFetch] -> ShowS)
-> Show ForceFetch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ForceFetch -> ShowS
showsPrec :: Int -> ForceFetch -> ShowS
$cshow :: ForceFetch -> String
show :: ForceFetch -> String
$cshowList :: [ForceFetch] -> ShowS
showList :: [ForceFetch] -> ShowS
Show, ForceFetch -> ForceFetch -> Bool
(ForceFetch -> ForceFetch -> Bool)
-> (ForceFetch -> ForceFetch -> Bool) -> Eq ForceFetch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ForceFetch -> ForceFetch -> Bool
== :: ForceFetch -> ForceFetch -> Bool
$c/= :: ForceFetch -> ForceFetch -> Bool
/= :: ForceFetch -> ForceFetch -> Bool
Eq, Eq ForceFetch
Eq ForceFetch =>
(ForceFetch -> ForceFetch -> Ordering)
-> (ForceFetch -> ForceFetch -> Bool)
-> (ForceFetch -> ForceFetch -> Bool)
-> (ForceFetch -> ForceFetch -> Bool)
-> (ForceFetch -> ForceFetch -> Bool)
-> (ForceFetch -> ForceFetch -> ForceFetch)
-> (ForceFetch -> ForceFetch -> ForceFetch)
-> Ord ForceFetch
ForceFetch -> ForceFetch -> Bool
ForceFetch -> ForceFetch -> Ordering
ForceFetch -> ForceFetch -> ForceFetch
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ForceFetch -> ForceFetch -> Ordering
compare :: ForceFetch -> ForceFetch -> Ordering
$c< :: ForceFetch -> ForceFetch -> Bool
< :: ForceFetch -> ForceFetch -> Bool
$c<= :: ForceFetch -> ForceFetch -> Bool
<= :: ForceFetch -> ForceFetch -> Bool
$c> :: ForceFetch -> ForceFetch -> Bool
> :: ForceFetch -> ForceFetch -> Bool
$c>= :: ForceFetch -> ForceFetch -> Bool
>= :: ForceFetch -> ForceFetch -> Bool
$cmax :: ForceFetch -> ForceFetch -> ForceFetch
max :: ForceFetch -> ForceFetch -> ForceFetch
$cmin :: ForceFetch -> ForceFetch -> ForceFetch
min :: ForceFetch -> ForceFetch -> ForceFetch
Ord, Eq ForceFetch
Eq ForceFetch =>
(Int -> ForceFetch -> Int)
-> (ForceFetch -> Int) -> Hashable ForceFetch
Int -> ForceFetch -> Int
ForceFetch -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> ForceFetch -> Int
hashWithSalt :: Int -> ForceFetch -> Int
$chash :: ForceFetch -> Int
hash :: ForceFetch -> Int
Hashable, ForceFetch -> ()
(ForceFetch -> ()) -> NFData ForceFetch
forall a. (a -> ()) -> NFData a
$crnf :: ForceFetch -> ()
rnf :: ForceFetch -> ()
NFData, Get ForceFetch
[ForceFetch] -> Put
ForceFetch -> Put
(ForceFetch -> Put)
-> Get ForceFetch -> ([ForceFetch] -> Put) -> Binary ForceFetch
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: ForceFetch -> Put
put :: ForceFetch -> Put
$cget :: Get ForceFetch
get :: Get ForceFetch
$cputList :: [ForceFetch] -> Put
putList :: [ForceFetch] -> Put
Binary, Typeable, (forall x. ForceFetch -> Rep ForceFetch x)
-> (forall x. Rep ForceFetch x -> ForceFetch) -> Generic ForceFetch
forall x. Rep ForceFetch x -> ForceFetch
forall x. ForceFetch -> Rep ForceFetch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ForceFetch -> Rep ForceFetch x
from :: forall x. ForceFetch -> Rep ForceFetch x
$cto :: forall x. Rep ForceFetch x -> ForceFetch
to :: forall x. Rep ForceFetch x -> ForceFetch
Generic)

instance Pretty ForceFetch where
  pretty :: forall ann. ForceFetch -> Doc ann
pretty ForceFetch
ForceFetch = Doc ann
"ForceFetch"
  pretty ForceFetch
NoForceFetch = Doc ann
"NoForceFetch"

instance Default ForceFetch where
  def :: ForceFetch
def = ForceFetch
NoForceFetch

-- | The input of prefetch rule
data RunFetch = RunFetch ForceFetch (NixFetcher Fresh)
  deriving (Int -> RunFetch -> ShowS
[RunFetch] -> ShowS
RunFetch -> String
(Int -> RunFetch -> ShowS)
-> (RunFetch -> String) -> ([RunFetch] -> ShowS) -> Show RunFetch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RunFetch -> ShowS
showsPrec :: Int -> RunFetch -> ShowS
$cshow :: RunFetch -> String
show :: RunFetch -> String
$cshowList :: [RunFetch] -> ShowS
showList :: [RunFetch] -> ShowS
Show, RunFetch -> RunFetch -> Bool
(RunFetch -> RunFetch -> Bool)
-> (RunFetch -> RunFetch -> Bool) -> Eq RunFetch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RunFetch -> RunFetch -> Bool
== :: RunFetch -> RunFetch -> Bool
$c/= :: RunFetch -> RunFetch -> Bool
/= :: RunFetch -> RunFetch -> Bool
Eq, Eq RunFetch
Eq RunFetch =>
(RunFetch -> RunFetch -> Ordering)
-> (RunFetch -> RunFetch -> Bool)
-> (RunFetch -> RunFetch -> Bool)
-> (RunFetch -> RunFetch -> Bool)
-> (RunFetch -> RunFetch -> Bool)
-> (RunFetch -> RunFetch -> RunFetch)
-> (RunFetch -> RunFetch -> RunFetch)
-> Ord RunFetch
RunFetch -> RunFetch -> Bool
RunFetch -> RunFetch -> Ordering
RunFetch -> RunFetch -> RunFetch
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: RunFetch -> RunFetch -> Ordering
compare :: RunFetch -> RunFetch -> Ordering
$c< :: RunFetch -> RunFetch -> Bool
< :: RunFetch -> RunFetch -> Bool
$c<= :: RunFetch -> RunFetch -> Bool
<= :: RunFetch -> RunFetch -> Bool
$c> :: RunFetch -> RunFetch -> Bool
> :: RunFetch -> RunFetch -> Bool
$c>= :: RunFetch -> RunFetch -> Bool
>= :: RunFetch -> RunFetch -> Bool
$cmax :: RunFetch -> RunFetch -> RunFetch
max :: RunFetch -> RunFetch -> RunFetch
$cmin :: RunFetch -> RunFetch -> RunFetch
min :: RunFetch -> RunFetch -> RunFetch
Ord, Eq RunFetch
Eq RunFetch =>
(Int -> RunFetch -> Int) -> (RunFetch -> Int) -> Hashable RunFetch
Int -> RunFetch -> Int
RunFetch -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> RunFetch -> Int
hashWithSalt :: Int -> RunFetch -> Int
$chash :: RunFetch -> Int
hash :: RunFetch -> Int
Hashable, RunFetch -> ()
(RunFetch -> ()) -> NFData RunFetch
forall a. (a -> ()) -> NFData a
$crnf :: RunFetch -> ()
rnf :: RunFetch -> ()
NFData, Get RunFetch
[RunFetch] -> Put
RunFetch -> Put
(RunFetch -> Put)
-> Get RunFetch -> ([RunFetch] -> Put) -> Binary RunFetch
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: RunFetch -> Put
put :: RunFetch -> Put
$cget :: Get RunFetch
get :: Get RunFetch
$cputList :: [RunFetch] -> Put
putList :: [RunFetch] -> Put
Binary, Typeable, (forall x. RunFetch -> Rep RunFetch x)
-> (forall x. Rep RunFetch x -> RunFetch) -> Generic RunFetch
forall x. Rep RunFetch x -> RunFetch
forall x. RunFetch -> Rep RunFetch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RunFetch -> Rep RunFetch x
from :: forall x. RunFetch -> Rep RunFetch x
$cto :: forall x. Rep RunFetch x -> RunFetch
to :: forall x. Rep RunFetch x -> RunFetch
Generic)

-- Prefetch rule never throws exceptions
type instance RuleResult RunFetch = Maybe (NixFetcher Fetched)

-- | If the package is prefetched, then we can obtain the SHA256
data NixFetcher (k :: FetchStatus)
  = FetchGit
      { forall (k :: FetchStatus). NixFetcher k -> Text
_furl :: Text,
        forall (k :: FetchStatus). NixFetcher k -> Version
_rev :: Version,
        forall (k :: FetchStatus). NixFetcher k -> Bool
_deepClone :: Bool,
        forall (k :: FetchStatus). NixFetcher k -> Bool
_fetchSubmodules :: Bool,
        forall (k :: FetchStatus). NixFetcher k -> Bool
_leaveDotGit :: Bool,
        forall (k :: FetchStatus). NixFetcher k -> [Text]
_sparseCheckout :: [Text],
        forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_name :: Maybe Text,
        forall (k :: FetchStatus). NixFetcher k -> FetchResult Checksum k
_sha256 :: FetchResult Checksum k
      }
  | FetchGitHub
      { forall (k :: FetchStatus). NixFetcher k -> Text
_fowner :: Text,
        forall (k :: FetchStatus). NixFetcher k -> Text
_frepo :: Text,
        _rev :: Version,
        _deepClone :: Bool,
        _fetchSubmodules :: Bool,
        _leaveDotGit :: Bool,
        _sparseCheckout :: [Text],
        _name :: Maybe Text,
        _sha256 :: FetchResult Checksum k
      }
  | FetchUrl
      { _furl :: Text,
        _name :: Maybe Text,
        _sha256 :: FetchResult Checksum k
      }
  | FetchTarball
      { _furl :: Text,
        _sha256 :: FetchResult Checksum k
      }
  | FetchDocker
      { forall (k :: FetchStatus). NixFetcher k -> Text
_imageName :: Text,
        forall (k :: FetchStatus). NixFetcher k -> Text
_imageTag :: Text,
        forall (k :: FetchStatus).
NixFetcher k -> FetchResult ContainerDigest k
_imageDigest :: FetchResult ContainerDigest k,
        _sha256 :: FetchResult Checksum k,
        forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_fos :: Maybe Text,
        forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_farch :: Maybe Text,
        forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_finalImageName :: Maybe Text,
        forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_finalImageTag :: Maybe Text,
        forall (k :: FetchStatus). NixFetcher k -> Maybe Bool
_tlsVerify :: Maybe Bool
      }
  deriving (Typeable, (forall x. NixFetcher k -> Rep (NixFetcher k) x)
-> (forall x. Rep (NixFetcher k) x -> NixFetcher k)
-> Generic (NixFetcher k)
forall x. Rep (NixFetcher k) x -> NixFetcher k
forall x. NixFetcher k -> Rep (NixFetcher k) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (k :: FetchStatus) x. Rep (NixFetcher k) x -> NixFetcher k
forall (k :: FetchStatus) x. NixFetcher k -> Rep (NixFetcher k) x
$cfrom :: forall (k :: FetchStatus) x. NixFetcher k -> Rep (NixFetcher k) x
from :: forall x. NixFetcher k -> Rep (NixFetcher k) x
$cto :: forall (k :: FetchStatus) x. Rep (NixFetcher k) x -> NixFetcher k
to :: forall x. Rep (NixFetcher k) x -> NixFetcher k
Generic)

class (c (FetchResult Checksum k), c (FetchResult ContainerDigest k)) => ForFetchResult c k

instance (c (FetchResult Checksum k), c (FetchResult ContainerDigest k)) => ForFetchResult c k

deriving instance Show `ForFetchResult` k => Show (NixFetcher k)

deriving instance Eq `ForFetchResult` k => Eq (NixFetcher k)

deriving instance Ord `ForFetchResult` k => Ord (NixFetcher k)

deriving instance Hashable `ForFetchResult` k => Hashable (NixFetcher k)

deriving instance Binary `ForFetchResult` k => Binary (NixFetcher k)

deriving instance NFData `ForFetchResult` k => NFData (NixFetcher k)

-- | Fetch status
data FetchStatus = Fresh | Fetched

-- | Prefetched fetchers hold hashes
type family FetchResult a (k :: FetchStatus) where
  FetchResult _ Fresh = ()
  FetchResult a Fetched = a

instance A.ToJSON (NixFetcher Fetched) where
  toJSON :: NixFetcher 'Fetched -> Value
toJSON FetchGit {Bool
[Text]
Maybe Text
Text
FetchResult Checksum 'Fetched
Version
_furl :: forall (k :: FetchStatus). NixFetcher k -> Text
_rev :: forall (k :: FetchStatus). NixFetcher k -> Version
_deepClone :: forall (k :: FetchStatus). NixFetcher k -> Bool
_fetchSubmodules :: forall (k :: FetchStatus). NixFetcher k -> Bool
_leaveDotGit :: forall (k :: FetchStatus). NixFetcher k -> Bool
_sparseCheckout :: forall (k :: FetchStatus). NixFetcher k -> [Text]
_name :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult Checksum k
_furl :: Text
_rev :: Version
_deepClone :: Bool
_fetchSubmodules :: Bool
_leaveDotGit :: Bool
_sparseCheckout :: [Text]
_name :: Maybe Text
_sha256 :: FetchResult Checksum 'Fetched
..} =
    [Pair] -> Value
A.object
      [ Key
"url" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text
_furl,
        Key
"rev" Key -> Version -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Version
_rev,
        Key
"deepClone" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Bool
_deepClone,
        Key
"fetchSubmodules" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Bool
_fetchSubmodules,
        Key
"leaveDotGit" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Bool
_leaveDotGit,
        Key
"sparseCheckout" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= [Text]
_sparseCheckout,
        Key
"name" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
_name,
        Key
"sha256" Key -> Checksum -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= FetchResult Checksum 'Fetched
Checksum
_sha256,
        Key
"type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
A.String Text
"git"
      ]
  toJSON FetchGitHub {Bool
[Text]
Maybe Text
Text
FetchResult Checksum 'Fetched
Version
_rev :: forall (k :: FetchStatus). NixFetcher k -> Version
_deepClone :: forall (k :: FetchStatus). NixFetcher k -> Bool
_fetchSubmodules :: forall (k :: FetchStatus). NixFetcher k -> Bool
_leaveDotGit :: forall (k :: FetchStatus). NixFetcher k -> Bool
_sparseCheckout :: forall (k :: FetchStatus). NixFetcher k -> [Text]
_name :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult Checksum k
_fowner :: forall (k :: FetchStatus). NixFetcher k -> Text
_frepo :: forall (k :: FetchStatus). NixFetcher k -> Text
_fowner :: Text
_frepo :: Text
_rev :: Version
_deepClone :: Bool
_fetchSubmodules :: Bool
_leaveDotGit :: Bool
_sparseCheckout :: [Text]
_name :: Maybe Text
_sha256 :: FetchResult Checksum 'Fetched
..} =
    [Pair] -> Value
A.object
      [ Key
"owner" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text
_fowner,
        Key
"repo" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text
_frepo,
        Key
"rev" Key -> Version -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Version
_rev,
        Key
"deepClone" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Bool
_deepClone,
        Key
"fetchSubmodules" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Bool
_fetchSubmodules,
        Key
"leaveDotGit" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Bool
_leaveDotGit,
        Key
"sparseCheckout" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= [Text]
_sparseCheckout,
        Key
"name" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
_name,
        Key
"sha256" Key -> Checksum -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= FetchResult Checksum 'Fetched
Checksum
_sha256,
        Key
"type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
A.String Text
"github"
      ]
  toJSON FetchUrl {Maybe Text
Text
FetchResult Checksum 'Fetched
_furl :: forall (k :: FetchStatus). NixFetcher k -> Text
_name :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult Checksum k
_furl :: Text
_name :: Maybe Text
_sha256 :: FetchResult Checksum 'Fetched
..} =
    [Pair] -> Value
A.object
      [ Key
"url" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text
_furl,
        Key
"name" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
_name,
        Key
"sha256" Key -> Checksum -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= FetchResult Checksum 'Fetched
Checksum
_sha256,
        Key
"type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
A.String Text
"url"
      ]
  toJSON FetchTarball {Text
FetchResult Checksum 'Fetched
_furl :: forall (k :: FetchStatus). NixFetcher k -> Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult Checksum k
_furl :: Text
_sha256 :: FetchResult Checksum 'Fetched
..} =
    [Pair] -> Value
A.object
      [ Key
"url" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text
_furl,
        Key
"sha256" Key -> Checksum -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= FetchResult Checksum 'Fetched
Checksum
_sha256,
        Key
"type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
A.String Text
"tarball"
      ]
  toJSON FetchDocker {Maybe Bool
Maybe Text
Text
FetchResult ContainerDigest 'Fetched
FetchResult Checksum 'Fetched
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult Checksum k
_imageName :: forall (k :: FetchStatus). NixFetcher k -> Text
_imageTag :: forall (k :: FetchStatus). NixFetcher k -> Text
_imageDigest :: forall (k :: FetchStatus).
NixFetcher k -> FetchResult ContainerDigest k
_fos :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_farch :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_finalImageName :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_finalImageTag :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_tlsVerify :: forall (k :: FetchStatus). NixFetcher k -> Maybe Bool
_imageName :: Text
_imageTag :: Text
_imageDigest :: FetchResult ContainerDigest 'Fetched
_sha256 :: FetchResult Checksum 'Fetched
_fos :: Maybe Text
_farch :: Maybe Text
_finalImageName :: Maybe Text
_finalImageTag :: Maybe Text
_tlsVerify :: Maybe Bool
..} =
    [Pair] -> Value
A.object
      [ Key
"imageName" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text
_imageName,
        Key
"imageTag" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text
_imageTag,
        Key
"imageDigest" Key -> ContainerDigest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= FetchResult ContainerDigest 'Fetched
ContainerDigest
_imageDigest,
        Key
"sha256" Key -> Checksum -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= FetchResult Checksum 'Fetched
Checksum
_sha256,
        Key
"os" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
_fos,
        Key
"arch" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
_farch,
        Key
"finalImageName" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
_finalImageName,
        Key
"finalImageTag" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
_finalImageTag,
        Key
"tlsVerify" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
_tlsVerify
      ]

instance Pretty (NixFetcher k) where
  pretty :: forall ann. NixFetcher k -> Doc ann
pretty FetchGit {Bool
[Text]
Maybe Text
Text
FetchResult Checksum k
Version
_furl :: forall (k :: FetchStatus). NixFetcher k -> Text
_rev :: forall (k :: FetchStatus). NixFetcher k -> Version
_deepClone :: forall (k :: FetchStatus). NixFetcher k -> Bool
_fetchSubmodules :: forall (k :: FetchStatus). NixFetcher k -> Bool
_leaveDotGit :: forall (k :: FetchStatus). NixFetcher k -> Bool
_sparseCheckout :: forall (k :: FetchStatus). NixFetcher k -> [Text]
_name :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult Checksum k
_furl :: Text
_rev :: Version
_deepClone :: Bool
_fetchSubmodules :: Bool
_leaveDotGit :: Bool
_sparseCheckout :: [Text]
_name :: Maybe Text
_sha256 :: FetchResult Checksum k
..} =
    Doc ann
"FetchGit"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
forall a b. (a -> b) -> a -> b
$
            [ Doc ann
"url" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_furl,
              Doc ann
"rev" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Version -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. Version -> Doc ann
pretty Version
_rev,
              Doc ann
"deepClone" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Bool -> Doc ann
forall ann. Bool -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Bool
_deepClone,
              Doc ann
"fetchSubmodules" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Bool -> Doc ann
forall ann. Bool -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Bool
_fetchSubmodules,
              Doc ann
"leaveDotGit" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Bool -> Doc ann
forall ann. Bool -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Bool
_leaveDotGit,
              Doc ann
"sparseCheckout" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> [Text] -> Doc ann
forall ann. [Text] -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty [Text]
_sparseCheckout
            ]
              [Doc ann] -> [Doc ann] -> [Doc ann]
forall a. Semigroup a => a -> a -> a
<> Doc ann -> Maybe Text -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"name" Maybe Text
_name
        )
  pretty FetchGitHub {Bool
[Text]
Maybe Text
Text
FetchResult Checksum k
Version
_rev :: forall (k :: FetchStatus). NixFetcher k -> Version
_deepClone :: forall (k :: FetchStatus). NixFetcher k -> Bool
_fetchSubmodules :: forall (k :: FetchStatus). NixFetcher k -> Bool
_leaveDotGit :: forall (k :: FetchStatus). NixFetcher k -> Bool
_sparseCheckout :: forall (k :: FetchStatus). NixFetcher k -> [Text]
_name :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult Checksum k
_fowner :: forall (k :: FetchStatus). NixFetcher k -> Text
_frepo :: forall (k :: FetchStatus). NixFetcher k -> Text
_fowner :: Text
_frepo :: Text
_rev :: Version
_deepClone :: Bool
_fetchSubmodules :: Bool
_leaveDotGit :: Bool
_sparseCheckout :: [Text]
_name :: Maybe Text
_sha256 :: FetchResult Checksum k
..} =
    Doc ann
"FetchGitHub"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
forall a b. (a -> b) -> a -> b
$
            [ Doc ann
"owner" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_fowner,
              Doc ann
"repo" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_frepo,
              Doc ann
"rev" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Version -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. Version -> Doc ann
pretty Version
_rev,
              Doc ann
"deepClone" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Bool -> Doc ann
forall ann. Bool -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Bool
_deepClone,
              Doc ann
"fetchSubmodules" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Bool -> Doc ann
forall ann. Bool -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Bool
_fetchSubmodules,
              Doc ann
"leaveDotGit" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Bool -> Doc ann
forall ann. Bool -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Bool
_leaveDotGit,
              Doc ann
"sparseCheckout" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> [Text] -> Doc ann
forall ann. [Text] -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty [Text]
_sparseCheckout
            ]
              [Doc ann] -> [Doc ann] -> [Doc ann]
forall a. Semigroup a => a -> a -> a
<> Doc ann -> Maybe Text -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"name" Maybe Text
_name
        )
  pretty FetchUrl {Maybe Text
Text
FetchResult Checksum k
_furl :: forall (k :: FetchStatus). NixFetcher k -> Text
_name :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult Checksum k
_furl :: Text
_name :: Maybe Text
_sha256 :: FetchResult Checksum k
..} =
    Doc ann
"FetchUrl"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
forall a b. (a -> b) -> a -> b
$
            [Doc ann
"url" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_furl]
              [Doc ann] -> [Doc ann] -> [Doc ann]
forall a. Semigroup a => a -> a -> a
<> Doc ann -> Maybe Text -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"name" Maybe Text
_name
        )
  pretty FetchTarball {Text
FetchResult Checksum k
_furl :: forall (k :: FetchStatus). NixFetcher k -> Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult Checksum k
_furl :: Text
_sha256 :: FetchResult Checksum k
..} =
    Doc ann
"FetchTarball" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_furl
  pretty FetchDocker {Maybe Bool
Maybe Text
Text
FetchResult ContainerDigest k
FetchResult Checksum k
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult Checksum k
_imageName :: forall (k :: FetchStatus). NixFetcher k -> Text
_imageTag :: forall (k :: FetchStatus). NixFetcher k -> Text
_imageDigest :: forall (k :: FetchStatus).
NixFetcher k -> FetchResult ContainerDigest k
_fos :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_farch :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_finalImageName :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_finalImageTag :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_tlsVerify :: forall (k :: FetchStatus). NixFetcher k -> Maybe Bool
_imageName :: Text
_imageTag :: Text
_imageDigest :: FetchResult ContainerDigest k
_sha256 :: FetchResult Checksum k
_fos :: Maybe Text
_farch :: Maybe Text
_finalImageName :: Maybe Text
_finalImageTag :: Maybe Text
_tlsVerify :: Maybe Bool
..} =
    Doc ann
"FetchDocker"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
forall a b. (a -> b) -> a -> b
$
            [ Doc ann
"imageName" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_imageName,
              Doc ann
"imageTag" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Maybe Text -> Doc ann
forall ann. Maybe Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Maybe Text
_finalImageTag
            ]
              [Doc ann] -> [Doc ann] -> [Doc ann]
forall a. Semigroup a => a -> a -> a
<> Doc ann -> Maybe Text -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"os" Maybe Text
_fos
              [Doc ann] -> [Doc ann] -> [Doc ann]
forall a. Semigroup a => a -> a -> a
<> Doc ann -> Maybe Text -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"arch" Maybe Text
_farch
              [Doc ann] -> [Doc ann] -> [Doc ann]
forall a. Semigroup a => a -> a -> a
<> Doc ann -> Maybe Text -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"finalImageName" Maybe Text
_finalImageName
              [Doc ann] -> [Doc ann] -> [Doc ann]
forall a. Semigroup a => a -> a -> a
<> Doc ann -> Maybe Text -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"finalImageTag" Maybe Text
_finalImageTag
              [Doc ann] -> [Doc ann] -> [Doc ann]
forall a. Semigroup a => a -> a -> a
<> Doc ann -> Maybe Bool -> [Doc ann]
forall a ann. Pretty a => Doc ann -> Maybe a -> [Doc ann]
ppField Doc ann
"tlsVerify" Maybe Bool
_tlsVerify
        )

--------------------------------------------------------------------------------

-- | Extract file contents from package source
-- e.g. @Cargo.lock@
data ExtractSrcQ = ExtractSrcQ (NixFetcher Fetched) (NE.NonEmpty FilePath)
  deriving (Int -> ExtractSrcQ -> ShowS
[ExtractSrcQ] -> ShowS
ExtractSrcQ -> String
(Int -> ExtractSrcQ -> ShowS)
-> (ExtractSrcQ -> String)
-> ([ExtractSrcQ] -> ShowS)
-> Show ExtractSrcQ
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ExtractSrcQ -> ShowS
showsPrec :: Int -> ExtractSrcQ -> ShowS
$cshow :: ExtractSrcQ -> String
show :: ExtractSrcQ -> String
$cshowList :: [ExtractSrcQ] -> ShowS
showList :: [ExtractSrcQ] -> ShowS
Show, ExtractSrcQ -> ExtractSrcQ -> Bool
(ExtractSrcQ -> ExtractSrcQ -> Bool)
-> (ExtractSrcQ -> ExtractSrcQ -> Bool) -> Eq ExtractSrcQ
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ExtractSrcQ -> ExtractSrcQ -> Bool
== :: ExtractSrcQ -> ExtractSrcQ -> Bool
$c/= :: ExtractSrcQ -> ExtractSrcQ -> Bool
/= :: ExtractSrcQ -> ExtractSrcQ -> Bool
Eq, Eq ExtractSrcQ
Eq ExtractSrcQ =>
(ExtractSrcQ -> ExtractSrcQ -> Ordering)
-> (ExtractSrcQ -> ExtractSrcQ -> Bool)
-> (ExtractSrcQ -> ExtractSrcQ -> Bool)
-> (ExtractSrcQ -> ExtractSrcQ -> Bool)
-> (ExtractSrcQ -> ExtractSrcQ -> Bool)
-> (ExtractSrcQ -> ExtractSrcQ -> ExtractSrcQ)
-> (ExtractSrcQ -> ExtractSrcQ -> ExtractSrcQ)
-> Ord ExtractSrcQ
ExtractSrcQ -> ExtractSrcQ -> Bool
ExtractSrcQ -> ExtractSrcQ -> Ordering
ExtractSrcQ -> ExtractSrcQ -> ExtractSrcQ
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ExtractSrcQ -> ExtractSrcQ -> Ordering
compare :: ExtractSrcQ -> ExtractSrcQ -> Ordering
$c< :: ExtractSrcQ -> ExtractSrcQ -> Bool
< :: ExtractSrcQ -> ExtractSrcQ -> Bool
$c<= :: ExtractSrcQ -> ExtractSrcQ -> Bool
<= :: ExtractSrcQ -> ExtractSrcQ -> Bool
$c> :: ExtractSrcQ -> ExtractSrcQ -> Bool
> :: ExtractSrcQ -> ExtractSrcQ -> Bool
$c>= :: ExtractSrcQ -> ExtractSrcQ -> Bool
>= :: ExtractSrcQ -> ExtractSrcQ -> Bool
$cmax :: ExtractSrcQ -> ExtractSrcQ -> ExtractSrcQ
max :: ExtractSrcQ -> ExtractSrcQ -> ExtractSrcQ
$cmin :: ExtractSrcQ -> ExtractSrcQ -> ExtractSrcQ
min :: ExtractSrcQ -> ExtractSrcQ -> ExtractSrcQ
Ord, Eq ExtractSrcQ
Eq ExtractSrcQ =>
(Int -> ExtractSrcQ -> Int)
-> (ExtractSrcQ -> Int) -> Hashable ExtractSrcQ
Int -> ExtractSrcQ -> Int
ExtractSrcQ -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> ExtractSrcQ -> Int
hashWithSalt :: Int -> ExtractSrcQ -> Int
$chash :: ExtractSrcQ -> Int
hash :: ExtractSrcQ -> Int
Hashable, ExtractSrcQ -> ()
(ExtractSrcQ -> ()) -> NFData ExtractSrcQ
forall a. (a -> ()) -> NFData a
$crnf :: ExtractSrcQ -> ()
rnf :: ExtractSrcQ -> ()
NFData, Get ExtractSrcQ
[ExtractSrcQ] -> Put
ExtractSrcQ -> Put
(ExtractSrcQ -> Put)
-> Get ExtractSrcQ -> ([ExtractSrcQ] -> Put) -> Binary ExtractSrcQ
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: ExtractSrcQ -> Put
put :: ExtractSrcQ -> Put
$cget :: Get ExtractSrcQ
get :: Get ExtractSrcQ
$cputList :: [ExtractSrcQ] -> Put
putList :: [ExtractSrcQ] -> Put
Binary, Typeable, (forall x. ExtractSrcQ -> Rep ExtractSrcQ x)
-> (forall x. Rep ExtractSrcQ x -> ExtractSrcQ)
-> Generic ExtractSrcQ
forall x. Rep ExtractSrcQ x -> ExtractSrcQ
forall x. ExtractSrcQ -> Rep ExtractSrcQ x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ExtractSrcQ -> Rep ExtractSrcQ x
from :: forall x. ExtractSrcQ -> Rep ExtractSrcQ x
$cto :: forall x. Rep ExtractSrcQ x -> ExtractSrcQ
to :: forall x. Rep ExtractSrcQ x -> ExtractSrcQ
Generic)

type instance RuleResult ExtractSrcQ = HashMap FilePath Text

instance Pretty ExtractSrcQ where
  pretty :: forall ann. ExtractSrcQ -> Doc ann
pretty (ExtractSrcQ NixFetcher 'Fetched
f NonEmpty String
n) =
    Doc ann
"ExtractSrc"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep
            [ Doc ann
"fetcher" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> NixFetcher 'Fetched -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. NixFetcher 'Fetched -> Doc ann
pretty NixFetcher 'Fetched
f,
              Doc ann
"files" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> NonEmpty String -> Doc ann
forall ann. NonEmpty String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty NonEmpty String
n
            ]
        )

--------------------------------------------------------------------------------

-- | Fetch @outputHashes@ for git dependencies in @Cargo.lock@.
-- See <https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md#importing-a-cargolock-file> for details.
-- We need fetched source and the file path to @Cargo.lock@.
data FetchRustGitDepsQ = FetchRustGitDepsQ (NixFetcher Fetched) FilePath
  deriving (Int -> FetchRustGitDepsQ -> ShowS
[FetchRustGitDepsQ] -> ShowS
FetchRustGitDepsQ -> String
(Int -> FetchRustGitDepsQ -> ShowS)
-> (FetchRustGitDepsQ -> String)
-> ([FetchRustGitDepsQ] -> ShowS)
-> Show FetchRustGitDepsQ
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FetchRustGitDepsQ -> ShowS
showsPrec :: Int -> FetchRustGitDepsQ -> ShowS
$cshow :: FetchRustGitDepsQ -> String
show :: FetchRustGitDepsQ -> String
$cshowList :: [FetchRustGitDepsQ] -> ShowS
showList :: [FetchRustGitDepsQ] -> ShowS
Show, FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
(FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool)
-> (FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool)
-> Eq FetchRustGitDepsQ
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
== :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
$c/= :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
/= :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
Eq, Eq FetchRustGitDepsQ
Eq FetchRustGitDepsQ =>
(FetchRustGitDepsQ -> FetchRustGitDepsQ -> Ordering)
-> (FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool)
-> (FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool)
-> (FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool)
-> (FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool)
-> (FetchRustGitDepsQ -> FetchRustGitDepsQ -> FetchRustGitDepsQ)
-> (FetchRustGitDepsQ -> FetchRustGitDepsQ -> FetchRustGitDepsQ)
-> Ord FetchRustGitDepsQ
FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
FetchRustGitDepsQ -> FetchRustGitDepsQ -> Ordering
FetchRustGitDepsQ -> FetchRustGitDepsQ -> FetchRustGitDepsQ
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Ordering
compare :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Ordering
$c< :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
< :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
$c<= :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
<= :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
$c> :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
> :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
$c>= :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
>= :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
$cmax :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> FetchRustGitDepsQ
max :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> FetchRustGitDepsQ
$cmin :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> FetchRustGitDepsQ
min :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> FetchRustGitDepsQ
Ord, Eq FetchRustGitDepsQ
Eq FetchRustGitDepsQ =>
(Int -> FetchRustGitDepsQ -> Int)
-> (FetchRustGitDepsQ -> Int) -> Hashable FetchRustGitDepsQ
Int -> FetchRustGitDepsQ -> Int
FetchRustGitDepsQ -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> FetchRustGitDepsQ -> Int
hashWithSalt :: Int -> FetchRustGitDepsQ -> Int
$chash :: FetchRustGitDepsQ -> Int
hash :: FetchRustGitDepsQ -> Int
Hashable, FetchRustGitDepsQ -> ()
(FetchRustGitDepsQ -> ()) -> NFData FetchRustGitDepsQ
forall a. (a -> ()) -> NFData a
$crnf :: FetchRustGitDepsQ -> ()
rnf :: FetchRustGitDepsQ -> ()
NFData, Get FetchRustGitDepsQ
[FetchRustGitDepsQ] -> Put
FetchRustGitDepsQ -> Put
(FetchRustGitDepsQ -> Put)
-> Get FetchRustGitDepsQ
-> ([FetchRustGitDepsQ] -> Put)
-> Binary FetchRustGitDepsQ
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: FetchRustGitDepsQ -> Put
put :: FetchRustGitDepsQ -> Put
$cget :: Get FetchRustGitDepsQ
get :: Get FetchRustGitDepsQ
$cputList :: [FetchRustGitDepsQ] -> Put
putList :: [FetchRustGitDepsQ] -> Put
Binary, Typeable, (forall x. FetchRustGitDepsQ -> Rep FetchRustGitDepsQ x)
-> (forall x. Rep FetchRustGitDepsQ x -> FetchRustGitDepsQ)
-> Generic FetchRustGitDepsQ
forall x. Rep FetchRustGitDepsQ x -> FetchRustGitDepsQ
forall x. FetchRustGitDepsQ -> Rep FetchRustGitDepsQ x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FetchRustGitDepsQ -> Rep FetchRustGitDepsQ x
from :: forall x. FetchRustGitDepsQ -> Rep FetchRustGitDepsQ x
$cto :: forall x. Rep FetchRustGitDepsQ x -> FetchRustGitDepsQ
to :: forall x. Rep FetchRustGitDepsQ x -> FetchRustGitDepsQ
Generic)

-- | @outputHashes@, a mapping from nameVer -> output hash
type instance RuleResult FetchRustGitDepsQ = HashMap Text Checksum

instance Pretty FetchRustGitDepsQ where
  pretty :: forall ann. FetchRustGitDepsQ -> Doc ann
pretty (FetchRustGitDepsQ NixFetcher 'Fetched
f String
n) =
    Doc ann
"FetchRustGitDeps"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep
            [ Doc ann
"fetcher" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> NixFetcher 'Fetched -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. NixFetcher 'Fetched -> Doc ann
pretty NixFetcher 'Fetched
f,
              Doc ann
"cargoLock" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
n
            ]
        )

--------------------------------------------------------------------------------

-- | @strftime@ format
--
-- Nothing defaults to @%Y-%m-%d@
newtype DateFormat = DateFormat (Maybe Text)
  deriving newtype (Int -> DateFormat -> ShowS
[DateFormat] -> ShowS
DateFormat -> String
(Int -> DateFormat -> ShowS)
-> (DateFormat -> String)
-> ([DateFormat] -> ShowS)
-> Show DateFormat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DateFormat -> ShowS
showsPrec :: Int -> DateFormat -> ShowS
$cshow :: DateFormat -> String
show :: DateFormat -> String
$cshowList :: [DateFormat] -> ShowS
showList :: [DateFormat] -> ShowS
Show, DateFormat -> DateFormat -> Bool
(DateFormat -> DateFormat -> Bool)
-> (DateFormat -> DateFormat -> Bool) -> Eq DateFormat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DateFormat -> DateFormat -> Bool
== :: DateFormat -> DateFormat -> Bool
$c/= :: DateFormat -> DateFormat -> Bool
/= :: DateFormat -> DateFormat -> Bool
Eq, Eq DateFormat
Eq DateFormat =>
(DateFormat -> DateFormat -> Ordering)
-> (DateFormat -> DateFormat -> Bool)
-> (DateFormat -> DateFormat -> Bool)
-> (DateFormat -> DateFormat -> Bool)
-> (DateFormat -> DateFormat -> Bool)
-> (DateFormat -> DateFormat -> DateFormat)
-> (DateFormat -> DateFormat -> DateFormat)
-> Ord DateFormat
DateFormat -> DateFormat -> Bool
DateFormat -> DateFormat -> Ordering
DateFormat -> DateFormat -> DateFormat
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: DateFormat -> DateFormat -> Ordering
compare :: DateFormat -> DateFormat -> Ordering
$c< :: DateFormat -> DateFormat -> Bool
< :: DateFormat -> DateFormat -> Bool
$c<= :: DateFormat -> DateFormat -> Bool
<= :: DateFormat -> DateFormat -> Bool
$c> :: DateFormat -> DateFormat -> Bool
> :: DateFormat -> DateFormat -> Bool
$c>= :: DateFormat -> DateFormat -> Bool
>= :: DateFormat -> DateFormat -> Bool
$cmax :: DateFormat -> DateFormat -> DateFormat
max :: DateFormat -> DateFormat -> DateFormat
$cmin :: DateFormat -> DateFormat -> DateFormat
min :: DateFormat -> DateFormat -> DateFormat
Ord, DateFormat
DateFormat -> Default DateFormat
forall a. a -> Default a
$cdef :: DateFormat
def :: DateFormat
Default, (forall ann. DateFormat -> Doc ann)
-> (forall ann. [DateFormat] -> Doc ann) -> Pretty DateFormat
forall ann. [DateFormat] -> Doc ann
forall ann. DateFormat -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. DateFormat -> Doc ann
pretty :: forall ann. DateFormat -> Doc ann
$cprettyList :: forall ann. [DateFormat] -> Doc ann
prettyList :: forall ann. [DateFormat] -> Doc ann
Pretty)
  deriving stock (Typeable, (forall x. DateFormat -> Rep DateFormat x)
-> (forall x. Rep DateFormat x -> DateFormat) -> Generic DateFormat
forall x. Rep DateFormat x -> DateFormat
forall x. DateFormat -> Rep DateFormat x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DateFormat -> Rep DateFormat x
from :: forall x. DateFormat -> Rep DateFormat x
$cto :: forall x. Rep DateFormat x -> DateFormat
to :: forall x. Rep DateFormat x -> DateFormat
Generic)
  deriving anyclass (Eq DateFormat
Eq DateFormat =>
(Int -> DateFormat -> Int)
-> (DateFormat -> Int) -> Hashable DateFormat
Int -> DateFormat -> Int
DateFormat -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> DateFormat -> Int
hashWithSalt :: Int -> DateFormat -> Int
$chash :: DateFormat -> Int
hash :: DateFormat -> Int
Hashable, Get DateFormat
[DateFormat] -> Put
DateFormat -> Put
(DateFormat -> Put)
-> Get DateFormat -> ([DateFormat] -> Put) -> Binary DateFormat
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: DateFormat -> Put
put :: DateFormat -> Put
$cget :: Get DateFormat
get :: Get DateFormat
$cputList :: [DateFormat] -> Put
putList :: [DateFormat] -> Put
Binary, DateFormat -> ()
(DateFormat -> ()) -> NFData DateFormat
forall a. (a -> ()) -> NFData a
$crnf :: DateFormat -> ()
rnf :: DateFormat -> ()
NFData)

-- | Get the commit date by using shallow clone
--
-- @_gformat@ is in.
-- Note: Requires git >= 2.5
data GetGitCommitDate = GetGitCommitDate {GetGitCommitDate -> Text
_gurl :: Text, GetGitCommitDate -> Text
_grev :: Text, GetGitCommitDate -> DateFormat
_gformat :: DateFormat}
  deriving (Int -> GetGitCommitDate -> ShowS
[GetGitCommitDate] -> ShowS
GetGitCommitDate -> String
(Int -> GetGitCommitDate -> ShowS)
-> (GetGitCommitDate -> String)
-> ([GetGitCommitDate] -> ShowS)
-> Show GetGitCommitDate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetGitCommitDate -> ShowS
showsPrec :: Int -> GetGitCommitDate -> ShowS
$cshow :: GetGitCommitDate -> String
show :: GetGitCommitDate -> String
$cshowList :: [GetGitCommitDate] -> ShowS
showList :: [GetGitCommitDate] -> ShowS
Show, GetGitCommitDate -> GetGitCommitDate -> Bool
(GetGitCommitDate -> GetGitCommitDate -> Bool)
-> (GetGitCommitDate -> GetGitCommitDate -> Bool)
-> Eq GetGitCommitDate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetGitCommitDate -> GetGitCommitDate -> Bool
== :: GetGitCommitDate -> GetGitCommitDate -> Bool
$c/= :: GetGitCommitDate -> GetGitCommitDate -> Bool
/= :: GetGitCommitDate -> GetGitCommitDate -> Bool
Eq, Eq GetGitCommitDate
Eq GetGitCommitDate =>
(GetGitCommitDate -> GetGitCommitDate -> Ordering)
-> (GetGitCommitDate -> GetGitCommitDate -> Bool)
-> (GetGitCommitDate -> GetGitCommitDate -> Bool)
-> (GetGitCommitDate -> GetGitCommitDate -> Bool)
-> (GetGitCommitDate -> GetGitCommitDate -> Bool)
-> (GetGitCommitDate -> GetGitCommitDate -> GetGitCommitDate)
-> (GetGitCommitDate -> GetGitCommitDate -> GetGitCommitDate)
-> Ord GetGitCommitDate
GetGitCommitDate -> GetGitCommitDate -> Bool
GetGitCommitDate -> GetGitCommitDate -> Ordering
GetGitCommitDate -> GetGitCommitDate -> GetGitCommitDate
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: GetGitCommitDate -> GetGitCommitDate -> Ordering
compare :: GetGitCommitDate -> GetGitCommitDate -> Ordering
$c< :: GetGitCommitDate -> GetGitCommitDate -> Bool
< :: GetGitCommitDate -> GetGitCommitDate -> Bool
$c<= :: GetGitCommitDate -> GetGitCommitDate -> Bool
<= :: GetGitCommitDate -> GetGitCommitDate -> Bool
$c> :: GetGitCommitDate -> GetGitCommitDate -> Bool
> :: GetGitCommitDate -> GetGitCommitDate -> Bool
$c>= :: GetGitCommitDate -> GetGitCommitDate -> Bool
>= :: GetGitCommitDate -> GetGitCommitDate -> Bool
$cmax :: GetGitCommitDate -> GetGitCommitDate -> GetGitCommitDate
max :: GetGitCommitDate -> GetGitCommitDate -> GetGitCommitDate
$cmin :: GetGitCommitDate -> GetGitCommitDate -> GetGitCommitDate
min :: GetGitCommitDate -> GetGitCommitDate -> GetGitCommitDate
Ord, Eq GetGitCommitDate
Eq GetGitCommitDate =>
(Int -> GetGitCommitDate -> Int)
-> (GetGitCommitDate -> Int) -> Hashable GetGitCommitDate
Int -> GetGitCommitDate -> Int
GetGitCommitDate -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> GetGitCommitDate -> Int
hashWithSalt :: Int -> GetGitCommitDate -> Int
$chash :: GetGitCommitDate -> Int
hash :: GetGitCommitDate -> Int
Hashable, GetGitCommitDate -> ()
(GetGitCommitDate -> ()) -> NFData GetGitCommitDate
forall a. (a -> ()) -> NFData a
$crnf :: GetGitCommitDate -> ()
rnf :: GetGitCommitDate -> ()
NFData, Get GetGitCommitDate
[GetGitCommitDate] -> Put
GetGitCommitDate -> Put
(GetGitCommitDate -> Put)
-> Get GetGitCommitDate
-> ([GetGitCommitDate] -> Put)
-> Binary GetGitCommitDate
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: GetGitCommitDate -> Put
put :: GetGitCommitDate -> Put
$cget :: Get GetGitCommitDate
get :: Get GetGitCommitDate
$cputList :: [GetGitCommitDate] -> Put
putList :: [GetGitCommitDate] -> Put
Binary, Typeable, (forall x. GetGitCommitDate -> Rep GetGitCommitDate x)
-> (forall x. Rep GetGitCommitDate x -> GetGitCommitDate)
-> Generic GetGitCommitDate
forall x. Rep GetGitCommitDate x -> GetGitCommitDate
forall x. GetGitCommitDate -> Rep GetGitCommitDate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. GetGitCommitDate -> Rep GetGitCommitDate x
from :: forall x. GetGitCommitDate -> Rep GetGitCommitDate x
$cto :: forall x. Rep GetGitCommitDate x -> GetGitCommitDate
to :: forall x. Rep GetGitCommitDate x -> GetGitCommitDate
Generic)

type instance RuleResult GetGitCommitDate = Text

instance Pretty GetGitCommitDate where
  pretty :: forall ann. GetGitCommitDate -> Doc ann
pretty GetGitCommitDate {Text
DateFormat
_gurl :: GetGitCommitDate -> Text
_grev :: GetGitCommitDate -> Text
_gformat :: GetGitCommitDate -> DateFormat
_gurl :: Text
_grev :: Text
_gformat :: DateFormat
..} =
    Doc ann
"GetGitCommitDate"
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
line
      Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
indent
        Int
2
        ( [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep
            [ Doc ann
"url" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_gurl,
              Doc ann
"rev" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
_grev,
              Doc ann
"format" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> DateFormat -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. DateFormat -> Doc ann
pretty DateFormat
_gformat
            ]
        )

--------------------------------------------------------------------------------

-- | Package name, used in generating nix expr
type PackageName = Text

-- | How to create package source fetcher given a version
type PackageFetcher = Version -> NixFetcher Fresh

newtype PackageExtractSrc = PackageExtractSrc (NE.NonEmpty FilePath)

newtype PackageCargoLockFiles = PackageCargoLockFiles (NE.NonEmpty FilePath)

newtype PackagePassthru = PackagePassthru (HashMap Text Text)
  deriving newtype (NonEmpty PackagePassthru -> PackagePassthru
PackagePassthru -> PackagePassthru -> PackagePassthru
(PackagePassthru -> PackagePassthru -> PackagePassthru)
-> (NonEmpty PackagePassthru -> PackagePassthru)
-> (forall b.
    Integral b =>
    b -> PackagePassthru -> PackagePassthru)
-> Semigroup PackagePassthru
forall b. Integral b => b -> PackagePassthru -> PackagePassthru
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
$c<> :: PackagePassthru -> PackagePassthru -> PackagePassthru
<> :: PackagePassthru -> PackagePassthru -> PackagePassthru
$csconcat :: NonEmpty PackagePassthru -> PackagePassthru
sconcat :: NonEmpty PackagePassthru -> PackagePassthru
$cstimes :: forall b. Integral b => b -> PackagePassthru -> PackagePassthru
stimes :: forall b. Integral b => b -> PackagePassthru -> PackagePassthru
Semigroup, Semigroup PackagePassthru
PackagePassthru
Semigroup PackagePassthru =>
PackagePassthru
-> (PackagePassthru -> PackagePassthru -> PackagePassthru)
-> ([PackagePassthru] -> PackagePassthru)
-> Monoid PackagePassthru
[PackagePassthru] -> PackagePassthru
PackagePassthru -> PackagePassthru -> PackagePassthru
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
$cmempty :: PackagePassthru
mempty :: PackagePassthru
$cmappend :: PackagePassthru -> PackagePassthru -> PackagePassthru
mappend :: PackagePassthru -> PackagePassthru -> PackagePassthru
$cmconcat :: [PackagePassthru] -> PackagePassthru
mconcat :: [PackagePassthru] -> PackagePassthru
Monoid)

-- | Using stale value indicates that we will /NOT/ check for new versions if
-- there is a known version recovered from json file or last use of the rule.
-- Normally you don't want a stale version
-- unless you need pin a package.
data UseStaleVersion
  = -- | Specified in configuration file
    PermanentStale
  | -- | Specified by @--filter@ command
    TemporaryStale
  | NoStale
  deriving stock (UseStaleVersion -> UseStaleVersion -> Bool
(UseStaleVersion -> UseStaleVersion -> Bool)
-> (UseStaleVersion -> UseStaleVersion -> Bool)
-> Eq UseStaleVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UseStaleVersion -> UseStaleVersion -> Bool
== :: UseStaleVersion -> UseStaleVersion -> Bool
$c/= :: UseStaleVersion -> UseStaleVersion -> Bool
/= :: UseStaleVersion -> UseStaleVersion -> Bool
Eq, Int -> UseStaleVersion -> ShowS
[UseStaleVersion] -> ShowS
UseStaleVersion -> String
(Int -> UseStaleVersion -> ShowS)
-> (UseStaleVersion -> String)
-> ([UseStaleVersion] -> ShowS)
-> Show UseStaleVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UseStaleVersion -> ShowS
showsPrec :: Int -> UseStaleVersion -> ShowS
$cshow :: UseStaleVersion -> String
show :: UseStaleVersion -> String
$cshowList :: [UseStaleVersion] -> ShowS
showList :: [UseStaleVersion] -> ShowS
Show, Eq UseStaleVersion
Eq UseStaleVersion =>
(UseStaleVersion -> UseStaleVersion -> Ordering)
-> (UseStaleVersion -> UseStaleVersion -> Bool)
-> (UseStaleVersion -> UseStaleVersion -> Bool)
-> (UseStaleVersion -> UseStaleVersion -> Bool)
-> (UseStaleVersion -> UseStaleVersion -> Bool)
-> (UseStaleVersion -> UseStaleVersion -> UseStaleVersion)
-> (UseStaleVersion -> UseStaleVersion -> UseStaleVersion)
-> Ord UseStaleVersion
UseStaleVersion -> UseStaleVersion -> Bool
UseStaleVersion -> UseStaleVersion -> Ordering
UseStaleVersion -> UseStaleVersion -> UseStaleVersion
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: UseStaleVersion -> UseStaleVersion -> Ordering
compare :: UseStaleVersion -> UseStaleVersion -> Ordering
$c< :: UseStaleVersion -> UseStaleVersion -> Bool
< :: UseStaleVersion -> UseStaleVersion -> Bool
$c<= :: UseStaleVersion -> UseStaleVersion -> Bool
<= :: UseStaleVersion -> UseStaleVersion -> Bool
$c> :: UseStaleVersion -> UseStaleVersion -> Bool
> :: UseStaleVersion -> UseStaleVersion -> Bool
$c>= :: UseStaleVersion -> UseStaleVersion -> Bool
>= :: UseStaleVersion -> UseStaleVersion -> Bool
$cmax :: UseStaleVersion -> UseStaleVersion -> UseStaleVersion
max :: UseStaleVersion -> UseStaleVersion -> UseStaleVersion
$cmin :: UseStaleVersion -> UseStaleVersion -> UseStaleVersion
min :: UseStaleVersion -> UseStaleVersion -> UseStaleVersion
Ord, Typeable, (forall x. UseStaleVersion -> Rep UseStaleVersion x)
-> (forall x. Rep UseStaleVersion x -> UseStaleVersion)
-> Generic UseStaleVersion
forall x. Rep UseStaleVersion x -> UseStaleVersion
forall x. UseStaleVersion -> Rep UseStaleVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. UseStaleVersion -> Rep UseStaleVersion x
from :: forall x. UseStaleVersion -> Rep UseStaleVersion x
$cto :: forall x. Rep UseStaleVersion x -> UseStaleVersion
to :: forall x. Rep UseStaleVersion x -> UseStaleVersion
Generic)
  deriving anyclass (Eq UseStaleVersion
Eq UseStaleVersion =>
(Int -> UseStaleVersion -> Int)
-> (UseStaleVersion -> Int) -> Hashable UseStaleVersion
Int -> UseStaleVersion -> Int
UseStaleVersion -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> UseStaleVersion -> Int
hashWithSalt :: Int -> UseStaleVersion -> Int
$chash :: UseStaleVersion -> Int
hash :: UseStaleVersion -> Int
Hashable, Get UseStaleVersion
[UseStaleVersion] -> Put
UseStaleVersion -> Put
(UseStaleVersion -> Put)
-> Get UseStaleVersion
-> ([UseStaleVersion] -> Put)
-> Binary UseStaleVersion
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: UseStaleVersion -> Put
put :: UseStaleVersion -> Put
$cget :: Get UseStaleVersion
get :: Get UseStaleVersion
$cputList :: [UseStaleVersion] -> Put
putList :: [UseStaleVersion] -> Put
Binary, UseStaleVersion -> ()
(UseStaleVersion -> ()) -> NFData UseStaleVersion
forall a. (a -> ()) -> NFData a
$crnf :: UseStaleVersion -> ()
rnf :: UseStaleVersion -> ()
NFData)

-- | A package is defined with:
--
-- 1. its name
-- 2. how to track its version
-- 3. how to fetch it as we have the version
-- 4. optional file paths to extract (dump to build dir)
-- 5. optional @Cargo.lock@ path (if it's a rust package)
-- 6. an optional pass through map
-- 7. if the package version was pinned
-- 8. optional git date format (if the version source is git)
-- 9. whether to always fetch a package regardless of the version changing
-- /INVARIANT: 'Version' passed to 'PackageFetcher' MUST be used textually,/
-- /i.e. can only be concatenated with other strings,/
-- /in case we can't check the equality between fetcher functions./
data Package = Package
  { Package -> Text
_pname :: PackageName,
    Package -> CheckVersion
_pversion :: CheckVersion,
    Package -> PackageFetcher
_pfetcher :: PackageFetcher,
    Package -> Maybe PackageExtractSrc
_pextract :: Maybe PackageExtractSrc,
    Package -> Maybe PackageCargoLockFiles
_pcargo :: Maybe PackageCargoLockFiles,
    Package -> PackagePassthru
_ppassthru :: PackagePassthru,
    Package -> UseStaleVersion
_ppinned :: UseStaleVersion,
    Package -> DateFormat
_pgitdateformat :: DateFormat,
    Package -> ForceFetch
_pforcefetch :: ForceFetch
  }

-- | Package key is the name of a package.
-- We use this type to index packages.
newtype PackageKey = PackageKey PackageName
  deriving newtype (PackageKey -> PackageKey -> Bool
(PackageKey -> PackageKey -> Bool)
-> (PackageKey -> PackageKey -> Bool) -> Eq PackageKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PackageKey -> PackageKey -> Bool
== :: PackageKey -> PackageKey -> Bool
$c/= :: PackageKey -> PackageKey -> Bool
/= :: PackageKey -> PackageKey -> Bool
Eq, Int -> PackageKey -> ShowS
[PackageKey] -> ShowS
PackageKey -> String
(Int -> PackageKey -> ShowS)
-> (PackageKey -> String)
-> ([PackageKey] -> ShowS)
-> Show PackageKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PackageKey -> ShowS
showsPrec :: Int -> PackageKey -> ShowS
$cshow :: PackageKey -> String
show :: PackageKey -> String
$cshowList :: [PackageKey] -> ShowS
showList :: [PackageKey] -> ShowS
Show, Eq PackageKey
Eq PackageKey =>
(PackageKey -> PackageKey -> Ordering)
-> (PackageKey -> PackageKey -> Bool)
-> (PackageKey -> PackageKey -> Bool)
-> (PackageKey -> PackageKey -> Bool)
-> (PackageKey -> PackageKey -> Bool)
-> (PackageKey -> PackageKey -> PackageKey)
-> (PackageKey -> PackageKey -> PackageKey)
-> Ord PackageKey
PackageKey -> PackageKey -> Bool
PackageKey -> PackageKey -> Ordering
PackageKey -> PackageKey -> PackageKey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PackageKey -> PackageKey -> Ordering
compare :: PackageKey -> PackageKey -> Ordering
$c< :: PackageKey -> PackageKey -> Bool
< :: PackageKey -> PackageKey -> Bool
$c<= :: PackageKey -> PackageKey -> Bool
<= :: PackageKey -> PackageKey -> Bool
$c> :: PackageKey -> PackageKey -> Bool
> :: PackageKey -> PackageKey -> Bool
$c>= :: PackageKey -> PackageKey -> Bool
>= :: PackageKey -> PackageKey -> Bool
$cmax :: PackageKey -> PackageKey -> PackageKey
max :: PackageKey -> PackageKey -> PackageKey
$cmin :: PackageKey -> PackageKey -> PackageKey
min :: PackageKey -> PackageKey -> PackageKey
Ord, (forall ann. PackageKey -> Doc ann)
-> (forall ann. [PackageKey] -> Doc ann) -> Pretty PackageKey
forall ann. [PackageKey] -> Doc ann
forall ann. PackageKey -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. PackageKey -> Doc ann
pretty :: forall ann. PackageKey -> Doc ann
$cprettyList :: forall ann. [PackageKey] -> Doc ann
prettyList :: forall ann. [PackageKey] -> Doc ann
Pretty)
  deriving stock (Typeable, (forall x. PackageKey -> Rep PackageKey x)
-> (forall x. Rep PackageKey x -> PackageKey) -> Generic PackageKey
forall x. Rep PackageKey x -> PackageKey
forall x. PackageKey -> Rep PackageKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PackageKey -> Rep PackageKey x
from :: forall x. PackageKey -> Rep PackageKey x
$cto :: forall x. Rep PackageKey x -> PackageKey
to :: forall x. Rep PackageKey x -> PackageKey
Generic)
  deriving anyclass (Eq PackageKey
Eq PackageKey =>
(Int -> PackageKey -> Int)
-> (PackageKey -> Int) -> Hashable PackageKey
Int -> PackageKey -> Int
PackageKey -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> PackageKey -> Int
hashWithSalt :: Int -> PackageKey -> Int
$chash :: PackageKey -> Int
hash :: PackageKey -> Int
Hashable, Get PackageKey
[PackageKey] -> Put
PackageKey -> Put
(PackageKey -> Put)
-> Get PackageKey -> ([PackageKey] -> Put) -> Binary PackageKey
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: PackageKey -> Put
put :: PackageKey -> Put
$cget :: Get PackageKey
get :: Get PackageKey
$cputList :: [PackageKey] -> Put
putList :: [PackageKey] -> Put
Binary, PackageKey -> ()
(PackageKey -> ()) -> NFData PackageKey
forall a. (a -> ()) -> NFData a
$crnf :: PackageKey -> ()
rnf :: PackageKey -> ()
NFData)

--------------------------------------------------------------------------------

-- | The key type of nvfetcher rule. See "NvFetcher.Core"
data Core = Core
  deriving (Core -> Core -> Bool
(Core -> Core -> Bool) -> (Core -> Core -> Bool) -> Eq Core
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Core -> Core -> Bool
== :: Core -> Core -> Bool
$c/= :: Core -> Core -> Bool
/= :: Core -> Core -> Bool
Eq, Int -> Core -> ShowS
[Core] -> ShowS
Core -> String
(Int -> Core -> ShowS)
-> (Core -> String) -> ([Core] -> ShowS) -> Show Core
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Core -> ShowS
showsPrec :: Int -> Core -> ShowS
$cshow :: Core -> String
show :: Core -> String
$cshowList :: [Core] -> ShowS
showList :: [Core] -> ShowS
Show, Eq Core
Eq Core =>
(Core -> Core -> Ordering)
-> (Core -> Core -> Bool)
-> (Core -> Core -> Bool)
-> (Core -> Core -> Bool)
-> (Core -> Core -> Bool)
-> (Core -> Core -> Core)
-> (Core -> Core -> Core)
-> Ord Core
Core -> Core -> Bool
Core -> Core -> Ordering
Core -> Core -> Core
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Core -> Core -> Ordering
compare :: Core -> Core -> Ordering
$c< :: Core -> Core -> Bool
< :: Core -> Core -> Bool
$c<= :: Core -> Core -> Bool
<= :: Core -> Core -> Bool
$c> :: Core -> Core -> Bool
> :: Core -> Core -> Bool
$c>= :: Core -> Core -> Bool
>= :: Core -> Core -> Bool
$cmax :: Core -> Core -> Core
max :: Core -> Core -> Core
$cmin :: Core -> Core -> Core
min :: Core -> Core -> Core
Ord, Typeable, (forall x. Core -> Rep Core x)
-> (forall x. Rep Core x -> Core) -> Generic Core
forall x. Rep Core x -> Core
forall x. Core -> Rep Core x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Core -> Rep Core x
from :: forall x. Core -> Rep Core x
$cto :: forall x. Rep Core x -> Core
to :: forall x. Rep Core x -> Core
Generic, Eq Core
Eq Core => (Int -> Core -> Int) -> (Core -> Int) -> Hashable Core
Int -> Core -> Int
Core -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> Core -> Int
hashWithSalt :: Int -> Core -> Int
$chash :: Core -> Int
hash :: Core -> Int
Hashable, Get Core
[Core] -> Put
Core -> Put
(Core -> Put) -> Get Core -> ([Core] -> Put) -> Binary Core
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: Core -> Put
put :: Core -> Put
$cget :: Get Core
get :: Get Core
$cputList :: [Core] -> Put
putList :: [Core] -> Put
Binary, Core -> ()
(Core -> ()) -> NFData Core
forall a. (a -> ()) -> NFData a
$crnf :: Core -> ()
rnf :: Core -> ()
NFData)

-- If prefetch fails, we don't want to fail the whole build
type instance RuleResult Core = Maybe PackageResult

-- | Decorate a rule's key with 'PackageKey'
newtype WithPackageKey k = WithPackageKey (k, PackageKey)
  deriving newtype (WithPackageKey k -> WithPackageKey k -> Bool
(WithPackageKey k -> WithPackageKey k -> Bool)
-> (WithPackageKey k -> WithPackageKey k -> Bool)
-> Eq (WithPackageKey k)
forall k. Eq k => WithPackageKey k -> WithPackageKey k -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall k. Eq k => WithPackageKey k -> WithPackageKey k -> Bool
== :: WithPackageKey k -> WithPackageKey k -> Bool
$c/= :: forall k. Eq k => WithPackageKey k -> WithPackageKey k -> Bool
/= :: WithPackageKey k -> WithPackageKey k -> Bool
Eq, Eq (WithPackageKey k)
Eq (WithPackageKey k) =>
(Int -> WithPackageKey k -> Int)
-> (WithPackageKey k -> Int) -> Hashable (WithPackageKey k)
Int -> WithPackageKey k -> Int
WithPackageKey k -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
forall k. Hashable k => Eq (WithPackageKey k)
forall k. Hashable k => Int -> WithPackageKey k -> Int
forall k. Hashable k => WithPackageKey k -> Int
$chashWithSalt :: forall k. Hashable k => Int -> WithPackageKey k -> Int
hashWithSalt :: Int -> WithPackageKey k -> Int
$chash :: forall k. Hashable k => WithPackageKey k -> Int
hash :: WithPackageKey k -> Int
Hashable, Get (WithPackageKey k)
[WithPackageKey k] -> Put
WithPackageKey k -> Put
(WithPackageKey k -> Put)
-> Get (WithPackageKey k)
-> ([WithPackageKey k] -> Put)
-> Binary (WithPackageKey k)
forall k. Binary k => Get (WithPackageKey k)
forall k. Binary k => [WithPackageKey k] -> Put
forall k. Binary k => WithPackageKey k -> Put
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
$cput :: forall k. Binary k => WithPackageKey k -> Put
put :: WithPackageKey k -> Put
$cget :: forall k. Binary k => Get (WithPackageKey k)
get :: Get (WithPackageKey k)
$cputList :: forall k. Binary k => [WithPackageKey k] -> Put
putList :: [WithPackageKey k] -> Put
Binary, WithPackageKey k -> ()
(WithPackageKey k -> ()) -> NFData (WithPackageKey k)
forall k. NFData k => WithPackageKey k -> ()
forall a. (a -> ()) -> NFData a
$crnf :: forall k. NFData k => WithPackageKey k -> ()
rnf :: WithPackageKey k -> ()
NFData)

instance Show k => Show (WithPackageKey k) where
  show :: WithPackageKey k -> String
show (WithPackageKey (k
k, PackageKey
n)) = k -> String
forall a. Show a => a -> String
show k
k String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" (" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> PackageKey -> String
forall a. Show a => a -> String
show PackageKey
n String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
")"

type instance RuleResult (WithPackageKey k) = RuleResult k

-- | Result type of 'Core'
data PackageResult = PackageResult
  { PackageResult -> Text
_prname :: PackageName,
    PackageResult -> NvcheckerResult
_prversion :: NvcheckerResult,
    PackageResult -> NixFetcher 'Fetched
_prfetched :: NixFetcher 'Fetched,
    PackageResult -> Maybe (HashMap Text Text)
_prpassthru :: Maybe (HashMap Text Text),
    -- | extracted file name -> file path in build dir
    PackageResult -> Maybe (HashMap String Text)
_prextract :: Maybe (HashMap FilePath NixExpr),
    -- | cargo lock file path in build dir -> (file path in nix, git dependencies)
    PackageResult
-> Maybe (HashMap String (Text, HashMap Text Checksum))
_prcargolock :: Maybe (HashMap FilePath (NixExpr, HashMap Text Checksum)),
    PackageResult -> UseStaleVersion
_prpinned :: UseStaleVersion,
    PackageResult -> Maybe Text
_prgitdate :: Maybe Text
  }
  deriving (Int -> PackageResult -> ShowS
[PackageResult] -> ShowS
PackageResult -> String
(Int -> PackageResult -> ShowS)
-> (PackageResult -> String)
-> ([PackageResult] -> ShowS)
-> Show PackageResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PackageResult -> ShowS
showsPrec :: Int -> PackageResult -> ShowS
$cshow :: PackageResult -> String
show :: PackageResult -> String
$cshowList :: [PackageResult] -> ShowS
showList :: [PackageResult] -> ShowS
Show, Typeable, (forall x. PackageResult -> Rep PackageResult x)
-> (forall x. Rep PackageResult x -> PackageResult)
-> Generic PackageResult
forall x. Rep PackageResult x -> PackageResult
forall x. PackageResult -> Rep PackageResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PackageResult -> Rep PackageResult x
from :: forall x. PackageResult -> Rep PackageResult x
$cto :: forall x. Rep PackageResult x -> PackageResult
to :: forall x. Rep PackageResult x -> PackageResult
Generic, PackageResult -> ()
(PackageResult -> ()) -> NFData PackageResult
forall a. (a -> ()) -> NFData a
$crnf :: PackageResult -> ()
rnf :: PackageResult -> ()
NFData)

instance A.ToJSON PackageResult where
  toJSON :: PackageResult -> Value
toJSON PackageResult {Maybe (HashMap String (Text, HashMap Text Checksum))
Maybe (HashMap String Text)
Maybe (HashMap Text Text)
Maybe Text
Text
UseStaleVersion
NixFetcher 'Fetched
NvcheckerResult
_prname :: PackageResult -> Text
_prversion :: PackageResult -> NvcheckerResult
_prfetched :: PackageResult -> NixFetcher 'Fetched
_prpassthru :: PackageResult -> Maybe (HashMap Text Text)
_prextract :: PackageResult -> Maybe (HashMap String Text)
_prcargolock :: PackageResult
-> Maybe (HashMap String (Text, HashMap Text Checksum))
_prpinned :: PackageResult -> UseStaleVersion
_prgitdate :: PackageResult -> Maybe Text
_prname :: Text
_prversion :: NvcheckerResult
_prfetched :: NixFetcher 'Fetched
_prpassthru :: Maybe (HashMap Text Text)
_prextract :: Maybe (HashMap String Text)
_prcargolock :: Maybe (HashMap String (Text, HashMap Text Checksum))
_prpinned :: UseStaleVersion
_prgitdate :: Maybe Text
..} =
    [Pair] -> Value
A.object
      [ Key
"name" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text
_prname,
        Key
"version" Key -> Version -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= NvcheckerResult -> Version
nvNow NvcheckerResult
_prversion,
        Key
"src" Key -> NixFetcher 'Fetched -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= NixFetcher 'Fetched
_prfetched,
        Key
"extract" Key -> Maybe (HashMap String Text) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe (HashMap String Text)
_prextract,
        Key
"passthru" Key -> Maybe (HashMap Text Text) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe (HashMap Text Text)
_prpassthru,
        Key
"cargoLocks" Key -> Maybe (HashMap String (Text, HashMap Text Checksum)) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe (HashMap String (Text, HashMap Text Checksum))
_prcargolock,
        Key
"pinned" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= case UseStaleVersion
_prpinned of
          UseStaleVersion
PermanentStale -> Bool
True
          UseStaleVersion
_ -> Bool
False,
        Key
"date" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
_prgitdate
      ]