diff options
| -rw-r--r-- | nix/overlay.nix | 43 | ||||
| -rw-r--r-- | package.yaml | 1 | ||||
| -rw-r--r-- | src/Hakyll/Core/Identifier/Pattorn.hs | 2 | ||||
| -rw-r--r-- | src/Hakyll/Error.hs | 7 | ||||
| -rw-r--r-- | src/Hakyll/Parsec/Parsec.hs | 9 | ||||
| -rw-r--r-- | src/Hakyll/Web/Template/Util.hs | 11 |
6 files changed, 67 insertions, 6 deletions
diff --git a/nix/overlay.nix b/nix/overlay.nix index 82c1d72..8c6baf4 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -14,11 +14,46 @@ in { www-main = hfinal.callCabal2nix "www-main" src {}; }); - site = prev.symlinkJoin { - name = "site"; + rubberWith = pkgs: prev.symlinkJoin { + name = "rubber"; + nativeBuildInputs = [ + prev.makeWrapper + ]; + paths = [ + prev.rubber + ]; + postBuild = '' + for x in $out/bin/*; do + wrapProgram "$x" --prefix PATH : ${prev.lib.makeBinPath pkgs} + done + ''; + }; + + hakyllWith = hakyll: pkgs: prev.symlinkJoin { + inherit (hakyll) name; + nativeBuildInputs = [ + prev.makeWrapper + ]; paths = [ - (final.haskell.lib.compose.justStaticExecutables final.haskellPackages.www-main) - prev.rsync + (final.haskell.lib.compose.justStaticExecutables hakyll) ]; + postBuild = '' + for x in $out/bin/*; do + wrapProgram "$x" --prefix PATH : ${prev.lib.makeBinPath pkgs} + done + ''; }; + + www-main = final.hakyllWith final.haskellPackages.www-main [ + (final.rubberWith [ prev.texlive.combined.scheme-full ]) + prev.rsync + ]; + + # site = prev.symlinkJoin { + # name = "site"; + # paths = [ + # (final.haskell.lib.compose.justStaticExecutables final.haskellPackages.www-main) + # prev.rsync + # ]; + # }; } diff --git a/package.yaml b/package.yaml index 550010e..776920e 100644 --- a/package.yaml +++ b/package.yaml @@ -51,6 +51,7 @@ library: - pandoc - parsec - process + - slugger - string-conv # - system - text diff --git a/src/Hakyll/Core/Identifier/Pattorn.hs b/src/Hakyll/Core/Identifier/Pattorn.hs index 0910320..e1767c4 100644 --- a/src/Hakyll/Core/Identifier/Pattorn.hs +++ b/src/Hakyll/Core/Identifier/Pattorn.hs @@ -11,6 +11,8 @@ newtype Pattorn = Pattorn { getPattern :: Pattern } instance Semigroup Pattorn where Pattorn a <> Pattorn b = Pattorn $ a .||. b + {-# INLINE (<>) #-} instance Monoid Pattorn where mempty = Pattorn $ complement mempty + {-# INLINE mempty #-} diff --git a/src/Hakyll/Error.hs b/src/Hakyll/Error.hs index 3ca29d3..35102d4 100644 --- a/src/Hakyll/Error.hs +++ b/src/Hakyll/Error.hs @@ -1,6 +1,8 @@ module Hakyll.Error ( ErrorConv (..) , throwErr + , liftErr + , squashErr , CompilerError ) where @@ -15,10 +17,13 @@ type CompilerError c = ErrorConv c [String] instance ErrorCnv err err where toErr = id +instance Exception c => ErrorCnv c SomeException where + toErr = SomeException + -- instance Functor f => ErrorCnv c err => ErrorCnv (f c) (f err) where -- toErr = fmap toErr -instance Applicative f => ErrorCnv c err => ErrorCnv c (f err) where +instance (Applicative f, ErrorCnv c err) => ErrorCnv c (f err) where toErr = pure . toErr throwErr :: (MonadError err m, ErrorConv c err) => c -> m a diff --git a/src/Hakyll/Parsec/Parsec.hs b/src/Hakyll/Parsec/Parsec.hs index cac653c..123c5fd 100644 --- a/src/Hakyll/Parsec/Parsec.hs +++ b/src/Hakyll/Parsec/Parsec.hs @@ -1,7 +1,8 @@ module Hakyll.Parsec.Parsec ( compileParsec , compileParsec_ - , evalParsec + , parsecCompiler + , parsecCompiler_ ) where import Prolog @@ -18,3 +19,9 @@ compileParsec p u itm@(Item i _) = traverse (liftErr . runParser p u (show i)) i compileParsec_ :: (MonadError [String] m, Stream s Identity t) => Parsec s () a -> Item s -> m (Item a) compileParsec_ p = compileParsec p () + +parsecCompiler :: (Stream s Identity t, StringConv LazyByteString s) => Parsec s u a -> u -> Compiler (Item a) +parsecCompiler p u = getResourceLBS >>= compileParsec p u . fmap toSL + +parsecCompiler_ :: (Stream s Identity t, StringConv LazyByteString s) => Parsec s () a -> Compiler (Item a) +parsecCompiler_ p = parsecCompiler p () diff --git a/src/Hakyll/Web/Template/Util.hs b/src/Hakyll/Web/Template/Util.hs new file mode 100644 index 0000000..cfd8573 --- /dev/null +++ b/src/Hakyll/Web/Template/Util.hs @@ -0,0 +1,11 @@ +module Hakyll.Web.Template.Util + ( slug + ) where + +import Prolog +import Hakyll.Web.Template.Context +import Data.String.Slugger + + +slug :: Context a +slug = functionField "slug" $ \strs _ -> pure $ toSlug $ unwords strs |
