From f442ea729cc63b95f6fb9b1ca09516914957875c Mon Sep 17 00:00:00 2001 From: root Date: Fri, 27 Nov 2020 11:36:10 -0600 Subject: [PATCH] Closer to 'correct' backplane-dns-server --- config/fudo/backplane/dns.nix | 72 +++++++++++++++++++++++++------ packages/backplane-dns-server.nix | 33 ++++++++++++++ packages/local.nix | 17 +++++--- 3 files changed, 103 insertions(+), 19 deletions(-) create mode 100644 packages/backplane-dns-server.nix diff --git a/config/fudo/backplane/dns.nix b/config/fudo/backplane/dns.nix index eacc5d7..e36b775 100644 --- a/config/fudo/backplane/dns.nix +++ b/config/fudo/backplane/dns.nix @@ -4,6 +4,54 @@ with lib; let cfg = config.fudo.backplane.dns; + lisp-pkgs = with pkgs.localLispPackages; [ + arrows + backplane-dns + backplane-server + cl-sasl + cl-xmpp + ip-utils + + alexandria + babel + bordeaux-threads + cffi + cl-base64 + cl-json + cl-postgres + cl-ppcre + cl-unicode + cl_plus_ssl + closer-mop + closure-common + cxml + flexi-streams + global-vars + introspect-environment + ironclad + iterate + lisp-namespace + md5 + nibbles + postmodern + puri + s-sql + split-sequence + trivia + trivia_dot_balland2006 + trivia_dot_level0 + trivia_dot_level1 + trivia_dot_level2 + trivia_dot_trivial + trivial-cltl2 + trivial-features + trivial-garbage + trivial-gray-streams + type-i + uax-15 + usocket + ]; + backup-directory = "/var/lib/fudo/backplane/dns"; powerdns-home = "/var/lib/powerdns"; @@ -32,6 +80,12 @@ let type = with types; submodule databaseOpts; description = "Database settings for backplane server."; }; + + cl-wrapper-package = mkOption { + type = types.package; + description = "Common Lisp wrapper package to use."; + default = pkgs.lispPackages.clwrapper; + }; }; }; @@ -61,15 +115,6 @@ let }; }; - lisp-libs = []; - - launchScript = pkgs.writeText "launch-backplane-dns.lisp" '' - (load (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname))) - (ql:quickload :backplane-dns) - (backplane-dns:start-listener-with-env) - (loop (sleep 600)) - ''; - in { options.fudo.backplane.dns = { enable = mkEnableOption "Enable backplane dynamic DNS server."; @@ -251,8 +296,7 @@ in { restartIfChanged = true; serviceConfig = { - ExecStartPre = "${pkgs.lispPackages.quicklisp}/bin/quicklisp init"; - ExecStart = "${pkgs.sbcl}/bin/sbcl --load ${launchScript}"; + ExecStart = "${pkgs.backplane-dns-server}/bin/launch-backplane-dns.sh"; Restart = "on-failure"; PIDFile = "/run/backplane-dns.$USERNAME.pid"; User = cfg.user; @@ -260,7 +304,7 @@ in { }; environment = { - LD_LIBRARY_PATH = "${pkgs.openssl_1_1.out}/lib"; + # LD_LIBRARY_PATH = "${pkgs.openssl_1_1.out}/lib"; FUDO_DNS_BACKPLANE_XMPP_HOSTNAME = cfg.backplane.host; FUDO_DNS_BACKPLANE_XMPP_USERNAME = cfg.backplane.role; @@ -270,8 +314,10 @@ in { FUDO_DNS_BACKPLANE_DATABASE_USERNAME = cfg.backplane.database.username; FUDO_DNS_BACKPLANE_DATABASE_PASSWORD_FILE = cfg.backplane.database.password-file; + # CL_SOURCE_REGISTRY = "${pkgs.localLispPackages.backplane-dns}//"; + CL_SOURCE_REGISTRY = lib.concatStringsSep ":" (map (pkg: "${pkg}//") - (lisp-libs ++ [pkgs.backplane-dns])); + lisp-pkgs); }; requires = cfg.required-services; diff --git a/packages/backplane-dns-server.nix b/packages/backplane-dns-server.nix new file mode 100644 index 0000000..a040d5f --- /dev/null +++ b/packages/backplane-dns-server.nix @@ -0,0 +1,33 @@ +{ pkgs, localLispPackages, ... }: + +with pkgs.lib; +let + launcher = pkgs.writeText "launch-backplane-dns.lisp" '' + (require :asdf) + (asdf:load-system :backplane-dns) + (backplane-dns:start-listener-with-env) + (loop (sleep 600)) + ''; + + launcherScript = pkgs.writeShellScriptBin "launch-backplane-dns.sh" '' + ${pkgs.lispPackages.clwrapper}/bin/common-lisp.sh --load ${launcher} + ''; + +in pkgs.stdenv.mkDerivation { + pname = "backplane-dns-server"; + version = "0.1.0"; + + propagatedBuildInputs = with pkgs; [ + asdf + sbcl + lispPackages.clwrapper + localLispPackages.backplane-dns + ]; + + phases = [ "installPhase" ]; + + installPhase = '' + mkdir -p "$out/bin" + cp ${launcherScript}/bin/launch-backplane-dns.sh "$out/bin" + ''; +} diff --git a/packages/local.nix b/packages/local.nix index b392b06..fe7339a 100644 --- a/packages/local.nix +++ b/packages/local.nix @@ -65,11 +65,11 @@ in { inherit (pkgs) stdenv fetchurl makeWrapper cups dpkg a2ps ghostscript gnugrep gnused coreutils file perl which; }; - backplane-dns = import ./backplane-dns.nix { - pkgs = pkgs; - stdenv = pkgs.stdenv; - fetchgit = pkgs.fetchgit; - }; + # backplane-dns = import ./backplane-dns.nix { + # pkgs = pkgs; + # stdenv = pkgs.stdenv; + # fetchgit = pkgs.fetchgit; + # }; backplane-dns-client = import ./backplane-dns-client.nix { pkgs = pkgs; @@ -112,9 +112,14 @@ in { }; }; - localLispPackages = import ./lisp { + localLispPackages = (import ./lisp { inherit lib; pkgs = unstablePkgs; + }) // unstablePkgs.lispPackages; + + backplane-dns-server = import ./backplane-dns-server.nix { + inherit localLispPackages; + pkgs = unstablePkgs; }; }; }