150 lines
4.4 KiB
Nix
150 lines
4.4 KiB
Nix
|
{ pkgs, config, ... }:
|
||
|
let
|
||
|
ikiwikiBootstrapTheme = pkgs.fetchgit {
|
||
|
url = "https://github.com/dequis/ikiwiki-bootstrap-theme.git";
|
||
|
rev = "afaedf8460d03664be6f590cf632b8be05de77dc";
|
||
|
hash = "sha256-iX/onqrsvzJdDrJ7WoQMnlAQtOA+rmi+esv25/IOsq8=";
|
||
|
}; # TODO: fork and set link color to #6d2bff or something
|
||
|
ikiwikiDataPath = "/mnt/data/ikiwiki";
|
||
|
ikiwikiSettingsHeader = pkgs.writeText "ikiwiki-settings-header" ''
|
||
|
# IkiWiki::Setup::Yaml - YAML formatted setup file
|
||
|
'';
|
||
|
ikiwikiSettings = {
|
||
|
wikiname = "fi-zone";
|
||
|
adminemail = "fi@ikiwiki.vs.grzb.de";
|
||
|
adminuser = [
|
||
|
"fi"
|
||
|
];
|
||
|
banned_users = [];
|
||
|
srcdir = "${ikiwikiDataPath}/fi-zone";
|
||
|
destdir = "${ikiwikiDataPath}/public_html/fi-zone";
|
||
|
url = "https://fi.nekover.se/";
|
||
|
cgiurl = "https://fi.nekover.se/ikiwiki.cgi";
|
||
|
reverse_proxy = 0;
|
||
|
cgi_wrapper = "${ikiwikiDataPath}/public_html/fi-zone/ikiwiki.cgi";
|
||
|
cgi_wrappermode = "06755";
|
||
|
cgi_overload_delay = "";
|
||
|
cgi_overload_message = "";
|
||
|
only_committed_changes = 0;
|
||
|
rcs = "";
|
||
|
add_plugins = [
|
||
|
"goodstuff"
|
||
|
"websetup"
|
||
|
];
|
||
|
disable_plugins = [];
|
||
|
templatedir = "${ikiwikiBootstrapTheme}";
|
||
|
underlaydir = "${pkgs.ikiwiki-full}/share/ikiwiki/basewiki";
|
||
|
usedirs = 1;
|
||
|
prefix_directives = 1;
|
||
|
indexpages = 0;
|
||
|
discussion = 0;
|
||
|
html5 = 1;
|
||
|
sslcookie = 1;
|
||
|
default_pageext = "mdwn";
|
||
|
htmlext = "html";
|
||
|
timeformat = "%c";
|
||
|
userdir = "";
|
||
|
numbacklinks = 10;
|
||
|
hardlink = 0;
|
||
|
libdirs = [];
|
||
|
libdir = "${ikiwikiDataPath}/.ikiwiki";
|
||
|
ENV = {};
|
||
|
timezone = ":/etc/localtime";
|
||
|
wiki_file_chars = "-[:alnum:]+/.:_";
|
||
|
allow_symlinks_before_srcdir = 0;
|
||
|
cookiejar = {
|
||
|
file = "${ikiwikiDataPath}/.ikiwiki/cookies";
|
||
|
};
|
||
|
useragent = "ikiwiki/${pkgs.ikiwiki-full.version}";
|
||
|
responsive_layout = 1;
|
||
|
deterministic = 0;
|
||
|
rss = 1;
|
||
|
atom = 1;
|
||
|
blogspam_pagespec = "postcomment(*)";
|
||
|
locked_pages = "* and !postcomment(*)";
|
||
|
comments_pagespec = "posts/* and !*/Discussion";
|
||
|
archive_pagespec = "page(posts/*) and !*/Discussion";
|
||
|
global_sidebars = 0;
|
||
|
tagbase = "tags";
|
||
|
};
|
||
|
ikiwikiSettingsFile = pkgs.concatText "fi-zone.setup" [
|
||
|
ikiwikiSettingsHeader
|
||
|
((pkgs.formats.yaml { }).generate "fi-zone-settings" ikiwikiSettings)
|
||
|
];
|
||
|
ikiwikiSetupAutomator = pkgs.writeScript "fi-zone.initial.setup" ''
|
||
|
#!${pkgs.perl}/bin/perl
|
||
|
require IkiWiki::Setup::Automator;
|
||
|
IkiWiki::Setup::Automator->import(
|
||
|
wikiname => '${ikiwikiSettings.wikiname}',
|
||
|
adminuser => ['fi'],
|
||
|
srcdir => '${ikiwikiSettings.srcdir}',
|
||
|
destdir => '${ikiwikiSettings.destdir}',
|
||
|
dumpsetup => '${ikiwikiSettings.wikiname}.setup',
|
||
|
url => '${ikiwikiSettings.url}',
|
||
|
cgiurl => '${ikiwikiSettings.cgiurl}',
|
||
|
cgi_wrapper => '${ikiwikiSettings.cgi_wrapper}',
|
||
|
adminemail => '${ikiwikiSettings.adminemail}',
|
||
|
add_plugins => [qw{goodstuff websetup}],
|
||
|
disable_plugins => [qw{}],
|
||
|
libdir => '${ikiwikiSettings.libdir}',
|
||
|
rss => 1,
|
||
|
atom => 1,
|
||
|
syslog => 1,
|
||
|
)
|
||
|
'';
|
||
|
in
|
||
|
{
|
||
|
environment.systemPackages = with pkgs; [
|
||
|
ikiwiki-full
|
||
|
];
|
||
|
|
||
|
services.fcgiwrap.instances."ikiwiki" = {
|
||
|
socket = {
|
||
|
user = config.services.nginx.user;
|
||
|
group = config.services.nginx.group;
|
||
|
};
|
||
|
process = {
|
||
|
user = config.services.nginx.user;
|
||
|
group = config.services.nginx.group;
|
||
|
};
|
||
|
};
|
||
|
|
||
|
systemd.services.ikiwiki-initial-setup = {
|
||
|
description = "Run the initial setup of ikiwiki and set permissions.";
|
||
|
|
||
|
script = ''
|
||
|
mkdir -p ${ikiwikiDataPath}
|
||
|
chown ${config.services.nginx.user}:${config.services.nginx.group} ${ikiwikiDataPath}
|
||
|
if [ ! -d "${ikiwikiSettings.srcdir}" ]; then
|
||
|
${pkgs.sudo}/bin/sudo -u ${config.services.nginx.user} ${pkgs.ikiwiki-full}/bin/ikiwiki --setup ${ikiwikiSetupAutomator}
|
||
|
fi
|
||
|
'';
|
||
|
|
||
|
serviceConfig = {
|
||
|
Type = "simple";
|
||
|
User = "root";
|
||
|
Group = "root";
|
||
|
};
|
||
|
|
||
|
wantedBy = [
|
||
|
"multi-user.target"
|
||
|
];
|
||
|
};
|
||
|
|
||
|
systemd.services.ikiwiki-settings-setup = {
|
||
|
description = "Setup ikiwiki with configuration managed by NixOS.";
|
||
|
|
||
|
serviceConfig = {
|
||
|
Type = "simple";
|
||
|
ExecStart = "${pkgs.ikiwiki-full}/bin/ikiwiki --setup ${ikiwikiSettingsFile}";
|
||
|
User = config.services.nginx.user;
|
||
|
Group = config.services.nginx.group;
|
||
|
Requires = [ "ikiwiki-initial-setup.service" ];
|
||
|
};
|
||
|
|
||
|
wantedBy = [
|
||
|
"multi-user.target"
|
||
|
];
|
||
|
};
|
||
|
}
|