Merge pull request #209316 from e1mo/dokuwiki/housekeeping

nixosTests.dokuwiki: Deduplicate node configuration

authored by

Jonas Heinrich and committed by
GitHub
059e0f89 8552d36e

+82 -85
+18 -24
nixos/modules/services/web-apps/dokuwiki.nix
··· 180 180 ''; 181 181 example = literalExpression '' 182 182 let 183 - # Let's package the icalevents plugin 184 - plugin-icalevents = pkgs.stdenv.mkDerivation { 183 + plugin-icalevents = pkgs.stdenv.mkDerivation rec { 185 184 name = "icalevents"; 186 - # Download the plugin from the dokuwiki site 187 - src = pkgs.fetchurl { 188 - url = "https://github.com/real-or-random/dokuwiki-plugin-icalevents/releases/download/2017-06-16/dokuwiki-plugin-icalevents-2017-06-16.zip"; 189 - sha256 = "e40ed7dd6bbe7fe3363bbbecb4de481d5e42385b5a0f62f6a6ce6bf3a1f9dfa8"; 185 + version = "2017-06-16"; 186 + src = pkgs.fetchzip { 187 + stripRoot = false; 188 + url = "https://github.com/real-or-random/dokuwiki-plugin-icalevents/releases/download/''${version}/dokuwiki-plugin-icalevents-''${version}.zip"; 189 + hash = "sha256-IPs4+qgEfe8AAWevbcCM9PnyI0uoyamtWeg4rEb+9Wc="; 190 190 }; 191 - sourceRoot = "."; 192 - # We need unzip to build this package 193 - buildInputs = [ pkgs.unzip ]; 194 - # Installing simply means copying all files to the output directory 195 191 installPhase = "mkdir -p $out; cp -R * $out/"; 196 192 }; 197 193 # And then pass this theme to the plugin list like this: ··· 211 207 ''; 212 208 example = literalExpression '' 213 209 let 214 - # Let's package the bootstrap3 theme 215 - template-bootstrap3 = pkgs.stdenv.mkDerivation { 216 - name = "bootstrap3"; 217 - # Download the theme from the dokuwiki site 218 - src = pkgs.fetchurl { 219 - url = "https://github.com/giterlizzi/dokuwiki-template-bootstrap3/archive/v2019-05-22.zip"; 220 - sha256 = "4de5ff31d54dd61bbccaf092c9e74c1af3a4c53e07aa59f60457a8f00cfb23a6"; 221 - }; 222 - # We need unzip to build this package 223 - buildInputs = [ pkgs.unzip ]; 224 - # Installing simply means copying all files to the output directory 225 - installPhase = "mkdir -p $out; cp -R * $out/"; 210 + template-bootstrap3 = pkgs.stdenv.mkDerivation rec { 211 + name = "bootstrap3"; 212 + version = "2022-07-27"; 213 + src = pkgs.fetchFromGitHub { 214 + owner = "giterlizzi"; 215 + repo = "dokuwiki-template-bootstrap3"; 216 + rev = "v''${version}"; 217 + hash = "sha256-B3Yd4lxdwqfCnfmZdp+i/Mzwn/aEuZ0ovagDxuR6lxo="; 226 218 }; 219 + installPhase = "mkdir -p $out; cp -R * $out/"; 220 + }; 227 221 # And then pass this theme to the template list like this: 228 222 in [ template-bootstrap3 ] 229 223 ''; ··· 310 304 Further nginx configuration can be done by adapting `services.nginx.virtualHosts.<name>`. 311 305 See [](#opt-services.nginx.virtualHosts) for further information. 312 306 313 - Further apache2 configuration can be done by adapting `services.httpd.virtualHosts.<name>`. 314 - See [](#opt-services.httpd.virtualHosts) for further information. 307 + Further caddy configuration can be done by adapting `services.caddy.virtualHosts.<name>`. 308 + See [](#opt-services.caddy.virtualHosts) for further information. 315 309 ''; 316 310 }; 317 311
+64 -61
nixos/tests/dokuwiki.nix
··· 1 1 import ./make-test-python.nix ({ pkgs, ... }: 2 2 3 3 let 4 - template-bootstrap3 = pkgs.stdenv.mkDerivation { 4 + template-bootstrap3 = pkgs.stdenv.mkDerivation rec { 5 5 name = "bootstrap3"; 6 - # Download the theme from the dokuwiki site 7 - src = pkgs.fetchurl { 8 - url = "https://github.com/giterlizzi/dokuwiki-template-bootstrap3/archive/v2019-05-22.zip"; 9 - sha256 = "4de5ff31d54dd61bbccaf092c9e74c1af3a4c53e07aa59f60457a8f00cfb23a6"; 6 + version = "2022-07-27"; 7 + src = pkgs.fetchFromGitHub { 8 + owner = "giterlizzi"; 9 + repo = "dokuwiki-template-bootstrap3"; 10 + rev = "v${version}"; 11 + hash = "sha256-B3Yd4lxdwqfCnfmZdp+i/Mzwn/aEuZ0ovagDxuR6lxo="; 10 12 }; 11 - # We need unzip to build this package 12 - nativeBuildInputs = [ pkgs.unzip ]; 13 - # Installing simply means copying all files to the output directory 14 13 installPhase = "mkdir -p $out; cp -R * $out/"; 15 14 }; 16 15 17 16 18 - # Let's package the icalevents plugin 19 - plugin-icalevents = pkgs.stdenv.mkDerivation { 17 + plugin-icalevents = pkgs.stdenv.mkDerivation rec { 20 18 name = "icalevents"; 21 - # Download the plugin from the dokuwiki site 22 - src = pkgs.fetchurl { 23 - url = "https://github.com/real-or-random/dokuwiki-plugin-icalevents/releases/download/2017-06-16/dokuwiki-plugin-icalevents-2017-06-16.zip"; 24 - sha256 = "e40ed7dd6bbe7fe3363bbbecb4de481d5e42385b5a0f62f6a6ce6bf3a1f9dfa8"; 19 + version = "2017-06-16"; 20 + src = pkgs.fetchzip { 21 + stripRoot = false; 22 + url = "https://github.com/real-or-random/dokuwiki-plugin-icalevents/releases/download/${version}/dokuwiki-plugin-icalevents-${version}.zip"; 23 + hash = "sha256-IPs4+qgEfe8AAWevbcCM9PnyI0uoyamtWeg4rEb+9Wc="; 25 24 }; 26 - # We need unzip to build this package 27 - nativeBuildInputs = [ pkgs.unzip ]; 28 - sourceRoot = "."; 29 - # Installing simply means copying all files to the output directory 30 25 installPhase = "mkdir -p $out; cp -R * $out/"; 31 26 }; 32 27 28 + acronymsFile = pkgs.writeText "acronyms.local.conf" '' 29 + r13y reproducibility 30 + ''; 31 + 32 + dwWithAcronyms = pkgs.dokuwiki.overrideAttrs (prev: { 33 + installPhase = prev.installPhase or "" + '' 34 + ln -sf ${acronymsFile} $out/share/dokuwiki/conf/acronyms.local.conf 35 + ''; 36 + }); 37 + 38 + mkNode = webserver: { ... }: { 39 + services.dokuwiki = { 40 + inherit webserver; 41 + 42 + sites = { 43 + "site1.local" = { 44 + aclUse = false; 45 + superUser = "admin"; 46 + }; 47 + "site2.local" = { 48 + package = dwWithAcronyms; 49 + usersFile = "/var/lib/dokuwiki/site2.local/users.auth.php"; 50 + superUser = "admin"; 51 + templates = [ template-bootstrap3 ]; 52 + plugins = [ plugin-icalevents ]; 53 + }; 54 + }; 55 + }; 56 + 57 + networking.firewall.allowedTCPPorts = [ 80 ]; 58 + networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ]; 59 + }; 60 + 33 61 in { 34 62 name = "dokuwiki"; 35 63 meta = with pkgs.lib; { ··· 40 68 }; 41 69 42 70 nodes = { 43 - dokuwiki_nginx = {...}: { 44 - services.dokuwiki = { 45 - sites = { 46 - "site1.local" = { 47 - aclUse = false; 48 - superUser = "admin"; 49 - }; 50 - "site2.local" = { 51 - usersFile = "/var/lib/dokuwiki/site2.local/users.auth.php"; 52 - superUser = "admin"; 53 - templates = [ template-bootstrap3 ]; 54 - plugins = [ plugin-icalevents ]; 55 - }; 56 - }; 57 - }; 58 - 59 - networking.firewall.allowedTCPPorts = [ 80 ]; 60 - networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ]; 61 - }; 62 - 63 - dokuwiki_caddy = {...}: { 64 - services.dokuwiki = { 65 - webserver = "caddy"; 66 - sites = { 67 - "site1.local" = { 68 - aclUse = false; 69 - superUser = "admin"; 70 - }; 71 - "site2.local" = { 72 - usersFile = "/var/lib/dokuwiki/site2.local/users.auth.php"; 73 - superUser = "admin"; 74 - templates = [ template-bootstrap3 ]; 75 - plugins = [ plugin-icalevents ]; 76 - }; 77 - }; 78 - }; 79 - 80 - networking.firewall.allowedTCPPorts = [ 80 ]; 81 - networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ]; 82 - }; 83 - 71 + dokuwiki_nginx = mkNode "nginx"; 72 + dokuwiki_caddy = mkNode "caddy"; 84 73 }; 85 74 86 75 testScript = '' ··· 102 91 machine.succeed("curl -sSfL http://site2.local/ | grep 'DokuWiki'") 103 92 machine.succeed("curl -sSfL 'http://site2.local/doku.php?do=login' | grep 'Login'") 104 93 105 - machine.succeed( 94 + with subtest("ACL Operations"): 95 + machine.succeed( 106 96 "echo 'admin:$2y$10$ijdBQMzSVV20SrKtCna8gue36vnsbVm2wItAXvdm876sshI4uwy6S:Admin:admin@example.test:user' >> /var/lib/dokuwiki/site2.local/users.auth.php", 107 97 "curl -sSfL -d 'u=admin&p=password' --cookie-jar cjar 'http://site2.local/doku.php?do=login'", 108 98 "curl -sSfL --cookie cjar --cookie-jar cjar 'http://site2.local/doku.php?do=login' | grep 'Logged in as: <bdi>Admin</bdi>'", 109 - ) 99 + ) 100 + 101 + with subtest("Customizing Dokuwiki"): 102 + machine.succeed( 103 + "echo 'r13y is awesome!' >> /var/lib/dokuwiki/site2.local/data/pages/acronyms-test.txt", 104 + "curl -sSfL 'http://site2.local/doku.php?id=acronyms-test' | grep '<abbr title=\"reproducibility\">r13y</abbr>'", 105 + ) 106 + 107 + # Just to ensure both Webserver configurations are consistent in allowing that 108 + with subtest("Rewriting"): 109 + machine.succeed( 110 + "echo 'Hello, NixOS!' >> /var/lib/dokuwiki/site1.local/data/pages/rewrite-test.txt", 111 + "curl -sSfL http://site1.local/rewrite-test | grep 'Hello, NixOS!'", 112 + ) 110 113 ''; 111 114 })