diff --git a/config/hosts/ikiwiki/configuration.nix b/config/hosts/ikiwiki/configuration.nix new file mode 100644 index 0000000..632c401 --- /dev/null +++ b/config/hosts/ikiwiki/configuration.nix @@ -0,0 +1,27 @@ +{ ... }: +{ + boot.loader.grub = { + enable = true; + device = "/dev/vda"; + }; + + networking = { + hostName = "ikiwiki"; + firewall = { + enable = true; + allowedTCPPorts = [ 80 8443 ]; + }; + }; + + fileSystems = { + # partition data disk with `sudo mkfs.ext4 /dev/vdx` + # label data disk with `e2label /dev/vdx "data"` + "/mnt/data" = { + device = "/dev/disk/by-label/data"; + fsType = "ext4"; + autoResize = true; + }; + }; + + system.stateVersion = "24.05"; +} diff --git a/config/hosts/ikiwiki/default.nix b/config/hosts/ikiwiki/default.nix new file mode 100644 index 0000000..bc9766c --- /dev/null +++ b/config/hosts/ikiwiki/default.nix @@ -0,0 +1,8 @@ +{ ... }: +{ + imports = [ + ./configuration.nix + ./ikiwiki.nix + ./nginx.nix + ]; +} diff --git a/config/hosts/ikiwiki/ikiwiki.nix b/config/hosts/ikiwiki/ikiwiki.nix new file mode 100644 index 0000000..dff935c --- /dev/null +++ b/config/hosts/ikiwiki/ikiwiki.nix @@ -0,0 +1,149 @@ +{ 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" + ]; + }; +} diff --git a/config/hosts/ikiwiki/nginx.nix b/config/hosts/ikiwiki/nginx.nix new file mode 100644 index 0000000..c3e0760 --- /dev/null +++ b/config/hosts/ikiwiki/nginx.nix @@ -0,0 +1,45 @@ +{ pkgs, config, ... }: +let + ikiwikiDataPath = "/mnt/data/ikiwiki"; +in +{ + services.nginx = { + enable = true; + virtualHosts."fi.nekover.se" = { + forceSSL = true; + enableACME = true; + listen = [ + { + addr = "0.0.0.0"; + port = 80; + } + { + addr = "0.0.0.0"; + port = 8443; + ssl = true; + extraParameters = [ "proxy_protocol" ]; + } + ]; + root = "${ikiwikiDataPath}/public_html/fi-zone"; + locations = { + "/" = { + tryFiles = "$uri $uri/ =404"; + }; + "~ .cgi" = { + extraConfig = '' + gzip off; + fastcgi_pass unix:${config.services.fcgiwrap.instances."ikiwiki".socket.address}; + fastcgi_index ikiwiki.cgi; + fastcgi_param SCRIPT_FILENAME ${ikiwikiDataPath}/public_html/fi-zone/ikiwiki.cgi; + fastcgi_param DOCUMENT_ROOT ${ikiwikiDataPath}/public_html/fi-zone; + include ${pkgs.nginx}/conf/fastcgi_params; + ''; + }; + }; + extraConfig = '' + set_real_ip_from 10.202.41.100; + real_ip_header proxy_protocol; + ''; + }; + }; +} diff --git a/config/hosts/web-public-2/nginx.nix b/config/hosts/web-public-2/nginx.nix index 8debb31..1f14695 100644 --- a/config/hosts/web-public-2/nginx.nix +++ b/config/hosts/web-public-2/nginx.nix @@ -20,6 +20,7 @@ birdsite.nekover.se 10.202.41.107:8443; cloud.nekover.se 10.202.41.122:8443; element.nekover.se 127.0.0.1:8443; + fi.nekover.se 10.202.41.125:8443; gameserver.grzb.de 127.0.0.1:8443; git.grzb.de 127.0.0.1:8443; git.nekover.se 10.202.41.106:8443; diff --git a/config/hosts/web-public-2/virtualHosts/acme-challenge.nix b/config/hosts/web-public-2/virtualHosts/acme-challenge.nix index 558aa95..59b9d3a 100644 --- a/config/hosts/web-public-2/virtualHosts/acme-challenge.nix +++ b/config/hosts/web-public-2/virtualHosts/acme-challenge.nix @@ -7,6 +7,7 @@ let "netbox.grzb.de" = "netbox.vs.grzb.de"; "git.nekover.se" = "forgejo.vs.grzb.de"; "grafana.grzb.de" = "metrics.vs.grzb.de"; + "fi.nekover.se" = "ikiwiki.vs.grzb.de"; "jackett.grzb.de" = "torrent.vs.grzb.de"; "jellyseerr.grzb.de" = "jellyseerr.vs.grzb.de"; "keycloak-admin.nekover.se" = "keycloak.vs.grzb.de"; diff --git a/hosts.nix b/hosts.nix index 363f377..4515394 100644 --- a/hosts.nix +++ b/hosts.nix @@ -26,13 +26,14 @@ let }) hosts; in generateDefaults { - #fee = { - # site = "wg"; - #}; hydra = { site = "vs"; environment = "proxmox"; }; + ikiwiki = { + site = "vs"; + environment = "proxmox"; + }; iperf = { site = "vs"; environment = "proxmox";