mirror of
https://github.com/nix-community/nixpkgs-update.git
synced 2024-11-25 09:34:13 +03:00
introduce OurPrelude to reduce importing boilerplate
This commit is contained in:
parent
77129e4da9
commit
2ebd9c33db
@ -10,9 +10,9 @@ module Blacklist
|
||||
, checkResult
|
||||
) where
|
||||
|
||||
import Control.Monad.Except
|
||||
import OurPrelude
|
||||
|
||||
import Data.Foldable (find)
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
|
||||
type Blacklist = [(Text -> Bool, Text)]
|
||||
|
@ -6,13 +6,11 @@ module Check
|
||||
( result
|
||||
) where
|
||||
|
||||
import OurPrelude
|
||||
|
||||
import Control.Applicative (many)
|
||||
import Control.Monad (forM)
|
||||
import Data.Char (isSpace)
|
||||
import Data.Maybe (isJust)
|
||||
import Data.Semigroup ((<>))
|
||||
import qualified Data.Text as T
|
||||
import Data.Text (Text)
|
||||
import Prelude hiding (FilePath)
|
||||
import qualified Shell
|
||||
import Shelly
|
||||
|
11
src/Clean.hs
11
src/Clean.hs
@ -6,15 +6,10 @@ module Clean
|
||||
( fixSrcUrl
|
||||
) where
|
||||
|
||||
import Control.Applicative ((<|>), some)
|
||||
import Control.Error
|
||||
import Control.Monad (forM_)
|
||||
import Control.Monad.Trans
|
||||
import Data.Function ((&))
|
||||
import Data.Maybe (isNothing)
|
||||
import Data.Semigroup ((<>))
|
||||
import OurPrelude
|
||||
|
||||
import Control.Applicative (some)
|
||||
import qualified Data.Text as T
|
||||
import Data.Text (Text)
|
||||
import qualified File
|
||||
import Prelude hiding (FilePath)
|
||||
import qualified Shell
|
||||
|
@ -6,10 +6,8 @@ module DeleteMerged
|
||||
( deleteDone
|
||||
) where
|
||||
|
||||
import Control.Monad (forM_)
|
||||
import Data.Function ((&))
|
||||
import Data.Maybe (mapMaybe)
|
||||
import Data.Semigroup ((<>))
|
||||
import OurPrelude
|
||||
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.IO as T
|
||||
import qualified Data.Vector as V
|
||||
|
@ -2,7 +2,8 @@ module File
|
||||
( replace
|
||||
) where
|
||||
|
||||
import Data.Text (Text)
|
||||
import OurPrelude
|
||||
|
||||
import qualified Data.Text as T
|
||||
import Data.Text.IO as T
|
||||
import qualified Shelly
|
||||
|
10
src/GH.hs
10
src/GH.hs
@ -12,17 +12,11 @@ module GH
|
||||
, openAutoUpdatePR
|
||||
) where
|
||||
|
||||
import Control.Category ((>>>))
|
||||
import Control.Error
|
||||
import Data.Bifunctor (bimap, first, second)
|
||||
import Data.Function ((&))
|
||||
import Data.Maybe (fromJust)
|
||||
import Data.Semigroup ((<>))
|
||||
import OurPrelude
|
||||
|
||||
import qualified Data.Text as T
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Data.Vector as V
|
||||
import Data.Vector (Vector)
|
||||
import GitHub
|
||||
import GitHub.Data.Name (Name(..), untagName)
|
||||
import GitHub.Endpoints.GitData.References (references')
|
||||
|
@ -17,12 +17,9 @@ module Git
|
||||
, showRef
|
||||
) where
|
||||
|
||||
import Control.Error
|
||||
import Control.Monad.IO.Class
|
||||
import Control.Monad.Trans.Class
|
||||
import Data.Semigroup ((<>))
|
||||
import OurPrelude
|
||||
|
||||
import qualified Data.Text as T
|
||||
import Data.Text (Text)
|
||||
import Data.Time.Clock (UTCTime, addUTCTime, diffUTCTime, getCurrentTime)
|
||||
import qualified Shell
|
||||
import Shelly
|
||||
|
10
src/Main.hs
10
src/Main.hs
@ -2,12 +2,12 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# OPTIONS_GHC -fno-warn-type-defaults #-}
|
||||
|
||||
import Control.Applicative ((<**>), (<|>))
|
||||
import Control.Exception
|
||||
import Data.Maybe (isJust)
|
||||
import Data.Semigroup ((<>))
|
||||
module Main where
|
||||
|
||||
import OurPrelude
|
||||
|
||||
import Control.Applicative ((<**>))
|
||||
import qualified Data.Text as T
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text.IO as T
|
||||
import DeleteMerged (deleteDone)
|
||||
import qualified Options.Applicative as Opt
|
||||
|
10
src/Nix.hs
10
src/Nix.hs
@ -23,15 +23,9 @@ module Nix
|
||||
, sha256Zero
|
||||
) where
|
||||
|
||||
import Control.Applicative ((<|>))
|
||||
import Control.Category ((>>>))
|
||||
import Control.Error
|
||||
import OurPrelude
|
||||
|
||||
import Control.Monad (void)
|
||||
import Control.Monad.IO.Class
|
||||
import Data.Bifunctor (second)
|
||||
import Data.Function ((&))
|
||||
import Data.Semigroup ((<>))
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Prelude hiding (FilePath)
|
||||
import qualified Shell
|
||||
|
31
src/OurPrelude.hs
Normal file
31
src/OurPrelude.hs
Normal file
@ -0,0 +1,31 @@
|
||||
module OurPrelude
|
||||
( (>>>)
|
||||
, (<|>)
|
||||
, (<>)
|
||||
, (&)
|
||||
, module Control.Error
|
||||
, module Control.Monad.Except
|
||||
, module Control.Monad.Trans.Class
|
||||
, module Control.Monad.IO.Class
|
||||
, module Data.Bifunctor
|
||||
, Set
|
||||
, Text
|
||||
, Vector
|
||||
, interpolate
|
||||
) where
|
||||
|
||||
import Control.Applicative ((<|>))
|
||||
import Control.Category ((>>>))
|
||||
import Control.Error
|
||||
import Control.Monad.Except
|
||||
import Control.Monad.IO.Class
|
||||
import Control.Monad.Trans.Class
|
||||
import Data.Bifunctor
|
||||
import Data.Function ((&))
|
||||
import Data.Semigroup ((<>))
|
||||
import Data.Set (Set)
|
||||
import Data.Text (Text)
|
||||
import Data.Vector (Vector)
|
||||
import qualified NeatInterpolation
|
||||
|
||||
interpolate = NeatInterpolation.text
|
@ -6,18 +6,12 @@
|
||||
|
||||
module Outpaths where
|
||||
|
||||
import Control.Category ((>>>))
|
||||
import Data.Bifunctor (first)
|
||||
import Data.Function ((&))
|
||||
import OurPrelude
|
||||
|
||||
import Data.List (sort)
|
||||
import Data.Semigroup ((<>))
|
||||
import Data.Set (Set)
|
||||
import qualified Data.Set as S
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Data.Vector (Vector)
|
||||
import qualified Data.Vector as V
|
||||
import qualified NeatInterpolation (text)
|
||||
import Shelly
|
||||
import Text.Parsec (parse)
|
||||
import Text.Parser.Char
|
||||
@ -27,7 +21,7 @@ import Utils
|
||||
default (Text)
|
||||
|
||||
outPathsExpr =
|
||||
[NeatInterpolation.text|
|
||||
[interpolate|
|
||||
|
||||
(let
|
||||
lib = import ./lib;
|
||||
@ -81,7 +75,6 @@ in
|
||||
tweak (builtins.removeAttrs hydraJobs blacklist))
|
||||
|]
|
||||
|
||||
--downloadOutPath :: Sh ()
|
||||
outPath :: Sh Text
|
||||
outPath =
|
||||
sub $ do
|
||||
@ -135,17 +128,17 @@ parseAttrpath :: CharParsing m => m Text
|
||||
parseAttrpath = T.concat <$> many (try parseAttrpathPart)
|
||||
|
||||
parseAttrpathPart :: CharParsing m => m Text
|
||||
parseAttrpathPart = T.append <$> (T.pack <$> many (noneOf ". ")) <*> text "."
|
||||
parseAttrpathPart = T.snoc <$> (T.pack <$> many (noneOf ". ")) <*> char '.'
|
||||
|
||||
parseArchitecture :: CharParsing m => m Text
|
||||
parseArchitecture = T.pack <$> many (noneOf " ")
|
||||
|
||||
parseOutpaths :: CharParsing m => m (Vector Outpath)
|
||||
parseOutpaths = V.fromList <$> (parseOutpath `sepBy1` text ";")
|
||||
parseOutpaths = V.fromList <$> (parseOutpath `sepBy1` char ';')
|
||||
|
||||
parseOutpath :: CharParsing m => m Outpath
|
||||
parseOutpath =
|
||||
Outpath <$> optional (try (T.pack <$> (many (noneOf "=\n") <* text "="))) <*>
|
||||
Outpath <$> optional (try (T.pack <$> (many (noneOf "=\n") <* char '='))) <*>
|
||||
(T.pack <$> many (noneOf ";\n"))
|
||||
|
||||
packageRebuilds :: Set ResultLine -> Vector Text
|
||||
@ -180,7 +173,7 @@ outpathReport diff =
|
||||
linux32b = tshow $ linux32bRebuilds diff
|
||||
arm = tshow $ armRebuilds diff
|
||||
numPaths = tshow $ S.size diff
|
||||
in [NeatInterpolation.text|
|
||||
in [interpolate|
|
||||
$numPaths total rebuild path(s)
|
||||
|
||||
$pkg package rebuild(s)
|
||||
|
@ -10,10 +10,8 @@ module Shell
|
||||
, ourSilentShell
|
||||
) where
|
||||
|
||||
import Control.Category ((>>>))
|
||||
import Control.Error
|
||||
import Control.Monad.IO.Class
|
||||
import Data.Text (Text)
|
||||
import OurPrelude
|
||||
|
||||
import qualified Data.Text as T
|
||||
import Shelly.Lifted
|
||||
import Utils
|
||||
|
@ -9,23 +9,15 @@ module Update
|
||||
( updateAll
|
||||
) where
|
||||
|
||||
import OurPrelude
|
||||
|
||||
import qualified Blacklist
|
||||
import qualified Check
|
||||
import Clean (fixSrcUrl)
|
||||
import Control.Applicative ((<|>))
|
||||
import Control.Error
|
||||
import Control.Exception (SomeException, throw, toException)
|
||||
import Control.Exception (SomeException)
|
||||
import Control.Exception.Lifted
|
||||
import Control.Monad (forM_, mplus)
|
||||
import Control.Monad.Except
|
||||
import Control.Monad.Trans.Class
|
||||
import Data.Function ((&))
|
||||
import Data.IORef
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Data.Semigroup ((<>))
|
||||
import Data.Set (Set)
|
||||
import qualified Data.Set as S
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.IO as T
|
||||
import Data.Time.Clock (UTCTime, addUTCTime, diffUTCTime, getCurrentTime)
|
||||
@ -33,7 +25,6 @@ import Data.Time.Format (defaultTimeLocale, formatTime, iso8601DateFormat)
|
||||
import qualified File
|
||||
import qualified GH
|
||||
import qualified Git
|
||||
import NeatInterpolation (text)
|
||||
import qualified Nix
|
||||
import Outpaths
|
||||
import Prelude hiding (FilePath)
|
||||
@ -261,7 +252,8 @@ publishPackage log updateEnv oldSrcUrl newSrcUrl attrPath result opDiff = do
|
||||
liftIO Git.cleanAndResetToMaster
|
||||
|
||||
repologyUrl :: UpdateEnv -> Text
|
||||
repologyUrl updateEnv = [text|https://repology.org/metapackage/$pname/versions|]
|
||||
repologyUrl updateEnv =
|
||||
[interpolate|https://repology.org/metapackage/$pname/versions|]
|
||||
where
|
||||
pname = updateEnv & packageName & T.toLower
|
||||
|
||||
@ -270,7 +262,7 @@ commitMessage updateEnv attrPath =
|
||||
let oV = oldVersion updateEnv
|
||||
nV = newVersion updateEnv
|
||||
repologyLink = repologyUrl updateEnv
|
||||
in [text|
|
||||
in [interpolate|
|
||||
$attrPath: $oV -> $nV
|
||||
|
||||
Semi-automatic update generated by
|
||||
@ -303,7 +295,7 @@ prMessage updateEnv isBroken metaDescription releaseUrlMessage compareUrlMessage
|
||||
nV = newVersion updateEnv
|
||||
repologyLink = repologyUrl updateEnv
|
||||
result = toTextIgnore resultPath
|
||||
in [text|
|
||||
in [interpolate|
|
||||
$attrPath: $oV -> $nV
|
||||
|
||||
Semi-automatic update generated by https://github.com/ryantm/nixpkgs-update tools. This update was made based on information from $repologyLink.
|
||||
|
@ -14,13 +14,8 @@ module Utils
|
||||
, branchName
|
||||
) where
|
||||
|
||||
import Control.Category ((>>>))
|
||||
import Control.Error
|
||||
import Control.Exception (Exception)
|
||||
import Control.Monad.IO.Class
|
||||
import Data.Bifunctor (first)
|
||||
import Data.Semigroup ((<>))
|
||||
import Data.Text (Text)
|
||||
import OurPrelude
|
||||
|
||||
import qualified Data.Text as T
|
||||
import Prelude hiding (FilePath)
|
||||
import Shelly.Lifted
|
||||
|
@ -4,8 +4,8 @@ module Version
|
||||
( assertCompatibleWithPathPin
|
||||
) where
|
||||
|
||||
import Control.Error
|
||||
import Data.Text (Text)
|
||||
import OurPrelude
|
||||
|
||||
import qualified Data.Text as T
|
||||
import Utils
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user