Compare commits
2 Commits
94f4593fdc
...
21013d7e40
Author | SHA1 | Date | |
---|---|---|---|
21013d7e40 | |||
9002d3424c |
33
flake.lock
33
flake.lock
@ -1,32 +1,12 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"easy-hls": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1637250802,
|
|
||||||
"narHash": "sha256-/crlHEVB148PGQLZCsHOR9L5qgvCAfRSocIoKgmMAhA=",
|
|
||||||
"owner": "jkachmar",
|
|
||||||
"repo": "easy-hls-nix",
|
|
||||||
"rev": "7c123399ef8a67dc0e505d9cf7f2c7f64f1cd847",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "jkachmar",
|
|
||||||
"repo": "easy-hls-nix",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1644229661,
|
"lastModified": 1649676176,
|
||||||
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
"narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
|
"rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -37,11 +17,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1644453163,
|
"lastModified": 1650440614,
|
||||||
"narHash": "sha256-VPlXtIsShceYHUspnJSvuvucrX1OWVFmrqiofn69yCM=",
|
"narHash": "sha256-7mF7gyS5P3UmZmQuo9jbikP2wMyRUnimI7HcKLJ9OZQ=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "7e003d7fb9eff8ecb84405360c75c716cdd1f79f",
|
"rev": "0bbb65673c0ba31047c9ba6c4cd211556b534a4e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -51,7 +31,6 @@
|
|||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"easy-hls": "easy-hls",
|
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
|
10
flake.nix
10
flake.nix
@ -2,17 +2,13 @@
|
|||||||
description = "A very basic flake";
|
description = "A very basic flake";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
easy-hls = {
|
|
||||||
url = "github:jkachmar/easy-hls-nix";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
flake-utils = {
|
flake-utils = {
|
||||||
url = "github:numtide/flake-utils";
|
url = "github:numtide/flake-utils";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils, easy-hls }:
|
outputs = { self, nixpkgs, flake-utils }:
|
||||||
{
|
{
|
||||||
overlay = final: prev: {
|
overlay = final: prev: {
|
||||||
haskellPackages = prev.haskellPackages.override ( old: {
|
haskellPackages = prev.haskellPackages.override ( old: {
|
||||||
@ -27,7 +23,6 @@
|
|||||||
let
|
let
|
||||||
pkgs = import nixpkgs { inherit system; overlays = [ self.overlay ]; };
|
pkgs = import nixpkgs { inherit system; overlays = [ self.overlay ]; };
|
||||||
hp = pkgs.haskellPackages;
|
hp = pkgs.haskellPackages;
|
||||||
hls = (easy-hls.withGhcs [ hp.ghc.version ] ).${system};
|
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
@ -48,7 +43,6 @@
|
|||||||
hp.hlint
|
hp.hlint
|
||||||
stylish-haskell
|
stylish-haskell
|
||||||
ghcid
|
ghcid
|
||||||
hls
|
|
||||||
rrdtool
|
rrdtool
|
||||||
jq
|
jq
|
||||||
sqlite-interactive
|
sqlite-interactive
|
||||||
@ -58,6 +52,8 @@
|
|||||||
hp.graphmod
|
hp.graphmod
|
||||||
|
|
||||||
hp.dhall-nixpkgs
|
hp.dhall-nixpkgs
|
||||||
|
|
||||||
|
hp.haskell-language-server
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ library
|
|||||||
|
|
||||||
-- LANGUAGE extensions used by modules in this package.
|
-- LANGUAGE extensions used by modules in this package.
|
||||||
-- other-extensions:
|
-- other-extensions:
|
||||||
build-depends: base ^>=4.14.1.0
|
build-depends: base ^>=4.15.1.0
|
||||||
, amqp
|
, amqp
|
||||||
, aeson
|
, aeson
|
||||||
, lens
|
, lens
|
||||||
@ -65,7 +65,7 @@ executable reddit-pub
|
|||||||
-- LANGUAGE extensions used by modules in this package.
|
-- LANGUAGE extensions used by modules in this package.
|
||||||
-- other-extensions:
|
-- other-extensions:
|
||||||
build-depends:
|
build-depends:
|
||||||
base ^>=4.14.1.0,
|
base ^>=4.15.1.0,
|
||||||
reddit-pub
|
reddit-pub
|
||||||
|
|
||||||
hs-source-dirs: app
|
hs-source-dirs: app
|
||||||
@ -82,7 +82,7 @@ test-suite reddit-tests
|
|||||||
-- LANGUAGE extensions used by modules in this package.
|
-- LANGUAGE extensions used by modules in this package.
|
||||||
-- other-extensions:
|
-- other-extensions:
|
||||||
build-depends:
|
build-depends:
|
||||||
base ^>=4.14.1.0,
|
base ^>=4.15.1.0,
|
||||||
mtl,
|
mtl,
|
||||||
containers,
|
containers,
|
||||||
bytestring,
|
bytestring,
|
||||||
|
21
src/MyLib.hs
21
src/MyLib.hs
@ -2,20 +2,25 @@
|
|||||||
{-# LANGUAGE DeriveAnyClass #-}
|
{-# LANGUAGE DeriveAnyClass #-}
|
||||||
{-# LANGUAGE DeriveGeneric #-}
|
{-# LANGUAGE DeriveGeneric #-}
|
||||||
{-# LANGUAGE DerivingVia #-}
|
{-# LANGUAGE DerivingVia #-}
|
||||||
|
{-# LANGUAGE NumericUnderscores #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE TypeOperators #-}
|
{-# LANGUAGE TypeOperators #-}
|
||||||
module MyLib (defaultMain) where
|
module MyLib (defaultMain) where
|
||||||
|
|
||||||
|
import Control.Concurrent (threadDelay)
|
||||||
import Control.Exception (bracket)
|
import Control.Exception (bracket)
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Control.Monad (void)
|
import Control.Monad (forever, void)
|
||||||
import Data.Aeson (FromJSON, ToJSON, Value)
|
import Data.Aeson (FromJSON, ToJSON, Value)
|
||||||
import qualified Data.Aeson as A
|
import qualified Data.Aeson as A
|
||||||
|
import Data.Aeson.Lens (_String, key)
|
||||||
|
import Data.Bool (bool)
|
||||||
import Data.Config
|
import Data.Config
|
||||||
import Data.Deriving.Aeson
|
import Data.Deriving.Aeson
|
||||||
import Data.Foldable (for_)
|
import Data.Foldable (for_)
|
||||||
import Data.Functor.Contravariant ((>$<))
|
import Data.Functor.Contravariant ((>$<))
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
|
import qualified Data.Text.IO as TI
|
||||||
import qualified Data.Text.Strict.Lens as T
|
import qualified Data.Text.Strict.Lens as T
|
||||||
import qualified Database.SQLite.Simple as SQL
|
import qualified Database.SQLite.Simple as SQL
|
||||||
import GHC.Generics (Generic)
|
import GHC.Generics (Generic)
|
||||||
@ -23,19 +28,21 @@ import qualified Membership
|
|||||||
import Network.AMQP
|
import Network.AMQP
|
||||||
( Channel
|
( Channel
|
||||||
, DeliveryMode(Persistent)
|
, DeliveryMode(Persistent)
|
||||||
|
, closeConnection
|
||||||
|
, declareExchange
|
||||||
, exchangeName
|
, exchangeName
|
||||||
, exchangeType
|
, exchangeType
|
||||||
, msgBody
|
, msgBody
|
||||||
, msgDeliveryMode
|
, msgDeliveryMode
|
||||||
|
, newExchange
|
||||||
, newMsg
|
, newMsg
|
||||||
, publishMsg, openConnection, closeConnection, openChannel, newExchange, declareExchange
|
, openChannel
|
||||||
|
, openConnection
|
||||||
|
, publishMsg
|
||||||
)
|
)
|
||||||
import Network.Reddit (RedditId (RedditId), publishEntries)
|
import Network.Reddit (RedditId(RedditId), publishEntries)
|
||||||
import Network.Wreq.Session (newSession)
|
import Network.Wreq.Session (newSession)
|
||||||
import Publish (Publish(..))
|
import Publish (Publish(..))
|
||||||
import Data.Aeson.Lens (key, _String)
|
|
||||||
import Data.Bool (bool)
|
|
||||||
import qualified Data.Text.IO as TI
|
|
||||||
|
|
||||||
data MessageType = Create | Update
|
data MessageType = Create | Update
|
||||||
deriving stock (Show, Eq, Generic)
|
deriving stock (Show, Eq, Generic)
|
||||||
@ -86,9 +93,11 @@ defaultMain path = do
|
|||||||
let encoder = amqpPublisher sqlConn chan "reddit_posts"
|
let encoder = amqpPublisher sqlConn chan "reddit_posts"
|
||||||
recorder = sqlRecorder sqlConn
|
recorder = sqlRecorder sqlConn
|
||||||
publisher = encoder <> (messageIdentifier >$< recorder)
|
publisher = encoder <> (messageIdentifier >$< recorder)
|
||||||
|
forever $ do
|
||||||
for_ (conf ^. fetchers) $ \fetcher -> do
|
for_ (conf ^. fetchers) $ \fetcher -> do
|
||||||
print fetcher
|
print fetcher
|
||||||
publishEntries (toMessage >$< publisher) sess fetcher
|
publishEntries (toMessage >$< publisher) sess fetcher
|
||||||
|
threadDelay (15 * 60_000_000)
|
||||||
|
|
||||||
getPassword :: Password -> IO Text
|
getPassword :: Password -> IO Text
|
||||||
getPassword (Password p) = pure p
|
getPassword (Password p) = pure p
|
||||||
|
Loading…
Reference in New Issue
Block a user