diff --git a/blog/default.nix b/blog/default.nix index ed1e405dd..5359a0ab6 100644 --- a/blog/default.nix +++ b/blog/default.nix @@ -1,23 +1,24 @@ { - pkgs ? import {}, + nixpkgs ? import {}, depot ? import {}, universe ? import {}, ... }: let - injectedPosts = pkgs.writeText "posts.lisp" '' + injectedPosts = nixpkgs.writeText "posts.lisp" '' (in-package #:server) (setq *path-to-posts* "${./posts}") ''; - injectedExecutables = pkgs.writeText "executables.lisp" '' + injectedExecutables = nixpkgs.writeText "executables.lisp" '' (in-package #:server) - (setq *pandoc-bin* "${pkgs.pandoc}/bin/pandoc") + (setq *pandoc-bin* "${nixpkgs.pandoc}/bin/pandoc") ''; in depot.nix.buildLisp.program { name = "server"; - deps = with depot.third_party.lisp; [ + deps = with depot.third_party.lisp; with universe.third_party.lisp; [ hunchentoot + cl-arrows ]; srcs = [ ./src/server.lisp diff --git a/blog/src/server.lisp b/blog/src/server.lisp index 7f669ddd7..ad8169fa1 100644 --- a/blog/src/server.lisp +++ b/blog/src/server.lisp @@ -2,6 +2,7 @@ (defpackage #:server (:documentation "Robot condemned to a life of admin work for my blog.") (:use #:cl) + (:import-from #:cl-arrows #:->>) (:export :main)) (in-package #:server) @@ -9,7 +10,9 @@ ;; Nix-injected dependencies ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defvar *path-to-posts* "/tmp" +;; TODO: Wrap this in an assert or ensure that there's a trailing slash so it's +;; treated as a directory. +(defvar *path-to-posts* "/tmp/" "File path pointing to the posts directory.") (defvar *pandoc-bin* "/usr/bin/pandoc") @@ -21,7 +24,7 @@ (defun render-post (path) "Render the markdown file stored at PATH to HTML using pandoc." (uiop:run-program (list *pandoc-bin* path "--to" "html") - :output t)) + :output :string)) ;; TODO: Figure out how to handle this with Nix. (defvar *posts* (uiop:directory-files *path-to-posts*) @@ -29,8 +32,7 @@ (hunchentoot:define-easy-handler (get-latest :uri "/latest") () - (print (parameter "name")) - (uiop:read-file-string (car *posts*))) + (render-post (concatenate 'string *path-to-posts* "/" "test.md"))) (hunchentoot:define-easy-handler (get-posts :uri "/posts") () diff --git a/default.nix b/default.nix index d1fb88e04..ff3127994 100644 --- a/default.nix +++ b/default.nix @@ -15,8 +15,11 @@ let readTree' = import /home/wpcarro/depot/nix/readTree {}; + # TODO: Find a better way to expose entire monorepo without introducing + # "infinite recursion". localPkgs = readTree: { - third_party = readTree ./third_party; + blog = readTree ./blog; + third_party = readTree ./third_party; }; in fix(self: { config = config self;