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

-- | Copyright: (c) 2021 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 (..),
    NvcheckerA (..),
    NvcheckerQ (..),
    NvcheckerOptions (..),
    UseStaleVersion (..),

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

    -- * ExtractSrc Types
    ExtractSrcQ (..),

    -- * FetchRustGitDeps types
    FetchRustGitDepsQ (..),

    -- * Core types
    Core (..),

    -- * Package types
    PackageName,
    PackageFetcher,
    PackageExtractSrc (..),
    PackageCargoFilePath (..),
    PackagePassthru (..),
    Package (..),
    PackageKey (..),
  )
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)
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)

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

-- | 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 -> String
(Int -> Version -> ShowS)
-> (Version -> String) -> ([Version] -> ShowS) -> Show Version
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Version] -> ShowS
$cshowList :: [Version] -> ShowS
show :: Version -> String
$cshow :: Version -> String
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
$cp1Ord :: Eq Version
Ord, String -> Version
(String -> Version) -> IsString Version
forall a. (String -> a) -> IsString a
fromString :: String -> Version
$cfromString :: String -> Version
IsString, b -> Version -> Version
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 :: 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
$cp1Monoid :: Semigroup 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)
  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 -> String
(Int -> Checksum -> ShowS)
-> (Checksum -> String) -> ([Checksum] -> ShowS) -> Show Checksum
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Checksum] -> ShowS
$cshowList :: [Checksum] -> ShowS
show :: Checksum -> String
$cshow :: Checksum -> String
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
$cp1Ord :: Eq Checksum
Ord)
  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 -> String
(Int -> Branch -> ShowS)
-> (Branch -> String) -> ([Branch] -> ShowS) -> Show Branch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Branch] -> ShowS
$cshowList :: [Branch] -> ShowS
show :: Branch -> String
$cshow :: Branch -> String
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
$cp1Ord :: Eq Branch
Ord, Branch
Branch -> Default Branch
forall a. a -> Default a
def :: Branch
$cdef :: Branch
Default)
  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 -> PackageName
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 -> String
show VersionChange {Maybe Version
PackageName
Version
vcNew :: Version
vcOld :: Maybe Version
vcName :: PackageName
vcNew :: VersionChange -> Version
vcOld :: VersionChange -> Maybe Version
vcName :: VersionChange -> PackageName
..} =
    PackageName -> String
T.unpack (PackageName -> String) -> PackageName -> String
forall a b. (a -> b) -> a -> b
$ PackageName
vcName PackageName -> PackageName -> PackageName
forall a. Semigroup a => a -> a -> a
<> PackageName
": " PackageName -> PackageName -> PackageName
forall a. Semigroup a => a -> a -> a
<> PackageName -> Maybe PackageName -> PackageName
forall a. a -> Maybe a -> a
fromMaybe PackageName
"∅" (Maybe Version -> Maybe PackageName
coerce Maybe Version
vcOld) PackageName -> PackageName -> PackageName
forall a. Semigroup a => a -> a -> a
<> PackageName
" → " PackageName -> PackageName -> PackageName
forall a. Semigroup a => a -> a -> a
<> Version -> PackageName
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
$cp1Ord :: Eq VersionSortMethod
Ord, Int -> VersionSortMethod
VersionSortMethod -> Int
VersionSortMethod -> [VersionSortMethod]
VersionSortMethod -> VersionSortMethod
VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
VersionSortMethod
-> VersionSortMethod -> VersionSortMethod -> [VersionSortMethod]
(VersionSortMethod -> VersionSortMethod)
-> (VersionSortMethod -> VersionSortMethod)
-> (Int -> VersionSortMethod)
-> (VersionSortMethod -> Int)
-> (VersionSortMethod -> [VersionSortMethod])
-> (VersionSortMethod -> VersionSortMethod -> [VersionSortMethod])
-> (VersionSortMethod -> VersionSortMethod -> [VersionSortMethod])
-> (VersionSortMethod
    -> VersionSortMethod -> VersionSortMethod -> [VersionSortMethod])
-> Enum VersionSortMethod
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
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 -> String
show = \case
    VersionSortMethod
ParseVersion -> String
"parse_version"
    VersionSortMethod
Vercmp -> String
"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 PackageName
_includeRegex :: Maybe Text,
    ListOptions -> Maybe PackageName
_excludeRegex :: Maybe Text,
    ListOptions -> Maybe VersionSortMethod
_sortVersionKey :: Maybe VersionSortMethod,
    ListOptions -> Maybe PackageName
_ignored :: Maybe Text
  }
  deriving (Int -> ListOptions -> ShowS
[ListOptions] -> ShowS
ListOptions -> String
(Int -> ListOptions -> ShowS)
-> (ListOptions -> String)
-> ([ListOptions] -> ShowS)
-> Show ListOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListOptions] -> ShowS
$cshowList :: [ListOptions] -> ShowS
show :: ListOptions -> String
$cshow :: ListOptions -> String
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
$cp1Ord :: Eq ListOptions
Ord, (forall x. ListOptions -> Rep ListOptions x)
-> (forall x. Rep ListOptions x -> ListOptions)
-> Generic ListOptions
forall x. Rep ListOptions x -> ListOptions
forall x. ListOptions -> Rep ListOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$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)

-- | Configuration available for evey version sourece.
-- See <https://nvchecker.readthedocs.io/en/latest/usage.html#global-options> for details.
data NvcheckerOptions = NvcheckerOptions
  { NvcheckerOptions -> Maybe PackageName
_stripPrefix :: Maybe Text,
    NvcheckerOptions -> Maybe PackageName
_fromPattern :: Maybe Text,
    NvcheckerOptions -> Maybe PackageName
_toPattern :: Maybe Text
  }
  deriving (Int -> NvcheckerOptions -> ShowS
[NvcheckerOptions] -> ShowS
NvcheckerOptions -> String
(Int -> NvcheckerOptions -> ShowS)
-> (NvcheckerOptions -> String)
-> ([NvcheckerOptions] -> ShowS)
-> Show NvcheckerOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NvcheckerOptions] -> ShowS
$cshowList :: [NvcheckerOptions] -> ShowS
show :: NvcheckerOptions -> String
$cshow :: NvcheckerOptions -> String
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
$cp1Ord :: Eq NvcheckerOptions
Ord, (forall x. NvcheckerOptions -> Rep NvcheckerOptions x)
-> (forall x. Rep NvcheckerOptions x -> NvcheckerOptions)
-> Generic NvcheckerOptions
forall x. Rep NvcheckerOptions x -> NvcheckerOptions
forall x. NvcheckerOptions -> Rep NvcheckerOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$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)

-- | Upstream version source for nvchecker to check
data VersionSource
  = GitHubRelease {VersionSource -> PackageName
_owner :: Text, VersionSource -> PackageName
_repo :: Text}
  | GitHubTag {_owner :: Text, _repo :: Text, VersionSource -> ListOptions
_listOptions :: ListOptions}
  | Git {VersionSource -> PackageName
_vurl :: Text, VersionSource -> Branch
_vbranch :: Branch}
  | Pypi {VersionSource -> PackageName
_pypi :: Text}
  | ArchLinux {VersionSource -> PackageName
_archpkg :: Text}
  | Aur {VersionSource -> PackageName
_aur :: Text}
  | Manual {VersionSource -> PackageName
_manual :: Text}
  | Repology {VersionSource -> PackageName
_repology :: Text, _repo :: Text}
  | Webpage {_vurl :: Text, VersionSource -> PackageName
_regex :: Text, _listOptions :: ListOptions}
  | HttpHeader {_vurl :: Text, _regex :: Text, _listOptions :: ListOptions}
  | OpenVsx {VersionSource -> PackageName
_ovPublisher :: Text, VersionSource -> PackageName
_ovExtName :: Text}
  | VscodeMarketplace {VersionSource -> PackageName
_vsmPublisher :: Text, VersionSource -> PackageName
_vsmExtName :: Text}
  | Cmd {VersionSource -> PackageName
_vcmd :: Text}
  deriving (Int -> VersionSource -> ShowS
[VersionSource] -> ShowS
VersionSource -> String
(Int -> VersionSource -> ShowS)
-> (VersionSource -> String)
-> ([VersionSource] -> ShowS)
-> Show VersionSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VersionSource] -> ShowS
$cshowList :: [VersionSource] -> ShowS
show :: VersionSource -> String
$cshow :: VersionSource -> String
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
$cp1Ord :: Eq VersionSource
Ord, (forall x. VersionSource -> Rep VersionSource x)
-> (forall x. Rep VersionSource x -> VersionSource)
-> Generic VersionSource
forall x. Rep VersionSource x -> VersionSource
forall x. VersionSource -> Rep VersionSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$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)

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

-- | The result of running nvchecker
data NvcheckerA = NvcheckerA
  { NvcheckerA -> Version
nvNow :: Version,
    -- | nvchecker doesn't give this value, but shake restores it from last run
    NvcheckerA -> Maybe Version
nvOld :: Maybe Version,
    -- | stale means even 'nvNow' comes from shake, where we actually didn't run nvchecker
    NvcheckerA -> Bool
nvStale :: Bool
  }
  deriving (Int -> NvcheckerA -> ShowS
[NvcheckerA] -> ShowS
NvcheckerA -> String
(Int -> NvcheckerA -> ShowS)
-> (NvcheckerA -> String)
-> ([NvcheckerA] -> ShowS)
-> Show NvcheckerA
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NvcheckerA] -> ShowS
$cshowList :: [NvcheckerA] -> ShowS
show :: NvcheckerA -> String
$cshow :: NvcheckerA -> String
showsPrec :: Int -> NvcheckerA -> ShowS
$cshowsPrec :: Int -> NvcheckerA -> ShowS
Show, Typeable, NvcheckerA -> NvcheckerA -> Bool
(NvcheckerA -> NvcheckerA -> Bool)
-> (NvcheckerA -> NvcheckerA -> Bool) -> Eq NvcheckerA
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NvcheckerA -> NvcheckerA -> Bool
$c/= :: NvcheckerA -> NvcheckerA -> Bool
== :: NvcheckerA -> NvcheckerA -> Bool
$c== :: NvcheckerA -> NvcheckerA -> Bool
Eq, (forall x. NvcheckerA -> Rep NvcheckerA x)
-> (forall x. Rep NvcheckerA x -> NvcheckerA) -> Generic NvcheckerA
forall x. Rep NvcheckerA x -> NvcheckerA
forall x. NvcheckerA -> Rep NvcheckerA x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NvcheckerA x -> NvcheckerA
$cfrom :: forall x. NvcheckerA -> Rep NvcheckerA x
Generic, Int -> NvcheckerA -> Int
NvcheckerA -> Int
(Int -> NvcheckerA -> Int)
-> (NvcheckerA -> Int) -> Hashable NvcheckerA
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: NvcheckerA -> Int
$chash :: NvcheckerA -> Int
hashWithSalt :: Int -> NvcheckerA -> Int
$chashWithSalt :: Int -> NvcheckerA -> Int
Hashable, Get NvcheckerA
[NvcheckerA] -> Put
NvcheckerA -> Put
(NvcheckerA -> Put)
-> Get NvcheckerA -> ([NvcheckerA] -> Put) -> Binary NvcheckerA
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
putList :: [NvcheckerA] -> Put
$cputList :: [NvcheckerA] -> Put
get :: Get NvcheckerA
$cget :: Get NvcheckerA
put :: NvcheckerA -> Put
$cput :: NvcheckerA -> Put
Binary, NvcheckerA -> ()
(NvcheckerA -> ()) -> NFData NvcheckerA
forall a. (a -> ()) -> NFData a
rnf :: NvcheckerA -> ()
$crnf :: NvcheckerA -> ()
NFData)

instance A.FromJSON NvcheckerA where
  parseJSON :: Value -> Parser NvcheckerA
parseJSON = String
-> (Object -> Parser NvcheckerA) -> Value -> Parser NvcheckerA
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"NvcheckerResult" ((Object -> Parser NvcheckerA) -> Value -> Parser NvcheckerA)
-> (Object -> Parser NvcheckerA) -> Value -> Parser NvcheckerA
forall a b. (a -> b) -> a -> b
$ \Object
o ->
    Version -> Maybe Version -> Bool -> NvcheckerA
NvcheckerA (Version -> Maybe Version -> Bool -> NvcheckerA)
-> Parser Version -> Parser (Maybe Version -> Bool -> NvcheckerA)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> PackageName -> Parser Version
forall a. FromJSON a => Object -> PackageName -> Parser a
A..: PackageName
"version" Parser (Maybe Version -> Bool -> NvcheckerA)
-> Parser (Maybe Version) -> Parser (Bool -> NvcheckerA)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Version -> Parser (Maybe Version)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Version
forall a. Maybe a
Nothing Parser (Bool -> NvcheckerA) -> Parser Bool -> Parser NvcheckerA
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> Parser Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
False

type instance RuleResult NvcheckerQ = NvcheckerA

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

-- | If the package is prefetched, then we can obtain the SHA256
data NixFetcher (k :: FetchStatus)
  = FetchGit
      { NixFetcher k -> PackageName
_furl :: Text,
        NixFetcher k -> Version
_rev :: Version,
        NixFetcher k -> Bool
_deepClone :: Bool,
        NixFetcher k -> Bool
_fetchSubmodules :: Bool,
        NixFetcher k -> Bool
_leaveDotGit :: Bool,
        NixFetcher k -> FetchResult k
_sha256 :: FetchResult k
      }
  | FetchGitHub
      { NixFetcher k -> PackageName
_fowner :: Text,
        NixFetcher k -> PackageName
_frepo :: Text,
        _rev :: Version,
        _deepClone :: Bool,
        _fetchSubmodules :: Bool,
        _leaveDotGit :: Bool,
        _sha256 :: FetchResult k
      }
  | FetchUrl {_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)

-- | Fetch status
data FetchStatus = Fresh | Fetched

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

type instance RuleResult (NixFetcher Fresh) = NixFetcher Fetched

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)

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

-- | 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 -> String
(Int -> ExtractSrcQ -> ShowS)
-> (ExtractSrcQ -> String)
-> ([ExtractSrcQ] -> ShowS)
-> Show ExtractSrcQ
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExtractSrcQ] -> ShowS
$cshowList :: [ExtractSrcQ] -> ShowS
show :: ExtractSrcQ -> String
$cshow :: ExtractSrcQ -> String
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
$cp1Ord :: Eq ExtractSrcQ
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

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

-- | 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 -> String
(Int -> FetchRustGitDepsQ -> ShowS)
-> (FetchRustGitDepsQ -> String)
-> ([FetchRustGitDepsQ] -> ShowS)
-> Show FetchRustGitDepsQ
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FetchRustGitDepsQ] -> ShowS
$cshowList :: [FetchRustGitDepsQ] -> ShowS
show :: FetchRustGitDepsQ -> String
$cshow :: FetchRustGitDepsQ -> String
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
$cp1Ord :: Eq FetchRustGitDepsQ
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

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

-- | 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 PackageCargoFilePath = PackageCargoFilePath FilePath

newtype PackagePassthru = PackagePassthru (HashMap Text Text)
  deriving newtype (b -> PackagePassthru -> PackagePassthru
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 :: 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
$cp1Monoid :: Semigroup PackagePassthru
Monoid)

-- | This bool value means whether or not to use stale value.
-- Using stale value indicates that we will /NOT/ check for new versions if
-- there is a known version in shake. Normally you don't want a stale version
-- unless you need pin a package.
newtype UseStaleVersion = UseStaleVersion Bool
  deriving newtype (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 -> String
(Int -> UseStaleVersion -> ShowS)
-> (UseStaleVersion -> String)
-> ([UseStaleVersion] -> ShowS)
-> Show UseStaleVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UseStaleVersion] -> ShowS
$cshowList :: [UseStaleVersion] -> ShowS
show :: UseStaleVersion -> String
$cshow :: UseStaleVersion -> String
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
$cp1Ord :: Eq UseStaleVersion
Ord)
  deriving stock (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 shake 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
--
-- /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 -> PackageName
_pname :: PackageName,
    Package -> NvcheckerQ
_pversion :: NvcheckerQ,
    Package -> PackageFetcher
_pfetcher :: PackageFetcher,
    Package -> Maybe PackageExtractSrc
_pextract :: Maybe PackageExtractSrc,
    Package -> Maybe PackageCargoFilePath
_pcargo :: Maybe PackageCargoFilePath,
    Package -> PackagePassthru
_ppassthru :: PackagePassthru,
    Package -> UseStaleVersion
_ppinned :: UseStaleVersion
  }

-- | 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 -> String
(Int -> PackageKey -> ShowS)
-> (PackageKey -> String)
-> ([PackageKey] -> ShowS)
-> Show PackageKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PackageKey] -> ShowS
$cshowList :: [PackageKey] -> ShowS
show :: PackageKey -> String
$cshow :: PackageKey -> String
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
$cp1Ord :: Eq PackageKey
Ord)
  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 -> String
(Int -> Core -> ShowS)
-> (Core -> String) -> ([Core] -> ShowS) -> Show Core
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Core] -> ShowS
$cshowList :: [Core] -> ShowS
show :: Core -> String
$cshow :: Core -> String
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
$cp1Ord :: Eq Core
Ord, Typeable, (forall x. Core -> Rep Core x)
-> (forall x. Rep Core x -> Core) -> Generic Core
forall x. Rep Core x -> Core
forall x. Core -> Rep Core x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$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 = NixExpr

-- | 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 -> String
show (WithPackageKey (k
k, PackageKey
n)) = k -> String
forall a. Show a => a -> String
show k
k String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" (" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> PackageKey -> String
forall a. Show a => a -> String
show PackageKey
n String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
")"

type instance RuleResult (WithPackageKey k) = RuleResult k