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

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

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

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

instance Show VersionChange where
  show :: VersionChange -> FilePath
show VersionChange {Maybe Version
Text
Version
vcNew :: Version
vcOld :: Maybe Version
vcName :: Text
vcNew :: VersionChange -> Version
vcOld :: VersionChange -> Maybe Version
vcName :: VersionChange -> Text
..} =
    Text -> FilePath
T.unpack (Text -> FilePath) -> Text -> FilePath
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
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
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
/= :: VersionSortMethod -> VersionSortMethod -> Bool
$c/= :: VersionSortMethod -> VersionSortMethod -> Bool
== :: VersionSortMethod -> VersionSortMethod -> Bool
$c== :: 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
min :: VersionSortMethod -> VersionSortMethod -> VersionSortMethod
$cmin :: VersionSortMethod -> VersionSortMethod -> VersionSortMethod
max :: VersionSortMethod -> VersionSortMethod -> VersionSortMethod
$cmax :: VersionSortMethod -> VersionSortMethod -> VersionSortMethod
>= :: VersionSortMethod -> VersionSortMethod -> Bool
$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
compare :: VersionSortMethod -> VersionSortMethod -> Ordering
$ccompare :: VersionSortMethod -> VersionSortMethod -> Ordering
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
enumFromThenTo :: VersionSortMethod
-> VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
$cenumFromThenTo :: VersionSortMethod
-> VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
enumFromTo :: VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
$cenumFromTo :: VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
enumFromThen :: VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
$cenumFromThen :: VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
enumFrom :: VersionSortMethod -> [VersionSortMethod]
$cenumFrom :: VersionSortMethod -> [VersionSortMethod]
fromEnum :: VersionSortMethod -> Int
$cfromEnum :: VersionSortMethod -> Int
toEnum :: Int -> VersionSortMethod
$ctoEnum :: Int -> VersionSortMethod
pred :: VersionSortMethod -> VersionSortMethod
$cpred :: VersionSortMethod -> VersionSortMethod
succ :: VersionSortMethod -> VersionSortMethod
$csucc :: 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
$cto :: forall x. Rep VersionSortMethod x -> VersionSortMethod
$cfrom :: forall x. VersionSortMethod -> Rep VersionSortMethod x
Generic, Int -> VersionSortMethod -> Int
VersionSortMethod -> Int
(Int -> VersionSortMethod -> Int)
-> (VersionSortMethod -> Int) -> Hashable VersionSortMethod
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: VersionSortMethod -> Int
$chash :: VersionSortMethod -> Int
hashWithSalt :: Int -> VersionSortMethod -> Int
$chashWithSalt :: Int -> 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
putList :: [VersionSortMethod] -> Put
$cputList :: [VersionSortMethod] -> Put
get :: Get VersionSortMethod
$cget :: Get VersionSortMethod
put :: VersionSortMethod -> Put
$cput :: VersionSortMethod -> Put
Binary, VersionSortMethod -> ()
(VersionSortMethod -> ()) -> NFData VersionSortMethod
forall a. (a -> ()) -> NFData a
rnf :: VersionSortMethod -> ()
$crnf :: VersionSortMethod -> ()
NFData)

instance Show VersionSortMethod where
  show :: VersionSortMethod -> FilePath
show = \case
    VersionSortMethod
ParseVersion -> FilePath
"parse_version"
    VersionSortMethod
Vercmp -> FilePath
"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 -> FilePath
(Int -> ListOptions -> ShowS)
-> (ListOptions -> FilePath)
-> ([ListOptions] -> ShowS)
-> Show ListOptions
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [ListOptions] -> ShowS
$cshowList :: [ListOptions] -> ShowS
show :: ListOptions -> FilePath
$cshow :: ListOptions -> FilePath
showsPrec :: Int -> ListOptions -> ShowS
$cshowsPrec :: Int -> 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
/= :: ListOptions -> ListOptions -> Bool
$c/= :: ListOptions -> ListOptions -> Bool
== :: ListOptions -> ListOptions -> Bool
$c== :: 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
min :: ListOptions -> ListOptions -> ListOptions
$cmin :: ListOptions -> ListOptions -> ListOptions
max :: ListOptions -> ListOptions -> ListOptions
$cmax :: ListOptions -> ListOptions -> ListOptions
>= :: ListOptions -> ListOptions -> Bool
$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
compare :: ListOptions -> ListOptions -> Ordering
$ccompare :: ListOptions -> ListOptions -> Ordering
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
$cto :: forall x. Rep ListOptions x -> ListOptions
$cfrom :: forall x. ListOptions -> Rep ListOptions x
Generic, Int -> ListOptions -> Int
ListOptions -> Int
(Int -> ListOptions -> Int)
-> (ListOptions -> Int) -> Hashable ListOptions
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: ListOptions -> Int
$chash :: ListOptions -> Int
hashWithSalt :: Int -> ListOptions -> Int
$chashWithSalt :: Int -> 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
putList :: [ListOptions] -> Put
$cputList :: [ListOptions] -> Put
get :: Get ListOptions
$cget :: Get ListOptions
put :: ListOptions -> Put
$cput :: ListOptions -> Put
Binary, ListOptions -> ()
(ListOptions -> ()) -> NFData ListOptions
forall a. (a -> ()) -> NFData a
rnf :: ListOptions -> ()
$crnf :: ListOptions -> ()
NFData, ListOptions
ListOptions -> Default ListOptions
forall a. a -> Default a
def :: ListOptions
$cdef :: ListOptions
Default)

isEmptyListOptions :: ListOptions -> Bool
isEmptyListOptions :: ListOptions -> Bool
isEmptyListOptions ListOptions {Maybe Text
Maybe VersionSortMethod
_ignored :: Maybe Text
_sortVersionKey :: Maybe VersionSortMethod
_excludeRegex :: Maybe Text
_includeRegex :: Maybe Text
_ignored :: ListOptions -> Maybe Text
_sortVersionKey :: ListOptions -> Maybe VersionSortMethod
_excludeRegex :: ListOptions -> Maybe Text
_includeRegex :: ListOptions -> 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
_ignored :: Maybe Text
_sortVersionKey :: Maybe VersionSortMethod
_excludeRegex :: Maybe Text
_includeRegex :: Maybe Text
_ignored :: ListOptions -> Maybe Text
_sortVersionKey :: ListOptions -> Maybe VersionSortMethod
_excludeRegex :: ListOptions -> Maybe Text
_includeRegex :: ListOptions -> 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 -> FilePath
(Int -> NvcheckerOptions -> ShowS)
-> (NvcheckerOptions -> FilePath)
-> ([NvcheckerOptions] -> ShowS)
-> Show NvcheckerOptions
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [NvcheckerOptions] -> ShowS
$cshowList :: [NvcheckerOptions] -> ShowS
show :: NvcheckerOptions -> FilePath
$cshow :: NvcheckerOptions -> FilePath
showsPrec :: Int -> NvcheckerOptions -> ShowS
$cshowsPrec :: Int -> 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
/= :: NvcheckerOptions -> NvcheckerOptions -> Bool
$c/= :: NvcheckerOptions -> NvcheckerOptions -> Bool
== :: NvcheckerOptions -> NvcheckerOptions -> Bool
$c== :: 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
min :: NvcheckerOptions -> NvcheckerOptions -> NvcheckerOptions
$cmin :: NvcheckerOptions -> NvcheckerOptions -> NvcheckerOptions
max :: NvcheckerOptions -> NvcheckerOptions -> NvcheckerOptions
$cmax :: NvcheckerOptions -> NvcheckerOptions -> NvcheckerOptions
>= :: NvcheckerOptions -> NvcheckerOptions -> Bool
$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
compare :: NvcheckerOptions -> NvcheckerOptions -> Ordering
$ccompare :: NvcheckerOptions -> NvcheckerOptions -> Ordering
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
$cto :: forall x. Rep NvcheckerOptions x -> NvcheckerOptions
$cfrom :: forall x. NvcheckerOptions -> Rep NvcheckerOptions x
Generic, Int -> NvcheckerOptions -> Int
NvcheckerOptions -> Int
(Int -> NvcheckerOptions -> Int)
-> (NvcheckerOptions -> Int) -> Hashable NvcheckerOptions
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: NvcheckerOptions -> Int
$chash :: NvcheckerOptions -> Int
hashWithSalt :: Int -> NvcheckerOptions -> Int
$chashWithSalt :: Int -> 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
putList :: [NvcheckerOptions] -> Put
$cputList :: [NvcheckerOptions] -> Put
get :: Get NvcheckerOptions
$cget :: Get NvcheckerOptions
put :: NvcheckerOptions -> Put
$cput :: NvcheckerOptions -> Put
Binary, NvcheckerOptions -> ()
(NvcheckerOptions -> ()) -> NFData NvcheckerOptions
forall a. (a -> ()) -> NFData a
rnf :: NvcheckerOptions -> ()
$crnf :: NvcheckerOptions -> ()
NFData, NvcheckerOptions
NvcheckerOptions -> Default NvcheckerOptions
forall a. a -> Default a
def :: NvcheckerOptions
$cdef :: NvcheckerOptions
Default)

isEmptyNvcheckerOptions :: NvcheckerOptions -> Bool
isEmptyNvcheckerOptions :: NvcheckerOptions -> Bool
isEmptyNvcheckerOptions NvcheckerOptions {Maybe Text
_toPattern :: Maybe Text
_fromPattern :: Maybe Text
_stripPrefix :: Maybe Text
_toPattern :: NvcheckerOptions -> Maybe Text
_fromPattern :: NvcheckerOptions -> Maybe Text
_stripPrefix :: NvcheckerOptions -> 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
_toPattern :: Maybe Text
_fromPattern :: Maybe Text
_stripPrefix :: Maybe Text
_toPattern :: NvcheckerOptions -> Maybe Text
_fromPattern :: NvcheckerOptions -> Maybe Text
_stripPrefix :: NvcheckerOptions -> 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 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}
  deriving (Int -> VersionSource -> ShowS
[VersionSource] -> ShowS
VersionSource -> FilePath
(Int -> VersionSource -> ShowS)
-> (VersionSource -> FilePath)
-> ([VersionSource] -> ShowS)
-> Show VersionSource
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [VersionSource] -> ShowS
$cshowList :: [VersionSource] -> ShowS
show :: VersionSource -> FilePath
$cshow :: VersionSource -> FilePath
showsPrec :: Int -> VersionSource -> ShowS
$cshowsPrec :: Int -> 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
/= :: VersionSource -> VersionSource -> Bool
$c/= :: VersionSource -> VersionSource -> Bool
== :: VersionSource -> VersionSource -> Bool
$c== :: 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
min :: VersionSource -> VersionSource -> VersionSource
$cmin :: VersionSource -> VersionSource -> VersionSource
max :: VersionSource -> VersionSource -> VersionSource
$cmax :: VersionSource -> VersionSource -> VersionSource
>= :: VersionSource -> VersionSource -> Bool
$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
compare :: VersionSource -> VersionSource -> Ordering
$ccompare :: VersionSource -> VersionSource -> Ordering
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
$cto :: forall x. Rep VersionSource x -> VersionSource
$cfrom :: forall x. VersionSource -> Rep VersionSource x
Generic, Int -> VersionSource -> Int
VersionSource -> Int
(Int -> VersionSource -> Int)
-> (VersionSource -> Int) -> Hashable VersionSource
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: VersionSource -> Int
$chash :: VersionSource -> Int
hashWithSalt :: Int -> VersionSource -> Int
$chashWithSalt :: Int -> 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
putList :: [VersionSource] -> Put
$cputList :: [VersionSource] -> Put
get :: Get VersionSource
$cget :: Get VersionSource
put :: VersionSource -> Put
$cput :: VersionSource -> Put
Binary, VersionSource -> ()
(VersionSource -> ()) -> NFData VersionSource
forall a. (a -> ()) -> NFData a
rnf :: VersionSource -> ()
$crnf :: VersionSource -> ()
NFData)

instance Pretty VersionSource where
  pretty :: forall ann. VersionSource -> Doc ann
pretty GitHubRelease {Text
_repo :: Text
_owner :: Text
_repo :: VersionSource -> Text
_owner :: VersionSource -> 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 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 a ann. Pretty a => a -> Doc ann
pretty Text
_repo
            ]
        )
  pretty GitHubTag {Text
ListOptions
_listOptions :: ListOptions
_repo :: Text
_owner :: Text
_listOptions :: VersionSource -> ListOptions
_repo :: VersionSource -> Text
_owner :: VersionSource -> Text
..} =
    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 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 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
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
_vbranch :: Branch
_vurl :: Text
_vbranch :: VersionSource -> Branch
_vurl :: VersionSource -> Text
..} =
    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 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
pretty Branch
_vbranch
            ]
        )
  pretty Pypi {Text
_pypi :: Text
_pypi :: VersionSource -> 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 a ann. Pretty a => a -> Doc ann
pretty Text
_pypi
  pretty ArchLinux {Text
_archpkg :: Text
_archpkg :: VersionSource -> 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 a ann. Pretty a => a -> Doc ann
pretty Text
_archpkg
  pretty Aur {Text
_aur :: Text
_aur :: VersionSource -> 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 a ann. Pretty a => a -> Doc ann
pretty Text
_aur
  pretty Manual {Text
_manual :: Text
_manual :: VersionSource -> 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 a ann. Pretty a => a -> Doc ann
pretty Text
_manual
  pretty Repology {Text
_repo :: Text
_repology :: Text
_repology :: VersionSource -> Text
_repo :: VersionSource -> 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 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 a ann. Pretty a => a -> Doc ann
pretty Text
_repo
            ]
        )
  pretty Webpage {Text
ListOptions
_listOptions :: ListOptions
_regex :: Text
_vurl :: Text
_regex :: VersionSource -> Text
_vurl :: VersionSource -> Text
_listOptions :: VersionSource -> 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 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 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
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 :: ListOptions
_regex :: Text
_vurl :: Text
_regex :: VersionSource -> Text
_vurl :: VersionSource -> Text
_listOptions :: VersionSource -> 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 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 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
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
_ovExtName :: Text
_ovPublisher :: Text
_ovExtName :: VersionSource -> Text
_ovPublisher :: VersionSource -> 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 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 a ann. Pretty a => a -> Doc ann
pretty Text
_ovExtName
            ]
        )
  pretty VscodeMarketplace {Text
_vsmExtName :: Text
_vsmPublisher :: Text
_vsmExtName :: VersionSource -> Text
_vsmPublisher :: VersionSource -> 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 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 a ann. Pretty a => a -> Doc ann
pretty Text
_vsmExtName
            ]
        )
  pretty Cmd {Text
_vcmd :: Text
_vcmd :: VersionSource -> 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 a ann. Pretty a => a -> Doc ann
pretty Text
_vcmd

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

-- | Parsed JSON output from nvchecker
newtype NvcheckerRaw = NvcheckerRaw Version
  deriving (Int -> NvcheckerRaw -> ShowS
[NvcheckerRaw] -> ShowS
NvcheckerRaw -> FilePath
(Int -> NvcheckerRaw -> ShowS)
-> (NvcheckerRaw -> FilePath)
-> ([NvcheckerRaw] -> ShowS)
-> Show NvcheckerRaw
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [NvcheckerRaw] -> ShowS
$cshowList :: [NvcheckerRaw] -> ShowS
show :: NvcheckerRaw -> FilePath
$cshow :: NvcheckerRaw -> FilePath
showsPrec :: Int -> NvcheckerRaw -> ShowS
$cshowsPrec :: Int -> 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
/= :: NvcheckerRaw -> NvcheckerRaw -> Bool
$c/= :: NvcheckerRaw -> NvcheckerRaw -> Bool
== :: NvcheckerRaw -> NvcheckerRaw -> Bool
$c== :: 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
$cto :: forall x. Rep NvcheckerRaw x -> NvcheckerRaw
$cfrom :: forall x. NvcheckerRaw -> Rep NvcheckerRaw x
Generic)

instance A.FromJSON NvcheckerRaw where
  parseJSON :: Value -> Parser NvcheckerRaw
parseJSON = FilePath
-> (Object -> Parser NvcheckerRaw) -> Value -> Parser NvcheckerRaw
forall a. FilePath -> (Object -> Parser a) -> Value -> Parser a
A.withObject FilePath
"NvcheckerRaw" ((Object -> Parser NvcheckerRaw) -> Value -> Parser NvcheckerRaw)
-> (Object -> Parser NvcheckerRaw) -> Value -> Parser NvcheckerRaw
forall a b. (a -> b) -> a -> b
$ \Object
o ->
    Version -> NvcheckerRaw
NvcheckerRaw (Version -> NvcheckerRaw) -> Parser Version -> Parser NvcheckerRaw
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser Version
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"version"

type instance RuleResult CheckVersion = NvcheckerResult

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

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

type instance RuleResult RunFetch = 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 -> Maybe Text
_name :: Maybe Text,
        forall (k :: FetchStatus). NixFetcher k -> FetchResult k
_sha256 :: FetchResult 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,
        _name :: Maybe Text,
        _sha256 :: FetchResult k
      }
  | FetchUrl
      { _furl :: Text,
        _name :: Maybe Text,
        _sha256 :: FetchResult k
      }
  | FetchTarball
      { _furl :: Text,
        _sha256 :: FetchResult k
      }
  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
$cto :: forall (k :: FetchStatus) x. Rep (NixFetcher k) x -> NixFetcher k
$cfrom :: forall (k :: FetchStatus) x. NixFetcher k -> Rep (NixFetcher k) x
Generic)

deriving instance Show (FetchResult k) => Show (NixFetcher k)

deriving instance Eq (FetchResult k) => Eq (NixFetcher k)

deriving instance Ord (FetchResult k) => Ord (NixFetcher k)

deriving instance Hashable (FetchResult k) => Hashable (NixFetcher k)

deriving instance Binary (FetchResult k) => Binary (NixFetcher k)

deriving instance NFData (FetchResult k) => NFData (NixFetcher k)

-- | Fetch status
data FetchStatus = Fresh | Fetched

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

instance A.ToJSON (NixFetcher Fetched) where
  toJSON :: NixFetcher 'Fetched -> Value
toJSON FetchGit {Bool
Maybe Text
Text
FetchResult 'Fetched
Version
_sha256 :: FetchResult 'Fetched
_name :: Maybe Text
_leaveDotGit :: Bool
_fetchSubmodules :: Bool
_deepClone :: Bool
_rev :: Version
_furl :: Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult k
_name :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_leaveDotGit :: forall (k :: FetchStatus). NixFetcher k -> Bool
_fetchSubmodules :: forall (k :: FetchStatus). NixFetcher k -> Bool
_deepClone :: forall (k :: FetchStatus). NixFetcher k -> Bool
_rev :: forall (k :: FetchStatus). NixFetcher k -> Version
_furl :: forall (k :: FetchStatus). NixFetcher k -> Text
..} =
    [Pair] -> Value
A.object
      [ Key
"url" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Text
_furl,
        Key
"rev" Key -> Version -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Version
_rev,
        Key
"deepClone" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Bool
_deepClone,
        Key
"fetchSubmodules" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Bool
_fetchSubmodules,
        Key
"leaveDotGit" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Bool
_leaveDotGit,
        Key
"name" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Maybe Text
_name,
        Key
"sha256" Key -> Checksum -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= FetchResult 'Fetched
Checksum
_sha256,
        Key
"type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Text -> Value
A.String Text
"git"
      ]
  toJSON FetchGitHub {Bool
Maybe Text
Text
FetchResult 'Fetched
Version
_sha256 :: FetchResult 'Fetched
_name :: Maybe Text
_leaveDotGit :: Bool
_fetchSubmodules :: Bool
_deepClone :: Bool
_rev :: Version
_frepo :: Text
_fowner :: Text
_frepo :: forall (k :: FetchStatus). NixFetcher k -> Text
_fowner :: forall (k :: FetchStatus). NixFetcher k -> Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult k
_name :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_leaveDotGit :: forall (k :: FetchStatus). NixFetcher k -> Bool
_fetchSubmodules :: forall (k :: FetchStatus). NixFetcher k -> Bool
_deepClone :: forall (k :: FetchStatus). NixFetcher k -> Bool
_rev :: forall (k :: FetchStatus). NixFetcher k -> Version
..} =
    [Pair] -> Value
A.object
      [ Key
"owner" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Text
_fowner,
        Key
"repo" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Text
_frepo,
        Key
"rev" Key -> Version -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Version
_rev,
        Key
"deepClone" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Bool
_deepClone,
        Key
"fetchSubmodules" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Bool
_fetchSubmodules,
        Key
"leaveDotGit" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Bool
_leaveDotGit,
        Key
"name" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Maybe Text
_name,
        Key
"sha256" Key -> Checksum -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= FetchResult 'Fetched
Checksum
_sha256,
        Key
"type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Text -> Value
A.String Text
"github"
      ]
  toJSON FetchUrl {Maybe Text
Text
FetchResult 'Fetched
_sha256 :: FetchResult 'Fetched
_name :: Maybe Text
_furl :: Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult k
_name :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_furl :: forall (k :: FetchStatus). NixFetcher k -> Text
..} =
    [Pair] -> Value
A.object
      [ Key
"url" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Text
_furl,
        Key
"name" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Maybe Text
_name,
        Key
"sha256" Key -> Checksum -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= FetchResult 'Fetched
Checksum
_sha256,
        Key
"type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Text -> Value
A.String Text
"url"
      ]
  toJSON FetchTarball {Text
FetchResult 'Fetched
_sha256 :: FetchResult 'Fetched
_furl :: Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult k
_furl :: forall (k :: FetchStatus). NixFetcher k -> Text
..} =
    [Pair] -> Value
A.object
      [ Key
"url" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Text
_furl,
        Key
"sha256" Key -> Checksum -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= FetchResult 'Fetched
Checksum
_sha256,
        Key
"type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Text -> Value
A.String Text
"tarball"
      ]

instance Pretty (NixFetcher k) where
  pretty :: forall ann. NixFetcher k -> Doc ann
pretty FetchGit {Bool
Maybe Text
Text
FetchResult k
Version
_sha256 :: FetchResult k
_name :: Maybe Text
_leaveDotGit :: Bool
_fetchSubmodules :: Bool
_deepClone :: Bool
_rev :: Version
_furl :: Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult k
_name :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_leaveDotGit :: forall (k :: FetchStatus). NixFetcher k -> Bool
_fetchSubmodules :: forall (k :: FetchStatus). NixFetcher k -> Bool
_deepClone :: forall (k :: FetchStatus). NixFetcher k -> Bool
_rev :: forall (k :: FetchStatus). NixFetcher k -> Version
_furl :: forall (k :: FetchStatus). NixFetcher k -> Text
..} =
    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 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
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 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 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 a ann. Pretty a => a -> Doc ann
pretty Bool
_leaveDotGit
            ]
              [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
Maybe Text
Text
FetchResult k
Version
_sha256 :: FetchResult k
_name :: Maybe Text
_leaveDotGit :: Bool
_fetchSubmodules :: Bool
_deepClone :: Bool
_rev :: Version
_frepo :: Text
_fowner :: Text
_frepo :: forall (k :: FetchStatus). NixFetcher k -> Text
_fowner :: forall (k :: FetchStatus). NixFetcher k -> Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult k
_name :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_leaveDotGit :: forall (k :: FetchStatus). NixFetcher k -> Bool
_fetchSubmodules :: forall (k :: FetchStatus). NixFetcher k -> Bool
_deepClone :: forall (k :: FetchStatus). NixFetcher k -> Bool
_rev :: forall (k :: FetchStatus). NixFetcher k -> Version
..} =
    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 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 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
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 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 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 a ann. Pretty a => a -> Doc ann
pretty Bool
_leaveDotGit
            ]
              [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 k
_sha256 :: FetchResult k
_name :: Maybe Text
_furl :: Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult k
_name :: forall (k :: FetchStatus). NixFetcher k -> Maybe Text
_furl :: forall (k :: FetchStatus). NixFetcher k -> Text
..} =
    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 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 k
_sha256 :: FetchResult k
_furl :: Text
_sha256 :: forall (k :: FetchStatus). NixFetcher k -> FetchResult k
_furl :: forall (k :: FetchStatus). NixFetcher k -> Text
..} =
    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 a ann. Pretty a => a -> Doc ann
pretty Text
_furl

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

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

type instance RuleResult ExtractSrcQ = HashMap FilePath Text

instance Pretty ExtractSrcQ where
  pretty :: forall ann. ExtractSrcQ -> Doc ann
pretty (ExtractSrcQ NixFetcher 'Fetched
f NonEmpty FilePath
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
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 FilePath -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty NonEmpty FilePath
n
            ]
        )

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

-- | Fetch @[email protected] for git dependencies in @[email protected]
-- 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 @[email protected]
data FetchRustGitDepsQ = FetchRustGitDepsQ (NixFetcher Fetched) FilePath
  deriving (Int -> FetchRustGitDepsQ -> ShowS
[FetchRustGitDepsQ] -> ShowS
FetchRustGitDepsQ -> FilePath
(Int -> FetchRustGitDepsQ -> ShowS)
-> (FetchRustGitDepsQ -> FilePath)
-> ([FetchRustGitDepsQ] -> ShowS)
-> Show FetchRustGitDepsQ
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [FetchRustGitDepsQ] -> ShowS
$cshowList :: [FetchRustGitDepsQ] -> ShowS
show :: FetchRustGitDepsQ -> FilePath
$cshow :: FetchRustGitDepsQ -> FilePath
showsPrec :: Int -> FetchRustGitDepsQ -> ShowS
$cshowsPrec :: Int -> FetchRustGitDepsQ -> ShowS
Show, FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
(FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool)
-> (FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool)
-> Eq FetchRustGitDepsQ
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
$c/= :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
== :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
$c== :: 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
min :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> FetchRustGitDepsQ
$cmin :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> FetchRustGitDepsQ
max :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> FetchRustGitDepsQ
$cmax :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> FetchRustGitDepsQ
>= :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Bool
$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
compare :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Ordering
$ccompare :: FetchRustGitDepsQ -> FetchRustGitDepsQ -> Ordering
Ord, Int -> FetchRustGitDepsQ -> Int
FetchRustGitDepsQ -> Int
(Int -> FetchRustGitDepsQ -> Int)
-> (FetchRustGitDepsQ -> Int) -> Hashable FetchRustGitDepsQ
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: FetchRustGitDepsQ -> Int
$chash :: FetchRustGitDepsQ -> Int
hashWithSalt :: Int -> FetchRustGitDepsQ -> Int
$chashWithSalt :: Int -> FetchRustGitDepsQ -> Int
Hashable, FetchRustGitDepsQ -> ()
(FetchRustGitDepsQ -> ()) -> NFData FetchRustGitDepsQ
forall a. (a -> ()) -> NFData a
rnf :: FetchRustGitDepsQ -> ()
$crnf :: 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
putList :: [FetchRustGitDepsQ] -> Put
$cputList :: [FetchRustGitDepsQ] -> Put
get :: Get FetchRustGitDepsQ
$cget :: Get FetchRustGitDepsQ
put :: FetchRustGitDepsQ -> Put
$cput :: 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
$cto :: forall x. Rep FetchRustGitDepsQ x -> FetchRustGitDepsQ
$cfrom :: forall x. FetchRustGitDepsQ -> Rep FetchRustGitDepsQ x
Generic)

-- | @[email protected], 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 FilePath
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
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
<+> FilePath -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty FilePath
n
            ]
        )

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

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

-- | Get the commit date by using shallow clone
--
-- @[email protected] 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 -> FilePath
(Int -> GetGitCommitDate -> ShowS)
-> (GetGitCommitDate -> FilePath)
-> ([GetGitCommitDate] -> ShowS)
-> Show GetGitCommitDate
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [GetGitCommitDate] -> ShowS
$cshowList :: [GetGitCommitDate] -> ShowS
show :: GetGitCommitDate -> FilePath
$cshow :: GetGitCommitDate -> FilePath
showsPrec :: Int -> GetGitCommitDate -> ShowS
$cshowsPrec :: Int -> GetGitCommitDate -> ShowS
Show, GetGitCommitDate -> GetGitCommitDate -> Bool
(GetGitCommitDate -> GetGitCommitDate -> Bool)
-> (GetGitCommitDate -> GetGitCommitDate -> Bool)
-> Eq GetGitCommitDate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetGitCommitDate -> GetGitCommitDate -> Bool
$c/= :: GetGitCommitDate -> GetGitCommitDate -> Bool
== :: GetGitCommitDate -> GetGitCommitDate -> Bool
$c== :: 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
min :: GetGitCommitDate -> GetGitCommitDate -> GetGitCommitDate
$cmin :: GetGitCommitDate -> GetGitCommitDate -> GetGitCommitDate
max :: GetGitCommitDate -> GetGitCommitDate -> GetGitCommitDate
$cmax :: GetGitCommitDate -> GetGitCommitDate -> GetGitCommitDate
>= :: GetGitCommitDate -> GetGitCommitDate -> Bool
$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
compare :: GetGitCommitDate -> GetGitCommitDate -> Ordering
$ccompare :: GetGitCommitDate -> GetGitCommitDate -> Ordering
Ord, Int -> GetGitCommitDate -> Int
GetGitCommitDate -> Int
(Int -> GetGitCommitDate -> Int)
-> (GetGitCommitDate -> Int) -> Hashable GetGitCommitDate
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: GetGitCommitDate -> Int
$chash :: GetGitCommitDate -> Int
hashWithSalt :: Int -> GetGitCommitDate -> Int
$chashWithSalt :: Int -> GetGitCommitDate -> Int
Hashable, GetGitCommitDate -> ()
(GetGitCommitDate -> ()) -> NFData GetGitCommitDate
forall a. (a -> ()) -> NFData a
rnf :: GetGitCommitDate -> ()
$crnf :: 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
putList :: [GetGitCommitDate] -> Put
$cputList :: [GetGitCommitDate] -> Put
get :: Get GetGitCommitDate
$cget :: Get GetGitCommitDate
put :: GetGitCommitDate -> Put
$cput :: 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
$cto :: forall x. Rep GetGitCommitDate x -> GetGitCommitDate
$cfrom :: forall x. GetGitCommitDate -> Rep GetGitCommitDate x
Generic)

type instance RuleResult GetGitCommitDate = Text

instance Pretty GetGitCommitDate where
  pretty :: forall ann. GetGitCommitDate -> Doc ann
pretty GetGitCommitDate {Text
DateFormat
_gformat :: DateFormat
_grev :: Text
_gurl :: Text
_gformat :: GetGitCommitDate -> DateFormat
_grev :: GetGitCommitDate -> Text
_gurl :: GetGitCommitDate -> Text
..} =
    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 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 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
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
stimes :: forall b. Integral b => b -> PackagePassthru -> PackagePassthru
$cstimes :: forall b. Integral b => b -> PackagePassthru -> PackagePassthru
sconcat :: NonEmpty PackagePassthru -> PackagePassthru
$csconcat :: NonEmpty PackagePassthru -> PackagePassthru
<> :: PackagePassthru -> PackagePassthru -> PackagePassthru
$c<> :: PackagePassthru -> 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
mconcat :: [PackagePassthru] -> PackagePassthru
$cmconcat :: [PackagePassthru] -> PackagePassthru
mappend :: PackagePassthru -> PackagePassthru -> PackagePassthru
$cmappend :: PackagePassthru -> PackagePassthru -> PackagePassthru
mempty :: PackagePassthru
$cmempty :: 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 @[email protected] 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
/= :: UseStaleVersion -> UseStaleVersion -> Bool
$c/= :: UseStaleVersion -> UseStaleVersion -> Bool
== :: UseStaleVersion -> UseStaleVersion -> Bool
$c== :: UseStaleVersion -> UseStaleVersion -> Bool
Eq, Int -> UseStaleVersion -> ShowS
[UseStaleVersion] -> ShowS
UseStaleVersion -> FilePath
(Int -> UseStaleVersion -> ShowS)
-> (UseStaleVersion -> FilePath)
-> ([UseStaleVersion] -> ShowS)
-> Show UseStaleVersion
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [UseStaleVersion] -> ShowS
$cshowList :: [UseStaleVersion] -> ShowS
show :: UseStaleVersion -> FilePath
$cshow :: UseStaleVersion -> FilePath
showsPrec :: Int -> UseStaleVersion -> ShowS
$cshowsPrec :: Int -> 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
min :: UseStaleVersion -> UseStaleVersion -> UseStaleVersion
$cmin :: UseStaleVersion -> UseStaleVersion -> UseStaleVersion
max :: UseStaleVersion -> UseStaleVersion -> UseStaleVersion
$cmax :: UseStaleVersion -> UseStaleVersion -> UseStaleVersion
>= :: UseStaleVersion -> UseStaleVersion -> Bool
$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
compare :: UseStaleVersion -> UseStaleVersion -> Ordering
$ccompare :: UseStaleVersion -> UseStaleVersion -> Ordering
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
$cto :: forall x. Rep UseStaleVersion x -> UseStaleVersion
$cfrom :: forall x. UseStaleVersion -> Rep UseStaleVersion x
Generic)
  deriving anyclass (Int -> UseStaleVersion -> Int
UseStaleVersion -> Int
(Int -> UseStaleVersion -> Int)
-> (UseStaleVersion -> Int) -> Hashable UseStaleVersion
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: UseStaleVersion -> Int
$chash :: UseStaleVersion -> Int
hashWithSalt :: Int -> UseStaleVersion -> Int
$chashWithSalt :: Int -> 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
putList :: [UseStaleVersion] -> Put
$cputList :: [UseStaleVersion] -> Put
get :: Get UseStaleVersion
$cget :: Get UseStaleVersion
put :: UseStaleVersion -> Put
$cput :: UseStaleVersion -> Put
Binary, UseStaleVersion -> ()
(UseStaleVersion -> ()) -> NFData UseStaleVersion
forall a. (a -> ()) -> NFData a
rnf :: UseStaleVersion -> ()
$crnf :: 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 @[email protected] 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
/= :: PackageKey -> PackageKey -> Bool
$c/= :: PackageKey -> PackageKey -> Bool
== :: PackageKey -> PackageKey -> Bool
$c== :: PackageKey -> PackageKey -> Bool
Eq, Int -> PackageKey -> ShowS
[PackageKey] -> ShowS
PackageKey -> FilePath
(Int -> PackageKey -> ShowS)
-> (PackageKey -> FilePath)
-> ([PackageKey] -> ShowS)
-> Show PackageKey
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [PackageKey] -> ShowS
$cshowList :: [PackageKey] -> ShowS
show :: PackageKey -> FilePath
$cshow :: PackageKey -> FilePath
showsPrec :: Int -> PackageKey -> ShowS
$cshowsPrec :: Int -> 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
min :: PackageKey -> PackageKey -> PackageKey
$cmin :: PackageKey -> PackageKey -> PackageKey
max :: PackageKey -> PackageKey -> PackageKey
$cmax :: PackageKey -> PackageKey -> PackageKey
>= :: PackageKey -> PackageKey -> Bool
$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
compare :: PackageKey -> PackageKey -> Ordering
$ccompare :: PackageKey -> PackageKey -> Ordering
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
prettyList :: forall ann. [PackageKey] -> Doc ann
$cprettyList :: forall ann. [PackageKey] -> Doc ann
pretty :: forall ann. PackageKey -> Doc ann
$cpretty :: 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
$cto :: forall x. Rep PackageKey x -> PackageKey
$cfrom :: forall x. PackageKey -> Rep PackageKey x
Generic)
  deriving anyclass (Int -> PackageKey -> Int
PackageKey -> Int
(Int -> PackageKey -> Int)
-> (PackageKey -> Int) -> Hashable PackageKey
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: PackageKey -> Int
$chash :: PackageKey -> Int
hashWithSalt :: Int -> PackageKey -> Int
$chashWithSalt :: Int -> 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
putList :: [PackageKey] -> Put
$cputList :: [PackageKey] -> Put
get :: Get PackageKey
$cget :: Get PackageKey
put :: PackageKey -> Put
$cput :: PackageKey -> Put
Binary, PackageKey -> ()
(PackageKey -> ()) -> NFData PackageKey
forall a. (a -> ()) -> NFData a
rnf :: PackageKey -> ()
$crnf :: 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
/= :: Core -> Core -> Bool
$c/= :: Core -> Core -> Bool
== :: Core -> Core -> Bool
$c== :: Core -> Core -> Bool
Eq, Int -> Core -> ShowS
[Core] -> ShowS
Core -> FilePath
(Int -> Core -> ShowS)
-> (Core -> FilePath) -> ([Core] -> ShowS) -> Show Core
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [Core] -> ShowS
$cshowList :: [Core] -> ShowS
show :: Core -> FilePath
$cshow :: Core -> FilePath
showsPrec :: Int -> Core -> ShowS
$cshowsPrec :: Int -> 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
min :: Core -> Core -> Core
$cmin :: Core -> Core -> Core
max :: Core -> Core -> Core
$cmax :: Core -> Core -> Core
>= :: Core -> Core -> Bool
$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
compare :: Core -> Core -> Ordering
$ccompare :: Core -> Core -> Ordering
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
$cto :: forall x. Rep Core x -> Core
$cfrom :: forall x. Core -> Rep Core x
Generic, Int -> Core -> Int
Core -> Int
(Int -> Core -> Int) -> (Core -> Int) -> Hashable Core
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: Core -> Int
$chash :: Core -> Int
hashWithSalt :: Int -> Core -> Int
$chashWithSalt :: Int -> 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
putList :: [Core] -> Put
$cputList :: [Core] -> Put
get :: Get Core
$cget :: Get Core
put :: Core -> Put
$cput :: Core -> Put
Binary, Core -> ()
(Core -> ()) -> NFData Core
forall a. (a -> ()) -> NFData a
rnf :: Core -> ()
$crnf :: Core -> ()
NFData)

type instance RuleResult Core = 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
/= :: WithPackageKey k -> WithPackageKey k -> Bool
$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
Eq, Int -> WithPackageKey k -> Int
WithPackageKey k -> Int
(Int -> WithPackageKey k -> Int)
-> (WithPackageKey k -> Int) -> Hashable (WithPackageKey k)
forall k. Hashable k => Int -> WithPackageKey k -> Int
forall k. Hashable k => WithPackageKey k -> Int
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: WithPackageKey k -> Int
$chash :: forall k. Hashable k => WithPackageKey k -> Int
hashWithSalt :: Int -> WithPackageKey k -> Int
$chashWithSalt :: forall k. Hashable k => Int -> 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
putList :: [WithPackageKey k] -> Put
$cputList :: forall k. Binary k => [WithPackageKey k] -> Put
get :: Get (WithPackageKey k)
$cget :: forall k. Binary k => Get (WithPackageKey k)
put :: WithPackageKey k -> Put
$cput :: forall k. Binary k => WithPackageKey k -> Put
Binary, WithPackageKey k -> ()
(WithPackageKey k -> ()) -> NFData (WithPackageKey k)
forall k. NFData k => WithPackageKey k -> ()
forall a. (a -> ()) -> NFData a
rnf :: WithPackageKey k -> ()
$crnf :: forall k. NFData k => WithPackageKey k -> ()
NFData)

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

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 FilePath Text)
_prextract :: Maybe (HashMap FilePath NixExpr),
    -- | cargo lock file path in build dir -> (file path in nix, git dependencies)
    PackageResult
-> Maybe (HashMap FilePath (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 -> FilePath
(Int -> PackageResult -> ShowS)
-> (PackageResult -> FilePath)
-> ([PackageResult] -> ShowS)
-> Show PackageResult
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [PackageResult] -> ShowS
$cshowList :: [PackageResult] -> ShowS
show :: PackageResult -> FilePath
$cshow :: PackageResult -> FilePath
showsPrec :: Int -> PackageResult -> ShowS
$cshowsPrec :: Int -> 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
$cto :: forall x. Rep PackageResult x -> PackageResult
$cfrom :: forall x. PackageResult -> Rep PackageResult x
Generic, PackageResult -> ()
(PackageResult -> ()) -> NFData PackageResult
forall a. (a -> ()) -> NFData a
rnf :: PackageResult -> ()
$crnf :: PackageResult -> ()
NFData)

instance A.ToJSON PackageResult where
  toJSON :: PackageResult -> Value
toJSON PackageResult {Maybe Text
Maybe (HashMap FilePath (Text, HashMap Text Checksum))
Maybe (HashMap FilePath Text)
Maybe (HashMap Text Text)
Text
UseStaleVersion
NixFetcher 'Fetched
NvcheckerResult
_prgitdate :: Maybe Text
_prpinned :: UseStaleVersion
_prcargolock :: Maybe (HashMap FilePath (Text, HashMap Text Checksum))
_prextract :: Maybe (HashMap FilePath Text)
_prpassthru :: Maybe (HashMap Text Text)
_prfetched :: NixFetcher 'Fetched
_prversion :: NvcheckerResult
_prname :: Text
_prgitdate :: PackageResult -> Maybe Text
_prpinned :: PackageResult -> UseStaleVersion
_prcargolock :: PackageResult
-> Maybe (HashMap FilePath (Text, HashMap Text Checksum))
_prextract :: PackageResult -> Maybe (HashMap FilePath Text)
_prpassthru :: PackageResult -> Maybe (HashMap Text Text)
_prfetched :: PackageResult -> NixFetcher 'Fetched
_prversion :: PackageResult -> NvcheckerResult
_prname :: PackageResult -> Text
..} =
    [Pair] -> Value
A.object
      [ Key
"name" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Text
_prname,
        Key
"version" Key -> Version -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= NvcheckerResult -> Version
nvNow NvcheckerResult
_prversion,
        Key
"src" Key -> NixFetcher 'Fetched -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= NixFetcher 'Fetched
_prfetched,
        Key
"extract" Key -> Maybe (HashMap FilePath Text) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Maybe (HashMap FilePath Text)
_prextract,
        Key
"passthru" Key -> Maybe (HashMap Text Text) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Maybe (HashMap Text Text)
_prpassthru,
        Key
"cargoLocks" Key
-> Maybe (HashMap FilePath (Text, HashMap Text Checksum)) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
A..= Maybe (HashMap FilePath (Text, HashMap Text Checksum))
_prcargolock,
        Key
"pinned" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
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
A..= Maybe Text
_prgitdate
      ]