Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose sitemap #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions modules/nixos-wiki/backup.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@
let
wikiDump = "/var/lib/mediawiki/backup/wikidump.xml.zst";

mediawiki-maintenance = pkgs.runCommand "mediawiki-maintenance"
{
nativeBuildInputs = [ pkgs.makeWrapper ];
preferLocalBuild = true;
} ''
mkdir -p $out/bin
makeWrapper ${config.services.phpfpm.pools.mediawiki.phpPackage}/bin/php $out/bin/mediawiki-maintenance \
--set MEDIAWIKI_CONFIG ${config.services.phpfpm.pools.mediawiki.phpEnv.MEDIAWIKI_CONFIG} \
--add-flags ${config.services.mediawiki.finalPackage}/share/mediawiki/maintenance/run.php
'';
mediawiki-maintenance = pkgs.callPackage ./mediawiki-maintenance.nix {
inherit config;
};

wiki-backup = pkgs.writeShellApplication
{
Expand Down
18 changes: 18 additions & 0 deletions modules/nixos-wiki/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{ config, pkgs, lib, ... }:
let
cfg = config.services.nixos-wiki;

mediawiki-maintenance = pkgs.callPackage ./mediawiki-maintenance.nix {
inherit config;
};
in
{
options = {
Expand Down Expand Up @@ -162,6 +166,20 @@ in
locations."=/nixos.png".alias = ./nixos.png;
locations."=/favicon.ico".alias = ./favicon.ico;
locations."=/robots.txt".alias = ./robots.txt;
locations."/sitemap/".alias = "/var/lib/mediawiki-sitemap/";
};
};

systemd.tmpfiles.rules = [
"d 'var/lib/mediawiki-sitemap' 0750 mediawiki ${config.services.nginx.group} - -"
];

systemd.services.wiki-sitemap = {
startAt = "daily";
serviceConfig = {
ExecStart = "${mediawiki-maintenance}/bin/mediawiki-maintenance generateSitemap.php --fspath /var/lib/mediawiki-sitemap/ --server http://${config.services.nixos-wiki.hostname} --urlpath sitemap/";
User = "mediawiki";
Type = "oneshot";
};
};
}
16 changes: 16 additions & 0 deletions modules/nixos-wiki/mediawiki-maintenance.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
runCommand,
makeWrapper,
config,
}:
runCommand "mediawiki-maintenance"
{
nativeBuildInputs = [ makeWrapper ];
preferLocalBuild = true;
}
''
mkdir -p $out/bin
makeWrapper ${config.services.phpfpm.pools.mediawiki.phpPackage}/bin/php $out/bin/mediawiki-maintenance \
--set MEDIAWIKI_CONFIG ${config.services.phpfpm.pools.mediawiki.phpEnv.MEDIAWIKI_CONFIG} \
--add-flags ${config.services.mediawiki.finalPackage}/share/mediawiki/maintenance/run.php
''