Disable ormolu for hakyll DSL-y code; only bring in a stylesheet if we have one
This commit is contained in:
parent
9244c2e20f
commit
8cec937b86
11
README.md
11
README.md
@ -8,9 +8,8 @@
|
||||
|
||||
1. Click the "Use this template" button and create your repository
|
||||
1. Renaming
|
||||
1. Rename all instances of `hakyll-nix-template` and `my-site` with a name for
|
||||
your project
|
||||
1. Rename `generator/my-site.cabal` to reflect your project name
|
||||
1. Rename all instances of `hakyll-nix-template` with the name of your project
|
||||
1. Rename `generator/hakyll-nix-template.cabal` to reflect your project name
|
||||
1. Cachix
|
||||
1. Create a cachix cache for your project on https://app.cachix.org
|
||||
1. Follow the cachix instructions to generate a signing keypair
|
||||
@ -23,9 +22,9 @@
|
||||
1. To start an environment for running hakyll commands like `hakyll-site watch`
|
||||
(the dev server) and `hakyll-site build`: `cd generator && nix-shell`. You'll
|
||||
then have access to the `hakyll-site` executable defined in
|
||||
`generator/my-site.cabal`. While you can do `nix-shell` in the root and then
|
||||
`cd generator && hakyll-site watch`, you get some more tools if you
|
||||
`nix-shell` from within the `generator/` folder.
|
||||
`generator/hakyll-nix-template.cabal`. While you can do `nix-shell` in the
|
||||
root and then `cd generator && hakyll-site watch`, you get some more tools if
|
||||
you `nix-shell` from within the `generator/` folder.
|
||||
1. Once you're satisfied, create a branch, push your project up there, and check
|
||||
that the GitHub Actions successfully build. If so, you're good to merge your
|
||||
project with your main branch.
|
||||
|
40
default.nix
40
default.nix
@ -1,26 +1,26 @@
|
||||
let
|
||||
cfg = import ./nix/default.nix {};
|
||||
cfg = import ./nix/default.nix { };
|
||||
in
|
||||
{ pkgs ? cfg.pkgs }:
|
||||
|
||||
pkgs.stdenv.mkDerivation {
|
||||
name = "my-site";
|
||||
buildInputs = [
|
||||
cfg.generator
|
||||
];
|
||||
src = cfg.src;
|
||||
pkgs.stdenv.mkDerivation {
|
||||
name = "hakyll-nix-template";
|
||||
buildInputs = [
|
||||
cfg.generator
|
||||
];
|
||||
src = cfg.src;
|
||||
|
||||
# https://github.com/jaspervdj/hakyll/issues/614
|
||||
# https://github.com/NixOS/nix/issues/318#issuecomment-52986702
|
||||
# https://github.com/MaxDaten/brutal-recipes/blob/source/default.nix#L24
|
||||
LOCALE_ARCHIVE = pkgs.lib.optionalString (pkgs.buildPlatform.libc == "glibc") "${pkgs.glibcLocales}/lib/locale/locale-archive";
|
||||
LANG = "en_US.UTF-8";
|
||||
# https://github.com/jaspervdj/hakyll/issues/614
|
||||
# https://github.com/NixOS/nix/issues/318#issuecomment-52986702
|
||||
# https://github.com/MaxDaten/brutal-recipes/blob/source/default.nix#L24
|
||||
LOCALE_ARCHIVE = pkgs.lib.optionalString (pkgs.buildPlatform.libc == "glibc") "${pkgs.glibcLocales}/lib/locale/locale-archive";
|
||||
LANG = "en_US.UTF-8";
|
||||
|
||||
buildPhase = ''
|
||||
hakyll-site build
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p "$out/dist"
|
||||
cp -r ../dist/* "$out/dist"
|
||||
'';
|
||||
}
|
||||
buildPhase = ''
|
||||
hakyll-site build
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p "$out/dist"
|
||||
cp -r ../dist/* "$out/dist"
|
||||
'';
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{ pkgs }:
|
||||
|
||||
(pkgs.callPackage ./hpkgs.nix {}).my-site
|
||||
(pkgs.callPackage ./hpkgs.nix { }).hakyll-nix-template
|
||||
|
@ -1,6 +1,6 @@
|
||||
cabal-version: 2.4
|
||||
|
||||
name: my-site
|
||||
name: hakyll-nix-template
|
||||
version: 0.1.0.0
|
||||
build-type: Simple
|
||||
license: BSD-3-Clause
|
@ -1,7 +1,6 @@
|
||||
{ compiler ? "ghc884"
|
||||
, pkgs
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (pkgs.lib.trivial) flip pipe;
|
||||
inherit (pkgs.haskell.lib) appendPatch appendConfigureFlags dontCheck;
|
||||
@ -18,13 +17,15 @@ let
|
||||
(flip appendConfigureFlags hakyllFlags)
|
||||
];
|
||||
|
||||
my-site = hpNew.callCabal2nix "my-site" ./. {};
|
||||
hakyll-nix-template = hpNew.callCabal2nix "hakyll-nix-template" ./. { };
|
||||
|
||||
# because hakyll is marked as broken in nixpkgs
|
||||
hslua = dontCheck (hpNew.callHackage "hslua" "1.0.3.2" {});
|
||||
jira-wiki-markup = dontCheck (hpNew.callHackage "jira-wiki-markup" "1.1.4" {});
|
||||
pandoc = dontCheck (hpNew.callHackage "pandoc" "2.9.2.1" {});
|
||||
pandoc-types = dontCheck (hpNew.callHackage "pandoc-types" "1.20" {});
|
||||
# when hakyll is marked as broken in nixpkgs
|
||||
# because of version issues, fix them here:
|
||||
|
||||
hslua = dontCheck (hpNew.callHackage "hslua" "1.0.3.2" { });
|
||||
jira-wiki-markup = dontCheck (hpNew.callHackage "jira-wiki-markup" "1.1.4" { });
|
||||
pandoc = dontCheck (hpNew.callHackage "pandoc" "2.9.2.1" { });
|
||||
pandoc-types = dontCheck (hpNew.callHackage "pandoc-types" "1.20" { });
|
||||
};
|
||||
};
|
||||
in
|
||||
|
@ -1,21 +1,21 @@
|
||||
let
|
||||
cfg = import ../nix/default.nix {};
|
||||
cfg = import ../nix/default.nix { };
|
||||
hp = cfg.haskellPackages;
|
||||
in
|
||||
{}:
|
||||
|
||||
hp.shellFor {
|
||||
packages = p: [
|
||||
p.my-site
|
||||
];
|
||||
hp.shellFor {
|
||||
packages = p: [
|
||||
p.hakyll-nix-template
|
||||
];
|
||||
|
||||
buildInputs = with hp; [
|
||||
cabal-install
|
||||
ghcid
|
||||
hlint
|
||||
hp.my-site
|
||||
ormolu
|
||||
];
|
||||
buildInputs = with hp; [
|
||||
cabal-install
|
||||
ghcid
|
||||
hlint
|
||||
hp.hakyll-nix-template
|
||||
ormolu
|
||||
];
|
||||
|
||||
withHoogle = true;
|
||||
}
|
||||
withHoogle = true;
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ config =
|
||||
|
||||
-- BUILD
|
||||
|
||||
{- ORMOLU_DISABLE -}
|
||||
|
||||
main :: IO ()
|
||||
main = hakyllWith config $ do
|
||||
forM_
|
||||
@ -57,6 +59,7 @@ main = hakyllWith config $ do
|
||||
match "css/*" $ do
|
||||
route idRoute
|
||||
compile compressCssCompiler
|
||||
|
||||
match "posts/*" $ do
|
||||
let ctx = constField "type" "article" <> postCtx
|
||||
route $ metadataRoute titleRoute
|
||||
@ -65,6 +68,7 @@ main = hakyllWith config $ do
|
||||
>>= loadAndApplyTemplate "templates/post.html" ctx
|
||||
>>= saveSnapshot "content"
|
||||
>>= loadAndApplyTemplate "templates/default.html" ctx
|
||||
|
||||
match "index.html" $ do
|
||||
route idRoute
|
||||
compile $ do
|
||||
@ -77,7 +81,10 @@ main = hakyllWith config $ do
|
||||
getResourceBody
|
||||
>>= applyAsTemplate indexCtx
|
||||
>>= loadAndApplyTemplate "templates/default.html" indexCtx
|
||||
match "templates/*" $ compile templateBodyCompiler
|
||||
|
||||
match "templates/*" $
|
||||
compile templateBodyCompiler
|
||||
|
||||
create ["sitemap.xml"] $ do
|
||||
route idRoute
|
||||
compile $ do
|
||||
@ -89,13 +96,17 @@ main = hakyllWith config $ do
|
||||
<> listField "pages" postCtx (return pages)
|
||||
makeItem ("" :: String)
|
||||
>>= loadAndApplyTemplate "templates/sitemap.xml" sitemapCtx
|
||||
|
||||
create ["rss.xml"] $ do
|
||||
route idRoute
|
||||
compile (feedCompiler renderRss)
|
||||
|
||||
create ["atom.xml"] $ do
|
||||
route idRoute
|
||||
compile (feedCompiler renderAtom)
|
||||
|
||||
{- ORMOLU_ENABLE -}
|
||||
|
||||
-- CONTEXT
|
||||
|
||||
feedCtx :: Context String
|
||||
|
@ -5,10 +5,10 @@
|
||||
"homepage": "https://github.com/nmattia/niv",
|
||||
"owner": "nmattia",
|
||||
"repo": "niv",
|
||||
"rev": "9d35b9e4837ab88517210b1701127612c260eccf",
|
||||
"sha256": "0q50xhnm8g2yfyakrh0nly4swyygxpi0a8cb9gp65wcakcgvzvdh",
|
||||
"rev": "20c899271f288d33114760bc298838575fc6c7f9",
|
||||
"sha256": "07zswk6dhlydihl9g6skmy52grjvqpra8r98f2dmbgwzc1yhjhxq",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nmattia/niv/archive/9d35b9e4837ab88517210b1701127612c260eccf.tar.gz",
|
||||
"url": "https://github.com/nmattia/niv/archive/20c899271f288d33114760bc298838575fc6c7f9.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs": {
|
||||
@ -29,10 +29,10 @@
|
||||
"homepage": "",
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "efdbd6d28f7f44db3d9f8cf0e0b4cb9db0d259e1",
|
||||
"sha256": "1qngfbp1bqn52ipf992vrj4vp1cvvcv2yvzp0fs9yawqjxzk4j5m",
|
||||
"rev": "117579f3cfe4c0abeff70631fa31261d5ea99cfd",
|
||||
"sha256": "1bjvadx76rlf54b43agfx1w35wqpagzihdv2yy0jsrk1glxc15ax",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/cachix/pre-commit-hooks.nix/archive/efdbd6d28f7f44db3d9f8cf0e0b4cb9db0d259e1.tar.gz",
|
||||
"url": "https://github.com/cachix/pre-commit-hooks.nix/archive/117579f3cfe4c0abeff70631fa31261d5ea99cfd.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,10 @@
|
||||
|
||||
<link rel="shortcut icon" href="/favicon.ico">
|
||||
<link rel="canonical" href="$root$$url$">
|
||||
<link rel="stylesheet" href="./css/default.css" />
|
||||
$if(stylesheet)$
|
||||
<link rel="stylesheet" href="./css/$stylesheet$.css" />
|
||||
$endif$
|
||||
</head>
|
||||
<body>
|
||||
$body$
|
||||
|
Loading…
Reference in New Issue
Block a user