From 115548495f0a64bc5b57832c728ccb972ab207dc Mon Sep 17 00:00:00 2001 From: "root@procul" Date: Thu, 16 Jul 2020 15:46:52 -0500 Subject: [PATCH] missed some changes --- config/informis/cl-gemini.nix | 79 +++++++++++++++++++++++++++++------ hosts/procul.nix | 16 +++++-- packages/cl-gemini.nix | 4 +- 3 files changed, 81 insertions(+), 18 deletions(-) diff --git a/config/informis/cl-gemini.nix b/config/informis/cl-gemini.nix index ccab8bc..172a92b 100644 --- a/config/informis/cl-gemini.nix +++ b/config/informis/cl-gemini.nix @@ -5,6 +5,8 @@ let cfg = config.informis.cl-gemini; lisp-libs = with pkgs.lispPackages; [ + asdf-package-system + asdf-system-connections alexandria asdf-package-system asdf-system-connections @@ -16,21 +18,17 @@ let usocket ]; - launchServer = load-paths: ip: port: root: public-dir: key: cert: slynk-port: - let - load-path-string = - concatStringsSep " " (map (path: "\"${path}\"") load-paths); - in pkgs.writeText "launch-server.lisp" '' + launchServer = ip: port: root: public-dir: key: cert: slynk-port: feeds-string: textfiles-archive: + pkgs.writeText "launch-server.lisp" '' (load (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname))) - (setf asdf:*central-registry* - (append asdf:*central-registry* - (list ${load-path-string}))) (ql:quickload :slynk) (ql:quickload :cl-gemini) ${optionalString (slynk-port != null) "(slynk:create-server :port ${toString slynk-port} :dont-close t)"} + ${feeds-string} (cl-gemini:start-gemini-server "${ip}" "${key}" "${cert}" :port ${toString port} :document-root "${root}" + :textfiles-root "${textfiles-archive}" :file-cmd "${pkgs.file}/bin/file" :log-stream *standard-output* :threaded t @@ -44,6 +42,36 @@ let ]; }); + feedOpts = with types; { + options = { + url = mkOption { + type = str; + description = "Base URI of the feed, i.e. the URI corresponding to the feed path."; + example = "gemini://my.server/path/to/feedfiles"; + }; + + title = mkOption { + type = str; + description = "Title of given feed."; + example = "My Fancy Feed"; + }; + + path = mkOption { + type = str; + description = "Path to Gemini files making up the feed."; + example = "/path/to/feed"; + }; + }; + }; + + register-feed = name: opts: '' + (cl-gemini:register-feed :name "${name}" :title "${opts.title}" :path "${opts.path}" :base-uri "${opts.url}")''; + + register-feeds = feeds: + concatStringsSep "\n" + (mapAttrsToList register-feed feeds); + + in { options.informis.cl-gemini = with types; { enable = mkEnableOption "Enable the cl-gemini server."; @@ -61,9 +89,9 @@ in { }; document-root = mkOption { - type = path; + type = str; description = "Root at which to look for gemini files."; - example = /my/gemini/root; + example = "/my/gemini/root"; }; user-public = mkOption { @@ -89,6 +117,25 @@ in { description = "Port on which to open a slynk server, if any."; default = null; }; + + feeds = mkOption { + type = loaOf (submodule feedOpts); + description = "Feeds to generate and make available (as eg. /feed/name.xml)."; + example = { + diary = { + title = "My Diary"; + path = "/path/to/my/gemfiles/"; + url = "gemini://my.host/blog-path/"; + }; + }; + default = {}; + }; + + textfiles-archive = mkOption { + type = str; + description = "A path containing only gemini & text files."; + example = "/path/to/textfiles/"; + }; }; config = mkIf cfg.enable { @@ -124,13 +171,11 @@ in { description = "cl-gemini Gemini server (https://gemini.circumlunar.space/)"; serviceConfig = let - load-paths = (map (pkg: "${pkg}/lib/common-lisp//") - (lisp-libs ++ [pkgs.cl-gemini])); + feed-registrations = register-feeds cfg.feeds; in { ExecStartPre = "${pkgs.lispPackages.quicklisp}/bin/quicklisp init"; ExecStart = "${sbcl-with-ssl}/bin/sbcl --load ${ launchServer - load-paths cfg.server-ip cfg.port cfg.document-root @@ -138,6 +183,8 @@ in { "/etc/cl-gemini/key.pem" "/etc/cl-gemini/cert.pem" cfg.slynk-port + feed-registrations + cfg.textfiles-archive }"; Restart = "on-failure"; PIDFile = "/run/cl-gemini.$USERNAME.uid"; @@ -146,9 +193,15 @@ in { environment = { LD_LIBRARY_PATH = "${pkgs.openssl_1_1.out}/lib"; + CL_SOURCE_REGISTRY = concatStringsSep ":" + (["${config.users.users.cl-gemini.home}/quicklisp/quicklisp"] ++ + (map + (pkg: "${pkg}//") + (lisp-libs ++ [pkgs.cl-gemini]))); }; path = with pkgs; [ + gcc file getent ]; diff --git a/hosts/procul.nix b/hosts/procul.nix index 754d83a..2276e63 100644 --- a/hosts/procul.nix +++ b/hosts/procul.nix @@ -267,9 +267,19 @@ in { enable = true; server-ip = host_ipv4; - document-root = /srv/gemini; - ssl-private-key = acme-private-key "informis.land"; - ssl-certificate = acme-certificate "informis.land"; + document-root = "/srv/gemini/root"; + ssl-private-key = "/srv/gemini/private/key.pem"; + ssl-certificate = "/srv/gemini/private/cert.pem"; slynk-port = 4005; + + textfiles-archive = "/srv/gemini/textfiles"; + + feeds = { + viator = { + title = "viator's phlog"; + path = "/home/viator/gemini-public/feed/"; + url = "gemini://informis.land/user/viator/feed/"; + }; + }; }; } diff --git a/packages/cl-gemini.nix b/packages/cl-gemini.nix index 5577e17..22ef42c 100644 --- a/packages/cl-gemini.nix +++ b/packages/cl-gemini.nix @@ -9,8 +9,8 @@ in stdenv.mkDerivation { src = fetchgit { url = "https://git.informis.land/viator/cl-gemini.git"; - rev = "a4596703a4e7ff628639ea4a2350591e4db9a32d"; - sha256 = "18zqgx200fd32kgbpfhvcnlwanzmjk3f0ggiks0n579zkhzslxs0"; + rev = "3de4d1945fc91d0c9f8f65a5d4b0d3f39fbdaa80"; + sha256 = "1xzfsp5vp36a3yas5pnhj2a1dd72r72fw3l49ah19hvbapaikhsw"; fetchSubmodules = false; };