Merge branch 'githash'
This commit is contained in:
commit
66018dca53
6 files changed
+29
-32
No files matched your search
+9
-9
@@ -1,10 +1,10 @@
|
||||
{ mkDerivation, aeson, annotated-exception, base, bytestring
|
||||
, containers, directory, ekg-core, exceptions, filepath
|
||||
, generic-lens, githash, http-client, http-types, katip, lens
|
||||
, lens-aeson, lib, monad-control, mtl, optparse-generic, pandoc
|
||||
, pipes, pipes-concurrency, retry, servant, servant-server, stm
|
||||
, streamly, streamly-core, text, time, transformers-base, unliftio
|
||||
, unordered-containers, wai, warp, wreq
|
||||
, generic-lens, http-client, http-types, katip, lens, lens-aeson
|
||||
, lib, monad-control, mtl, optparse-generic, pandoc, pipes
|
||||
, pipes-concurrency, retry, servant, servant-server, stm, streamly
|
||||
, streamly-core, template-haskell, text, time, transformers-base
|
||||
, unliftio, unordered-containers, wai, warp, wreq
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "wallabag-tagger";
|
||||
@@ -14,10 +14,10 @@ mkDerivation {
|
||||
isExecutable = true;
|
||||
libraryHaskellDepends = [
|
||||
aeson annotated-exception base bytestring containers directory
|
||||
ekg-core exceptions filepath generic-lens githash http-client
|
||||
http-types katip lens lens-aeson monad-control mtl optparse-generic
|
||||
pandoc pipes pipes-concurrency retry servant servant-server stm
|
||||
streamly streamly-core text time transformers-base unliftio
|
||||
ekg-core exceptions filepath generic-lens http-client http-types
|
||||
katip lens lens-aeson monad-control mtl optparse-generic pandoc
|
||||
pipes pipes-concurrency retry servant servant-server stm streamly
|
||||
streamly-core template-haskell text time transformers-base unliftio
|
||||
unordered-containers wai warp wreq
|
||||
];
|
||||
executableHaskellDepends = [ base ];
|
||||
|
||||
@@ -12,7 +12,11 @@
|
||||
let pkgs = nixpkgs.legacyPackages.${system};
|
||||
hp = nixpkgs.legacyPackages.${system}.haskellPackages.override (old: {
|
||||
overrides = pkgs.lib.composeExtensions (old.overrides or (_: _: {})) (f: p: {
|
||||
wallabag-tagger = f.callPackage ./. {};
|
||||
wallabag-tagger = pkgs.haskell.lib.overrideCabal (f.callPackage ./. {}) (_: {
|
||||
preBuild = ''
|
||||
export COMMIT="${self.rev or "unknown"}"
|
||||
'';
|
||||
});
|
||||
});
|
||||
});
|
||||
in rec {
|
||||
|
||||
@@ -30,10 +30,12 @@ import UnliftIO.Exception (displayException, isAsyncException)
|
||||
import UnliftIO.IORef (IORef, newIORef, writeIORef)
|
||||
import Wallabag
|
||||
import Pipes.Concurrent (performGC)
|
||||
import qualified Version
|
||||
|
||||
data Options
|
||||
= Quick {verbose :: Bool}
|
||||
| Full {verbose :: Bool}
|
||||
| Version
|
||||
| Daemon
|
||||
{ verbose :: Bool,
|
||||
credentials :: FilePath <?> "Path to the credentials.json",
|
||||
@@ -170,6 +172,7 @@ defaultMain = do
|
||||
case opts of
|
||||
Quick {verbose} -> run (severity verbose) Unarchived
|
||||
Full {verbose} -> run (severity verbose) Everything
|
||||
Version -> print Version.compileTimeVersion
|
||||
Daemon {verbose, credentials, port} ->
|
||||
runDaemon (unHelpful $ unDefValue port) (unHelpful credentials) (severity verbose)
|
||||
where
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ import System.Metrics.Distribution qualified as D
|
||||
import UnliftIO (liftIO)
|
||||
import UnliftIO.IORef (readIORef)
|
||||
import Data.Coerce (coerce)
|
||||
import Version (Version, version)
|
||||
import Version (Version, compileTimeVersion)
|
||||
|
||||
data Health
|
||||
= OK
|
||||
@@ -77,7 +77,7 @@ getHealth :: IORef Health -> M Health
|
||||
getHealth = readIORef
|
||||
|
||||
getVersion :: M Version
|
||||
getVersion = pure version -- Comes from TH during compile time
|
||||
getVersion = pure compileTimeVersion
|
||||
|
||||
getMetrics :: M Metrics
|
||||
getMetrics = do
|
||||
|
||||
+9
-19
@@ -3,32 +3,22 @@
|
||||
{-# HLINT ignore "Unused LANGUAGE pragma" #-}
|
||||
module Version where
|
||||
|
||||
import GitHash (tGitInfoCwd, giHash, giDirty, giCommitDate, giCommitMessage)
|
||||
import qualified Data.Aeson as A
|
||||
import qualified Data.ByteString.Lazy.Char8 as BL
|
||||
import GHC.Generics (Generic)
|
||||
import System.Environment (lookupEnv)
|
||||
import Language.Haskell.TH (runIO, litE, stringL)
|
||||
import Data.Maybe (fromMaybe)
|
||||
|
||||
|
||||
-- Populate the version via the 'githash' package
|
||||
data Version = Version
|
||||
{ versionCommit :: String
|
||||
, versionDirty :: Bool
|
||||
, versionCommitDate :: String
|
||||
, versionCommitMessage :: String
|
||||
}
|
||||
newtype Version = Version
|
||||
{ versionCommit :: String }
|
||||
deriving (Show, Generic)
|
||||
|
||||
instance A.ToJSON Version
|
||||
|
||||
version :: Version
|
||||
version = Version
|
||||
{ versionCommit = giHash gi
|
||||
, versionDirty = giDirty gi
|
||||
, versionCommitDate = giCommitDate gi
|
||||
, versionCommitMessage = giCommitMessage gi
|
||||
}
|
||||
where
|
||||
gi = $$tGitInfoCwd
|
||||
versionFromEnv :: IO Version
|
||||
versionFromEnv = maybe (Version "unknown") Version <$> lookupEnv "COMMIT"
|
||||
|
||||
test :: IO ()
|
||||
test = BL.putStrLn $ A.encode version
|
||||
compileTimeVersion :: Version
|
||||
compileTimeVersion = Version $(runIO (fromMaybe "unknown" <$> lookupEnv "COMMIT") >>= litE . stringL)
|
||||
@@ -65,7 +65,7 @@ library
|
||||
, generic-lens
|
||||
, optparse-generic
|
||||
, containers
|
||||
, githash
|
||||
, template-haskell
|
||||
hs-source-dirs: src
|
||||
default-language: GHC2021
|
||||
|
||||
|
||||
Reference in new issue
Block a user