From b0be8e1bbba9e832c8423785263e27baadaa185a Mon Sep 17 00:00:00 2001 From: Guillem Marpons Date: Sat, 25 Dec 2021 22:42:30 +0100 Subject: [PATCH] Add file shell.nix It installs all necessary tools for development. It also declares a shell function calldoctor, that compares the output of asciidoctor/asciidoc-hs for a given AsciiDoc file. --- shell.nix | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..2487ce9 --- /dev/null +++ b/shell.nix @@ -0,0 +1,33 @@ +let pkgs = import (fetchTarball path) {}; + path = https://github.com/NixOS/nixpkgs/archive/master.tar.gz; +in with pkgs; + mkShell { + buildInputs = [ + asciidoctor-with-extensions + git + haskell.compiler.ghc901 + haskellPackages.cabal-install + haskellPackages.pandoc + html-tidy + icdiff + ]; + shellHook = '' + git config core.hooksPath .hooks + + function calldoctor() { + if [[ -z "$2" ]] ; then + echo "calldoctor [html4|html5] FILE" + echo "Compares the output of asciidoctor/asciidoc-hs on AsciiDoc file FILE." + else + local FILE="$2" + cabal build exe:asciidoc-hs + icdiff <( + asciidoctor -s -a "sectids!" -a "showtitle" $FILE -o - 2> /dev/null | tidy 2> /dev/null + ) <( + cat $FILE | cabal exec asciidoc-hs | pandoc -f json -t $1 | tidy 2> /dev/null + ) + fi + } + ''; + LC_ALL="C.UTF-8"; + }