Skip to content

Commit dbb94e9

Browse files
committed
default.nix for pandoc
1 parent c95a014 commit dbb94e9

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
result

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ http://cross-magazine.sub.jp/magazine/
1111
Code: https://github.com/xc-jp/blog-post-code
1212

1313
All content is copyright Cross Compass LLC 2021.
14+
15+
## Building
16+
17+
To locally `pandoc` all of the `*.md` files into `result/*.html` files,
18+
19+
```
20+
nix-build
21+
```

default.nix

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{ pkgs ? import <nixpkgs> {} }:
2+
3+
pkgs.stdenv.mkDerivation {
4+
name = "xc-blog-posts";
5+
src = builtins.path { path = ./.; name = "blog-posts"; }; # https://nix.dev/anti-patterns/language.html#reproducability-referencing-top-level-directory-with
6+
nativeBuildInputs = [pkgs.pandoc];
7+
phases = "unpackPhase installPhase";
8+
unpackPhase = ''
9+
cp $src/*.md ./
10+
'';
11+
installPhase = ''
12+
mkdir -p $out
13+
for file in *.md; do
14+
pandoc $file --from markdown --to html --standalone --output "$out/''${file%%.md}.html"
15+
done
16+
'';
17+
}
18+

0 commit comments

Comments
 (0)