Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Created February 11, 2019 21:21
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 cleverca22/c9ac52d5b3dccc064a82c33418d67d54 to your computer and use it in GitHub Desktop.
Save cleverca22/c9ac52d5b3dccc064a82c33418d67d54 to your computer and use it in GitHub Desktop.
with import <nixpkgs> {};
let
ext = ext: path: let eL = builtins.stringLength ext;
pL = builtins.stringLength path;
in ext == builtins.substring (pL - eL) eL path;
things = self: {
odt2md = input: runCommand ("${builtins.baseNameOf input}.md") { buildInputs = [ pandoc ]; } ''
pandoc -t markdown ${input} > $out
'';
fileList = builtins.attrNames (lib.filterAttrs (name: value: ext ".odt" name && value == "regular") (builtins.readDir ./.));
mdList = map (file: self.odt2md (./. + "/${file}")) self.fileList;
allMds = runCommand "all-the-mds" {} ''
mkdir $out
cat ${self.mdList} > $out/all-the-things.md
'';
};
in lib.fix things
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment