Skip to content

Instantly share code, notes, and snippets.

@dustinlacewell-wk
Last active October 19, 2017 02:40
Show Gist options
  • Save dustinlacewell-wk/519883f42241045b17793b491c6a0bb8 to your computer and use it in GitHub Desktop.
Save dustinlacewell-wk/519883f42241045b17793b491c6a0bb8 to your computer and use it in GitHub Desktop.
args@{ pkgs, ... }:
with builtins;
with (import <nixpkgs> { });
let
# defines programs.emacs.org-build
org-build = (import ../../../nix-hm-org-build) args;
# org-build = fetchFromGitHub {
# owner = "dustinlacewell";
# repo = "nix-hm-org-build";
# rev = "c1e604690191ef616837d4b8c35f8e6110bc89ae";
# sha256 = "03037zcliyvz7xig35wszaczswcwzl730rwdpqqg61mm0g6aiij9";
# } args;
# provides org-export.export
org-export = (import ../../../nix-hm-org-export) args;
# org-export = (fetchFromGitHub {
# owner = "dustinlacewell";
# repo = "nix-hm-org-export";
# rev = "master";
# }) args;
# export init.org to Github Pages
export = org-export.export {
source = ./init.org;
user = "dustinlacewell";
repo = "emacs.d";
token = getEnv "EMACS_D_GITHUB_TOKEN";
};
in {
# import org-build to load its Options
imports = [ org-build.module ];
# ensure that emacs gets installed
programs.emacs = { enable = true; };
# compile init.el from init.org
programs.emacs.org-build = { enable = true; source = ./init.org; };
}
{ config, pkgs, lib, ... }:
with lib;
with builtins;
rec {
build = { source }: let
# the build uses emacs to perform the conversion
env = { buildInputs = [ pkgs.emacs ]; };
# call make-init-el to convert the file
script = ''
ln -s "${source}" ./init.org;
emacs -Q --script "${./org-build.el}" -f make-init-el;
cp ./init.el $out;
'';
in pkgs.runCommand "org-build" env script;
module = let
cfg = config.programs.emacs.org-build;
in {
options.programs.emacs.org-build = {
enable = mkEnableOption "Build init.el from Orgmode file";
source = mkOption {
type = types.path;
description = ''
The source orgfile to build as init.el
'';
};
};
config = mkIf cfg.enable {
home.file.".emacs.d/init.el".source = build { source=cfg.source; };
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment