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 ${props-file} ${stateDir}/server.properties
|
||||||
cp -f ${eula-file} ${stateDir}/eula.txt
|
cp -f ${eula-file} ${stateDir}/eula.txt
|
||||||
mkdir -p ${stateDir}/plugins
|
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
|
chmod u+w ${stateDir}/server.properties
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,12 @@ in {
|
||||||
options.fudo.postgresql = with types; {
|
options.fudo.postgresql = with types; {
|
||||||
enable = mkEnableOption "Fudo PostgreSQL Server";
|
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 {
|
ssl-private-key = mkOption {
|
||||||
type = nullOr str;
|
type = nullOr str;
|
||||||
description = "Location of the server SSL private key.";
|
description = "Location of the server SSL private key.";
|
||||||
|
@ -247,7 +253,7 @@ in {
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [ 5432 ];
|
networking.firewall.allowedTCPPorts = [ 5432 ];
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [ postgresql_11_gssapi ];
|
environment.systemPackages = with pkgs; [ cfg.package ];
|
||||||
|
|
||||||
users.groups = {
|
users.groups = {
|
||||||
${cfg.socket-group} = { members = [ "postgres" ] ++ cfg.local-users; };
|
${cfg.socket-group} = { members = [ "postgres" ] ++ cfg.local-users; };
|
||||||
|
@ -255,7 +261,7 @@ in {
|
||||||
|
|
||||||
services.postgresql = {
|
services.postgresql = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.postgresql_11_gssapi;
|
package = cfg.package;
|
||||||
enableTCPIP = true;
|
enableTCPIP = true;
|
||||||
ensureDatabases = mapAttrsToList (name: value: name) cfg.databases;
|
ensureDatabases = mapAttrsToList (name: value: name) cfg.databases;
|
||||||
ensureUsers = ((mapAttrsToList (username: attrs: {
|
ensureUsers = ((mapAttrsToList (username: attrs: {
|
||||||
|
|
|
@ -4,11 +4,13 @@ with lib;
|
||||||
let
|
let
|
||||||
cfg = config.informis.cl-gemini;
|
cfg = config.informis.cl-gemini;
|
||||||
|
|
||||||
feedOpts = { ... }: with types; {
|
feedOpts = { ... }:
|
||||||
|
with types; {
|
||||||
options = {
|
options = {
|
||||||
url = mkOption {
|
url = mkOption {
|
||||||
type = str;
|
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";
|
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
|
if [[ ! -e ${key} ]]; then
|
||||||
TARGET_CERT_DIR=$(${pkgs.coreutils}/bin/dirname ${cert})
|
TARGET_CERT_DIR=$(${pkgs.coreutils}/bin/dirname ${cert})
|
||||||
TARGET_KEY_DIR=$(${pkgs.coreutils}/bin/dirname ${key})
|
TARGET_KEY_DIR=$(${pkgs.coreutils}/bin/dirname ${key})
|
||||||
|
@ -43,8 +46,11 @@ let
|
||||||
generate-feeds = feeds:
|
generate-feeds = feeds:
|
||||||
let
|
let
|
||||||
feed-strings = mapAttrsToList (feed-name: opts:
|
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 {
|
in {
|
||||||
options.informis.cl-gemini = with types; {
|
options.informis.cl-gemini = with types; {
|
||||||
|
@ -58,7 +64,8 @@ in {
|
||||||
|
|
||||||
hostname = mkOption {
|
hostname = mkOption {
|
||||||
type = str;
|
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";
|
example = "my.hostname.com";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -108,7 +115,8 @@ in {
|
||||||
|
|
||||||
feeds = mkOption {
|
feeds = mkOption {
|
||||||
type = attrsOf (submodule feedOpts);
|
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 = {
|
example = {
|
||||||
diary = {
|
diary = {
|
||||||
title = "My Diary";
|
title = "My Diary";
|
||||||
|
@ -141,10 +149,13 @@ in {
|
||||||
|
|
||||||
systemd.services = {
|
systemd.services = {
|
||||||
cl-gemini = {
|
cl-gemini = {
|
||||||
description = "cl-gemini Gemini server (https://gemini.circumlunar.space/)";
|
description =
|
||||||
|
"cl-gemini Gemini server (https://gemini.circumlunar.space/)";
|
||||||
|
|
||||||
serviceConfig = {
|
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";
|
ExecStart = "${pkgs.cl-gemini}/bin/launch-server.sh";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
PIDFile = "/run/cl-gemini.$USERNAME.uid";
|
PIDFile = "/run/cl-gemini.$USERNAME.uid";
|
||||||
|
@ -152,7 +163,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
environment = {
|
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_LISTEN_IP = cfg.server-ip;
|
||||||
GEMINI_PRIVATE_KEY = cfg.ssl-private-key;
|
GEMINI_PRIVATE_KEY = cfg.ssl-private-key;
|
||||||
GEMINI_CERTIFICATE = cfg.ssl-certificate;
|
GEMINI_CERTIFICATE = cfg.ssl-certificate;
|
||||||
|
@ -161,14 +173,11 @@ in {
|
||||||
GEMINI_TEXTFILES_ROOT = cfg.textfiles-archive;
|
GEMINI_TEXTFILES_ROOT = cfg.textfiles-archive;
|
||||||
GEMINI_FEEDS = "${generate-feeds cfg.feeds}";
|
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; [
|
path = with pkgs; [ gcc file getent ];
|
||||||
gcc
|
|
||||||
file
|
|
||||||
getent
|
|
||||||
];
|
|
||||||
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue