tvl-depot/users/glittershark/gws.fyi/orgExportHTML.nix
Griffin Smith a7cd92770d revert(glittershark): "Temporarily skip grfn's subtree"
This reverts commit 475d41f698. I'd like
my derivations back, please.

Changes necessary to get this working:

- Don't depend on `nixpkgs` being in the NIX_PATH for my website - it's
  not necessary anyway since emacs 27 is mainline now
- .skip-subtrees on things that shouldn't be evaluated anyway
- Get rid of system/pkgs, and move the one thing in there that *wasn't*
  already in third_party (alsi) to third_party
- Drop notifymuch for now - it's not working, and I'll probably get it
  landed in nixpkgs before I manage to get it working
- Add __readTree = true to my systems so they get built.
- explicitly disable ci for xanthous, which is failing to build and had
  been omitted previously

Change-Id: I20f5e81d6eb7ffe040091a08d75d0cb15304f707
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1864
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-08-28 21:24:36 +00:00

54 lines
1.1 KiB
Nix

{ pkgs, ... }:
with pkgs;
with lib;
let
emacsWithPackages = (pkgs.emacsPackagesGen pkgs.emacs27).emacsWithPackages;
emacs = emacsWithPackages (p: with p; [
org
]);
in
opts:
let
src = if isAttrs opts then opts.src else opts;
headline = if isAttrs opts then opts.headline else null;
bn = builtins.baseNameOf src;
filename = elemAt (splitString "." bn) 0;
outName =
if isNull headline
then
let bn = builtins.baseNameOf src;
filename = elemAt (splitString "." bn) 0;
in filename + ".html"
else "${filename}-${replaceStrings [" "] ["-"] filename}.html";
escapeDoubleQuotes = replaceStrings ["\""] ["\\\""];
navToHeadline = optionalString (! isNull headline) ''
(search-forward "${escapeDoubleQuotes headline}")
(org-narrow-to-subtree)
'';
in
runCommand outName {} ''
cp ${src} file.org
echo "${emacs}/bin/emacs --batch"
${emacs}/bin/emacs --batch \
--load ${./config.el} \
--visit file.org \
--eval "(progn
${escapeDoubleQuotes navToHeadline}
(org-html-export-to-html))" \
--kill
substitute file.html $out \
--replace '<title>&lrm;</title>' ""
''