Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 18 additions & 36 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
inputs.treefmt-nix.url = "github:numtide/treefmt-nix";
inputs.treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";

inputs.runtimeDeps.url = "github:NixOS/nixpkgs/nixos-unstable-small";

nixConfig.extra-substituters = "https://nix-community.cachix.org";
nixConfig.extra-trusted-public-keys = "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=";

outputs = { self, nixpkgs, mmdoc, treefmt-nix, runtimeDeps } @ args:
outputs = { self, nixpkgs, mmdoc, treefmt-nix } @ args:
let
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
eachSystem = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
Expand Down
7 changes: 2 additions & 5 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
{ nixpkgs
, mmdoc
, runtimeDeps
, system
, self
, ...
}:

let

runtimePkgs = import runtimeDeps { inherit system; };

pkgs = import nixpkgs { inherit system; config = { allowBroken = true; }; };

drvAttrs = attrs: with runtimePkgs; {
drvAttrs = attrs: with pkgs; {
NIX = nix;
GIT = git;
JQ = jq;
Expand All @@ -33,7 +30,7 @@ let
pkgs.haskell.lib.failOnAllWarnings (
pkgs.haskell.lib.disableExecutableProfiling (
pkgs.haskell.lib.disableLibraryProfiling (
pkgs.haskell.lib.generateOptparseApplicativeCompletion "nixpkgs-update" (
pkgs.haskellPackages.generateOptparseApplicativeCompletions [ "nixpkgs-update" ] (
(haskellPackages.callPackage ../nixpkgs-update.nix { }).overrideAttrs drvAttrs
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/CVE.hs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ instance Show CPE where
]
<> "}"
where
cpeField :: Show a => String -> Maybe a -> [String]
cpeField :: (Show a) => String -> Maybe a -> [String]
cpeField _ Nothing = []
cpeField name (Just value) = [name <> " = " <> show value]

Expand Down
2 changes: 1 addition & 1 deletion src/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ duGist resultPath =
return $ "- du listing: " <> g <> "\n"
)

result :: MonadIO m => UpdateEnv -> String -> m Text
result :: (MonadIO m) => UpdateEnv -> String -> m Text
result updateEnv resultPath =
liftIO $ do
let expectedVersion = newVersion updateEnv
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Hex.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Hex t where
hex :: t -> t

-- | Convert from hexadecimal and fail on invalid input.
unhex :: MonadFail m => t -> m t
unhex :: (MonadFail m) => t -> m t

instance Hex String where
hex = Prelude.concatMap w
Expand All @@ -42,7 +42,7 @@ instance Hex String where
liftM (toEnum ((x * 16) + y) :) $ unhex r
unhex [_] = fail "Non-even length"

c :: MonadFail m => Char -> m Int
c :: (MonadFail m) => Char -> m Int
c '0' = return 0
c '1' = return 1
c '2' = return 2
Expand Down
6 changes: 3 additions & 3 deletions src/File.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data File m a where
makeSem ''File

runIO ::
Member (Embed IO) r =>
(Member (Embed IO) r) =>
Sem (File ': r) a ->
Sem r a
runIO =
Expand All @@ -38,7 +38,7 @@ runPure contentList =
Write _file contents -> output contents

replace ::
Member File r =>
(Member File r) =>
Text ->
Text ->
FilePath ->
Expand All @@ -50,7 +50,7 @@ replace find replacement file = do
File.write file newContents
return $ contents /= newContents

replaceIO :: MonadIO m => Text -> Text -> FilePath -> m Bool
replaceIO :: (MonadIO m) => Text -> Text -> FilePath -> m Bool
replaceIO find replacement file =
liftIO $
runFinal $
Expand Down
18 changes: 9 additions & 9 deletions src/GH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ import qualified Utils as U

default (T.Text)

gReleaseUrl :: MonadIO m => GH.Auth -> URLParts -> ExceptT Text m Text
gReleaseUrl :: (MonadIO m) => GH.Auth -> URLParts -> ExceptT Text m Text
gReleaseUrl auth (URLParts o r t) =
ExceptT $
bimap (T.pack . show) (GH.getUrl . GH.releaseHtmlUrl)
<$> liftIO (GH.github auth (GH.releaseByTagNameR o r t))

releaseUrl :: MonadIO m => UpdateEnv -> Text -> ExceptT Text m Text
releaseUrl :: (MonadIO m) => UpdateEnv -> Text -> ExceptT Text m Text
releaseUrl env url = do
urlParts <- parseURL url
gReleaseUrl (authFrom env) urlParts

pr :: MonadIO m => UpdateEnv -> Text -> Text -> Text -> Text -> ExceptT Text m (Bool, Text)
pr :: (MonadIO m) => UpdateEnv -> Text -> Text -> Text -> Text -> ExceptT Text m (Bool, Text)
pr env title body prHead base = do
tryPR `catchE` \case
-- If creating the PR returns a 422, most likely cause is that the
Expand All @@ -74,9 +74,9 @@ pr env title body prHead base = do
)
)

prUpdate :: forall m. MonadIO m => UpdateEnv -> Text -> Text -> Text -> Text -> ExceptT Text m (Bool, Text)
prUpdate :: forall m. (MonadIO m) => UpdateEnv -> Text -> Text -> Text -> Text -> ExceptT Text m (Bool, Text)
prUpdate env title body prHead base = do
let runRequest :: FromJSON a => GH.Request k a -> ExceptT Text m a
let runRequest :: (FromJSON a) => GH.Request k a -> ExceptT Text m a
runRequest = ExceptT . fmap (first (T.pack . show)) . liftIO . GH.github (authFrom env)
let inNixpkgs f = f (N "nixos") (N "nixpkgs")

Expand Down Expand Up @@ -149,11 +149,11 @@ parseURLMaybe url =
)
in url =~ regex

parseURL :: MonadIO m => Text -> ExceptT Text m URLParts
parseURL :: (MonadIO m) => Text -> ExceptT Text m URLParts
parseURL url =
tryJust ("GitHub: " <> url <> " is not a GitHub URL.") (parseURLMaybe url)

compareUrl :: MonadIO m => Text -> Text -> ExceptT Text m Text
compareUrl :: (MonadIO m) => Text -> Text -> ExceptT Text m Text
compareUrl urlOld urlNew = do
oldParts <- parseURL urlOld
newParts <- parseURL urlNew
Expand Down Expand Up @@ -213,7 +213,7 @@ authFromToken = GH.OAuth . T.encodeUtf8
authFrom :: UpdateEnv -> GH.Auth
authFrom = authFromToken . U.githubToken . options

checkExistingUpdatePR :: MonadIO m => UpdateEnv -> Text -> ExceptT Text m ()
checkExistingUpdatePR :: (MonadIO m) => UpdateEnv -> Text -> ExceptT Text m ()
checkExistingUpdatePR env attrPath = do
searchResult <-
ExceptT $
Expand All @@ -239,7 +239,7 @@ checkExistingUpdatePR env attrPath = do
& T.unlines
report i = "- " <> GH.issueTitle i <> "\n " <> tshow (GH.issueUrl i)

latestVersion :: MonadIO m => UpdateEnv -> Text -> ExceptT Text m Version
latestVersion :: (MonadIO m) => UpdateEnv -> Text -> ExceptT Text m Version
latestVersion env url = do
urlParts <- parseURL url
r <-
Expand Down
26 changes: 13 additions & 13 deletions src/Git.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ deleteOrigin :: [Text] -> ProcessConfig () () ()
deleteOrigin branches =
silently $ procGit (["push", "origin", "--delete"] ++ fmap T.unpack branches)

cleanAndResetTo :: MonadIO m => Text -> ExceptT Text m ()
cleanAndResetTo :: (MonadIO m) => Text -> ExceptT Text m ()
cleanAndResetTo branch =
let target = "upstream/" <> branch
in do
Expand All @@ -90,19 +90,19 @@ cleanAndResetTo branch =
runProcessNoIndexIssue_ $ reset target
runProcessNoIndexIssue_ clean

show :: MonadIO m => Text -> Text -> ExceptT Text m Text
show :: (MonadIO m) => Text -> Text -> ExceptT Text m Text
show branch file =
readProcessInterleavedNoIndexIssue_ $ silently $ procGit ["show", T.unpack ("remotes/upstream/" <> branch <> ":" <> file)]

diff :: MonadIO m => Text -> ExceptT Text m Text
diff :: (MonadIO m) => Text -> ExceptT Text m Text
diff branch = readProcessInterleavedNoIndexIssue_ $ procGit ["diff", T.unpack branch]

diffFileNames :: MonadIO m => Text -> ExceptT Text m [Text]
diffFileNames :: (MonadIO m) => Text -> ExceptT Text m [Text]
diffFileNames branch =
readProcessInterleavedNoIndexIssue_ (procGit ["diff", T.unpack branch, "--name-only"])
& fmapRT T.lines

staleFetchHead :: MonadIO m => m Bool
staleFetchHead :: (MonadIO m) => m Bool
staleFetchHead =
liftIO $ do
nixpkgsGit <- getUserCacheDir "nixpkgs"
Expand All @@ -116,16 +116,16 @@ staleFetchHead =
fetchedLast <- getModificationTime fetchHead
return (fetchedLast < oneHourAgo)

fetchIfStale :: MonadIO m => ExceptT Text m ()
fetchIfStale :: (MonadIO m) => ExceptT Text m ()
fetchIfStale = whenM staleFetchHead fetch

fetch :: MonadIO m => ExceptT Text m ()
fetch :: (MonadIO m) => ExceptT Text m ()
fetch =
runProcessNoIndexIssue_ $
silently $
procGit ["fetch", "-q", "--prune", "--multiple", "upstream", "origin"]

push :: MonadIO m => UpdateEnv -> ExceptT Text m ()
push :: (MonadIO m) => UpdateEnv -> ExceptT Text m ()
push updateEnv =
runProcessNoIndexIssue_
( procGit
Expand Down Expand Up @@ -176,7 +176,7 @@ mergeBase = do

-- Return Nothing if a remote branch for this package doesn't exist. If a
-- branch does exist, return a Just of its last commit message.
findAutoUpdateBranchMessage :: MonadIO m => Text -> ExceptT Text m (Maybe Text)
findAutoUpdateBranchMessage :: (MonadIO m) => Text -> ExceptT Text m (Maybe Text)
findAutoUpdateBranchMessage pName = do
remoteBranches <-
readProcessInterleavedNoIndexIssue_ (procGit ["branch", "--remote", "--format=%(refname:short) %(subject)"])
Expand All @@ -190,11 +190,11 @@ inNixpkgsRepo = do
currentDir <- getCurrentDirectory
doesFileExist (currentDir <> "/nixos/release.nix")

commit :: MonadIO m => Text -> ExceptT Text m ()
commit :: (MonadIO m) => Text -> ExceptT Text m ()
commit ref =
runProcessNoIndexIssue_ (procGit ["commit", "-am", T.unpack ref])

headRev :: MonadIO m => ExceptT Text m Text
headRev :: (MonadIO m) => ExceptT Text m Text
headRev = T.strip <$> readProcessInterleavedNoIndexIssue_ (procGit ["rev-parse", "HEAD"])

deleteBranchesEverywhere :: Vector Text -> IO ()
Expand Down Expand Up @@ -227,7 +227,7 @@ runProcessNoIndexIssue_IO config = go
ExitFailure _ -> throw $ ExitCodeException code config out e

runProcessNoIndexIssue_ ::
MonadIO m => ProcessConfig () () () -> ExceptT Text m ()
(MonadIO m) => ProcessConfig () () () -> ExceptT Text m ()
runProcessNoIndexIssue_ config = tryIOTextET go
where
go = do
Expand All @@ -241,7 +241,7 @@ runProcessNoIndexIssue_ config = tryIOTextET go
ExitFailure _ -> throw $ ExitCodeException code config out e

readProcessInterleavedNoIndexIssue_ ::
MonadIO m => ProcessConfig () () () -> ExceptT Text m Text
(MonadIO m) => ProcessConfig () () () -> ExceptT Text m Text
readProcessInterleavedNoIndexIssue_ config = tryIOTextET go
where
go = do
Expand Down
6 changes: 3 additions & 3 deletions src/NVDRules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ filter _ cpeMatch "socat" v
filter _ cpeMatch "uzbl" v
| isNothing (v =~ yearRegex)
&& "2009.12.22"
`anyVersionInfixOf` cpeMatchVersionMatcher cpeMatch =
`anyVersionInfixOf` cpeMatchVersionMatcher cpeMatch =
False
| isNothing (v =~ yearRegex)
&& "2010.04.03"
`anyVersionInfixOf` cpeMatchVersionMatcher cpeMatch =
`anyVersionInfixOf` cpeMatchVersionMatcher cpeMatch =
False
filter _ cpeMatch "go" v
| "."
`T.isInfixOf` v
&& "-"
`anyVersionInfixOf` cpeMatchVersionMatcher cpeMatch =
`anyVersionInfixOf` cpeMatchVersionMatcher cpeMatch =
False
filter _ cpeMatch "terraform" _
| cpeTargetSoftware (cpeMatchCPE cpeMatch) == Just "aws" = False
Expand Down
Loading