Skip to content

Instantly share code, notes, and snippets.

@dustinlacewell-wk
Created October 20, 2017 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustinlacewell-wk/108ee3896bbc20a70b593634c1ee40fa to your computer and use it in GitHub Desktop.
Save dustinlacewell-wk/108ee3896bbc20a70b593634c1ee40fa to your computer and use it in GitHub Desktop.
{ pkgs, lib }:
with lib;
with builtins;
rec {
export = { source, user, repo, ... }: let
# use the main emacs package
pkgGen = pkgs.emacsPackagesNgGen pkgs.emacs;
# install htmlize for emacs
emacs = pkgGen.emacsWithPackages (epkgs: [ epkgs.htmlize ]);
# get the auth token from the environment
token = getEnv "GITHUB_PUBLIC_REPO_TOKEN";
# calculate the url of the repository
giturl = "https://${user}:${token}@github.com/${user}/${repo}.git";
# export Orgmode file to HTML and upload to Github Pages
env = { buildInputs = [ emacs pkgs.git ]; };
script = trace "WTF" ''
ln -s "${source}" ./init.org;
emacs -Q --script ${./org-export.el} -f export-init-to-html;
mv init.html index.html
git init;
git checkout -b gh-pages
git remote add origin "${giturl}"
git add index.html;
git commit -m "autodeploy";
git push --force origin gh-pages;
cp ./index.html $out;
'';
in pkgs.runCommand "org-export" env script;
module = { config, pkgs, lib, ... }:
let
cfg = config.plugins.org-export;
in {
options.plugins.org-export = {
finished = mkOption { type = types.bool; };
sources = mkOption {
type = with types; listOf (submodule {
options = {
source = mkOption { type = path; };
user = mkOption { type = str; };
repo = mkOption { type = str; };
};
});
description = ''
Orgfile sources to build export.
'';
};
};
config.plugins.org-export.finished = trace ":)" (deepSeq (map (job: export job) cfg.sources) true);
config.home.file."blah".text = toString cfg.finished;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment