Allow psotgresql database to be switched
This commit is contained in:
parent
93bc54ec67
commit
2720ce9be9
|
@ -226,7 +226,8 @@ in {
|
|||
cp -f ${props-file} ${stateDir}/server.properties
|
||||
cp -f ${eula-file} ${stateDir}/eula.txt
|
||||
mkdir -p ${stateDir}/plugins
|
||||
cp -f ${witchcraft-plugin} ${stateDir}/plugins/witchcraft-plugin.jar
|
||||
# Version not working...
|
||||
# cp -f ${witchcraft-plugin} ${stateDir}/plugins/witchcraft-plugin.jar
|
||||
chmod u+w ${stateDir}/server.properties
|
||||
'';
|
||||
|
||||
|
|
|
@ -151,6 +151,12 @@ in {
|
|||
options.fudo.postgresql = with types; {
|
||||
enable = mkEnableOption "Fudo PostgreSQL Server";
|
||||
|
||||
package = mkOption {
|
||||
type = package;
|
||||
description = "Which package to use for Postgresql server.";
|
||||
default = pkgs.postgresql_11_gssapi;
|
||||
};
|
||||
|
||||
ssl-private-key = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Location of the server SSL private key.";
|
||||
|
@ -247,7 +253,7 @@ in {
|
|||
|
||||
networking.firewall.allowedTCPPorts = [ 5432 ];
|
||||
|
||||
environment.systemPackages = with pkgs; [ postgresql_11_gssapi ];
|
||||
environment.systemPackages = with pkgs; [ cfg.package ];
|
||||
|
||||
users.groups = {
|
||||
${cfg.socket-group} = { members = [ "postgres" ] ++ cfg.local-users; };
|
||||
|
@ -255,7 +261,7 @@ in {
|
|||
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
package = pkgs.postgresql_11_gssapi;
|
||||
package = cfg.package;
|
||||
enableTCPIP = true;
|
||||
ensureDatabases = mapAttrsToList (name: value: name) cfg.databases;
|
||||
ensureUsers = ((mapAttrsToList (username: attrs: {
|
||||
|
|
|
@ -4,11 +4,13 @@ with lib;
|
|||
let
|
||||
cfg = config.informis.cl-gemini;
|
||||
|
||||
feedOpts = { ... }: with types; {
|
||||
feedOpts = { ... }:
|
||||
with types; {
|
||||
options = {
|
||||
url = mkOption {
|
||||
type = str;
|
||||
description = "Base URI of the feed, i.e. the URI corresponding to the feed path.";
|
||||
description =
|
||||
"Base URI of the feed, i.e. the URI corresponding to the feed path.";
|
||||
example = "gemini://my.server/path/to/feedfiles";
|
||||
};
|
||||
|
||||
|
@ -26,7 +28,8 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
ensure-certificates = hostname: user: key: cert: pkgs.writeShellScript "ensure-gemini-certificates.sh" ''
|
||||
ensure-certificates = hostname: user: key: cert:
|
||||
pkgs.writeShellScript "ensure-gemini-certificates.sh" ''
|
||||
if [[ ! -e ${key} ]]; then
|
||||
TARGET_CERT_DIR=$(${pkgs.coreutils}/bin/dirname ${cert})
|
||||
TARGET_KEY_DIR=$(${pkgs.coreutils}/bin/dirname ${key})
|
||||
|
@ -43,8 +46,11 @@ let
|
|||
generate-feeds = feeds:
|
||||
let
|
||||
feed-strings = mapAttrsToList (feed-name: opts:
|
||||
"(cl-gemini:register-feed :name \"${feed-name}\" :title \"${opts.title}\" :path \"${opts.path}\" :base-uri \"${opts.url}\")") feeds;
|
||||
in pkgs.writeText "gemini-local-feeds.lisp" (concatStringsSep "\n" feed-strings);
|
||||
''
|
||||
(cl-gemini:register-feed :name "${feed-name}" :title "${opts.title}" :path "${opts.path}" :base-uri "${opts.url}")'')
|
||||
feeds;
|
||||
in pkgs.writeText "gemini-local-feeds.lisp"
|
||||
(concatStringsSep "\n" feed-strings);
|
||||
|
||||
in {
|
||||
options.informis.cl-gemini = with types; {
|
||||
|
@ -58,7 +64,8 @@ in {
|
|||
|
||||
hostname = mkOption {
|
||||
type = str;
|
||||
description = "Hostname at which the server is available (for generating the SSL certificate).";
|
||||
description =
|
||||
"Hostname at which the server is available (for generating the SSL certificate).";
|
||||
example = "my.hostname.com";
|
||||
};
|
||||
|
||||
|
@ -108,7 +115,8 @@ in {
|
|||
|
||||
feeds = mkOption {
|
||||
type = attrsOf (submodule feedOpts);
|
||||
description = "Feeds to generate and make available (as eg. /feed/name.xml).";
|
||||
description =
|
||||
"Feeds to generate and make available (as eg. /feed/name.xml).";
|
||||
example = {
|
||||
diary = {
|
||||
title = "My Diary";
|
||||
|
@ -141,10 +149,13 @@ in {
|
|||
|
||||
systemd.services = {
|
||||
cl-gemini = {
|
||||
description = "cl-gemini Gemini server (https://gemini.circumlunar.space/)";
|
||||
description =
|
||||
"cl-gemini Gemini server (https://gemini.circumlunar.space/)";
|
||||
|
||||
serviceConfig = {
|
||||
ExecStartPre = "${ensure-certificates cfg.hostname cfg.user cfg.ssl-private-key cfg.ssl-certificate}";
|
||||
ExecStartPre =
|
||||
"${ensure-certificates cfg.hostname cfg.user cfg.ssl-private-key
|
||||
cfg.ssl-certificate}";
|
||||
ExecStart = "${pkgs.cl-gemini}/bin/launch-server.sh";
|
||||
Restart = "on-failure";
|
||||
PIDFile = "/run/cl-gemini.$USERNAME.uid";
|
||||
|
@ -152,7 +163,8 @@ in {
|
|||
};
|
||||
|
||||
environment = {
|
||||
GEMINI_SLYNK_PORT = mkIf (cfg.slynk-port != null) (toString cfg.slynk-port);
|
||||
GEMINI_SLYNK_PORT =
|
||||
mkIf (cfg.slynk-port != null) (toString cfg.slynk-port);
|
||||
GEMINI_LISTEN_IP = cfg.server-ip;
|
||||
GEMINI_PRIVATE_KEY = cfg.ssl-private-key;
|
||||
GEMINI_CERTIFICATE = cfg.ssl-certificate;
|
||||
|
@ -161,14 +173,11 @@ in {
|
|||
GEMINI_TEXTFILES_ROOT = cfg.textfiles-archive;
|
||||
GEMINI_FEEDS = "${generate-feeds cfg.feeds}";
|
||||
|
||||
CL_SOURCE_REGISTRY = pkgs.lib.lisp.lisp-source-registry pkgs.cl-gemini;
|
||||
CL_SOURCE_REGISTRY =
|
||||
pkgs.lib.lisp.lisp-source-registry pkgs.cl-gemini;
|
||||
};
|
||||
|
||||
path = with pkgs; [
|
||||
gcc
|
||||
file
|
||||
getent
|
||||
];
|
||||
path = with pkgs; [ gcc file getent ];
|
||||
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue