(use-modules ((gnu packages haskell-xyz) #:select (pandoc)) ((gnu packages python) #:select (python)) (guix build utils) (guix gexp)) (define (build-post post) (computed-file (basename post ".md") (with-imported-modules '((guix build utils)) #~(begin (use-modules (guix build utils)) (let ((posts-directory (string-append #$output "/posts/"))) (mkdir-p posts-directory) (invoke #$(file-append pandoc "/bin/pandoc") "--from" "markdown" "--to" "html" "--standalone" "--output" (string-append posts-directory #$(basename post ".md") ".html") #$(local-file post))))))) (define (build-index posts) (computed-file "blog-index" (with-imported-modules '((guix build utils)) #~(begin (use-modules (guix build utils)) (invoke #$(file-append python "/bin/python3") #$(local-file "generate-index.py") "index.md" #$@(map (lambda (file) (local-file file)) posts)) (mkdir #$output) (invoke #$(file-append pandoc "/bin/pandoc") "--from" "markdown" "--to" "html" "--standalone" "--metadata" "title=My blog" "--output" (string-append #$output "/index.html") "index.md"))))) (let ((posts (find-files "posts" "\\.md$"))) (directory-union "blog" (cons (build-index posts) (map build-post posts))))