Dokuwiki

From NixOS Wiki
Revision as of 18:52, 21 October 2022 by imported>Fadenb (→‎Templates: typo fix)

DokuWiki is a web application and simple Wiki software for creating documentation and editable pages in markdown language. Compared to other Wikis, it is more minimal and only depends on PHP and file access without any need for databases.

Installation

To setup DokuWiki locally, this is the most minimal configuration to get started

 
/etc/nixos/configuration.nix
services.dokuwiki.sites."localhost" = {
  enable = true;
  extraConfig = ''
    $conf['title'] = 'My Wiki';
  '';
};

After that DokuWiki will be available at http://localhost .

Configuration

Besides several options which are exposed by the DokuWiki module in NixOS, you can also use extraConfig to add custom options to your DokuWiki configuration. See the upstream documentation for available options.

Templates

Unfortunately no templates are packaged yet in nixpkgs. It is possible to manually package a template, for example from the official template repository, and include it in your Dokuwiki instance. In the following example the template mindthedark is packaged and enabled

 
/etc/nixos/configuration.nix
let

  dokuwiki-template-mindthedark = pkgs.stdenv.mkDerivation {
    name = "mindthedark";
    src = pkgs.fetchurl {
      url = "https://github.com/MrReSc/MindTheDark/archive/2021-12-24.zip";
      sha256 = "12qwd8cz4ay4lzp69ra5cmpssqwav6nxn767l43s86ja2b7m7zia";
    };
    buildInputs = [ pkgs.unzip ];
    installPhase = "mkdir -p $out; cp -R * $out/";
  };

in {
  services.dokuwiki.sites."localhost" = {
    templates = [ dokuwiki-template-mindthedark ];
    extraConfig = ''
      $conf['template'] = "mindthedark";
    '';
  };
};

Please note that you'll have to manually update the tempalte source and checksum in case there's a new version.

Clean URLs

If supported by the webserver you've choosen (using the webserver option), you can enable clean urls or url rewriting by enabling the option userewrite. This means you can access your sites with the simple URL scheme like http://localhost/my_project .

 
/etc/nixos/configuration.nix
services.dokuwiki.sites."localhost".extraConfig = ''
  $conf['userewrite'] = 1;
'';
};

Clean URLs are reported to work with the webserver Caddy.

Anonymous editing

To disable the user authentication completely and make the Wiki editable by anyone (even anonymous users), you can disable the config useacl with the following option

 
/etc/nixos/configuration.nix
services.dokuwiki.sites."localhost".aclUse = false;

Tips and tricks

SSL behind reverse proxy

In case you're running DokuWiki behind a reverse proxy which offers ssl/https to the outside, you might have to enforce https protocol by changing the baseurl

 
/etc/nixos/configuration.nix
services.dokuwiki.sites."localhost".extraConfig = ''
  $conf['baseurl'] = 'https://example.org';
'';
};