Closer to 'correct' backplane-dns-server

This commit is contained in:
root 2020-11-27 11:36:10 -06:00
parent 96da822c5a
commit f442ea729c
3 changed files with 103 additions and 19 deletions

View File

@ -4,6 +4,54 @@ with lib;
let let
cfg = config.fudo.backplane.dns; 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"; backup-directory = "/var/lib/fudo/backplane/dns";
powerdns-home = "/var/lib/powerdns"; powerdns-home = "/var/lib/powerdns";
@ -32,6 +80,12 @@ let
type = with types; submodule databaseOpts; type = with types; submodule databaseOpts;
description = "Database settings for backplane server."; 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 { in {
options.fudo.backplane.dns = { options.fudo.backplane.dns = {
enable = mkEnableOption "Enable backplane dynamic DNS server."; enable = mkEnableOption "Enable backplane dynamic DNS server.";
@ -251,8 +296,7 @@ in {
restartIfChanged = true; restartIfChanged = true;
serviceConfig = { serviceConfig = {
ExecStartPre = "${pkgs.lispPackages.quicklisp}/bin/quicklisp init"; ExecStart = "${pkgs.backplane-dns-server}/bin/launch-backplane-dns.sh";
ExecStart = "${pkgs.sbcl}/bin/sbcl --load ${launchScript}";
Restart = "on-failure"; Restart = "on-failure";
PIDFile = "/run/backplane-dns.$USERNAME.pid"; PIDFile = "/run/backplane-dns.$USERNAME.pid";
User = cfg.user; User = cfg.user;
@ -260,7 +304,7 @@ in {
}; };
environment = { 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_HOSTNAME = cfg.backplane.host;
FUDO_DNS_BACKPLANE_XMPP_USERNAME = cfg.backplane.role; 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_USERNAME = cfg.backplane.database.username;
FUDO_DNS_BACKPLANE_DATABASE_PASSWORD_FILE = cfg.backplane.database.password-file; 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}//") CL_SOURCE_REGISTRY = lib.concatStringsSep ":" (map (pkg: "${pkg}//")
(lisp-libs ++ [pkgs.backplane-dns])); lisp-pkgs);
}; };
requires = cfg.required-services; requires = cfg.required-services;

View File

@ -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"
'';
}

View File

@ -65,11 +65,11 @@ in {
inherit (pkgs) stdenv fetchurl makeWrapper cups dpkg a2ps ghostscript gnugrep gnused coreutils file perl which; inherit (pkgs) stdenv fetchurl makeWrapper cups dpkg a2ps ghostscript gnugrep gnused coreutils file perl which;
}; };
backplane-dns = import ./backplane-dns.nix { # backplane-dns = import ./backplane-dns.nix {
pkgs = pkgs; # pkgs = pkgs;
stdenv = pkgs.stdenv; # stdenv = pkgs.stdenv;
fetchgit = pkgs.fetchgit; # fetchgit = pkgs.fetchgit;
}; # };
backplane-dns-client = import ./backplane-dns-client.nix { backplane-dns-client = import ./backplane-dns-client.nix {
pkgs = pkgs; pkgs = pkgs;
@ -112,9 +112,14 @@ in {
}; };
}; };
localLispPackages = import ./lisp { localLispPackages = (import ./lisp {
inherit lib; inherit lib;
pkgs = unstablePkgs; pkgs = unstablePkgs;
}) // unstablePkgs.lispPackages;
backplane-dns-server = import ./backplane-dns-server.nix {
inherit localLispPackages;
pkgs = unstablePkgs;
}; };
}; };
} }