Skip to content

nixos/dokuwiki: Lists in settings are rendered as comma separated strings instead of php arrays #380915

Open
@NomAnor

Description

Nixpkgs version

  • Stable (24.11)

Describe the bug

I'm configuring Dokuwiki with the oauthgeneric plugin and I'm setting the scope option to a list of strings. This gets rendered as a comma separated single string in the settings file instead of a php array construct as required by the plugin.

Steps to reproduce

{ config, lib, pkgs, ...}:
let
  plugin-oauth = pkgs.stdenv.mkDerivation (finalAttrs:  {
    name = "oauth";
    version = "2024-11-02";
    src = pkgs.fetchFromGitHub {
      owner = "cosmocode";
      repo = "dokuwiki-plugin-oauth";
      rev = finalAttrs.version;
      hash = "sha256-RYWBfrZOg2Vv6JefVHgRvfQ/UnU2yJJzmfS3nj+fRYc=";
    };
    installPhase = "mkdir -p $out; cp -R * $out/";
  });

  plugin-oauthgeneric = pkgs.stdenv.mkDerivation (finalAttrs:  {
    name = "oauthgeneric";
    version = "2024-03-21";
    src = pkgs.fetchFromGitHub {
      owner = "cosmocode";
      repo = "dokuwiki-plugin-oauthgeneric";
      rev = finalAttrs.version;
      hash = "sha256-lcD7u6Rr+FXo6rAT8uY1fnbDlSVPHTtDacPdsZBoHGg=";
    };
    installPhase = "mkdir -p $out; cp -R * $out/";
  });
in {
  services.dokuwiki = {
    webserver = "nginx";
    sites.wiki = {
      enable = true;
      stateDir = "/srv/dokuwiki/";
      plugins = [ plugin-oauth plugin-oauthgeneric ];
      settings = {
        useacl = true;
        userewrite = true;
        authtype = "oauth";
        superuser = "@admin";
        title = "Wiki";
        basedir = "/wiki/";
        plugin.oauth = {
           register-on-auth = true;
        };
        plugin.oauthgeneric = {
          key = "xxx";
          secret._file = "xxx";
          authurl = "xxx";
          tokenurl = "xxx";
          userurl = "xxx";
          authmethod = 1; # Bearer Header
          scopes = [ "email" "openid" "profile" "offline_access" ];
          needs-state = true;
          json-user = "preferred_username";
          json-name = "name";
          json-mail = "email";
          json-grps = "groups";
        };
      };
    };
  };
}

This produces the following local.php:

<?php
$conf['authtype'] = 'oauth';
$conf['basedir'] = '/wiki/';
$conf['plugin']['oauth']['register-on-auth'] = 1;
$conf['plugin']['oauthgeneric']['authmethod'] = 1;
$conf['plugin']['oauthgeneric']['authurl'] = 'xxx';
$conf['plugin']['oauthgeneric']['json-grps'] = 'groups';
$conf['plugin']['oauthgeneric']['json-mail'] = 'email';
$conf['plugin']['oauthgeneric']['json-name'] = 'name';
$conf['plugin']['oauthgeneric']['json-user'] = 'preferred_username';
$conf['plugin']['oauthgeneric']['key'] = 'xxx';
$conf['plugin']['oauthgeneric']['needs-state'] = 1;
$conf['plugin']['oauthgeneric']['scopes'] = 'email,openid,profile,offline_access';
$conf['plugin']['oauthgeneric']['secret'] = 'xxx';
$conf['plugin']['oauthgeneric']['tokenurl'] = 'xxx';
$conf['plugin']['oauthgeneric']['userurl'] = 'xxx';
$conf['savedir'] = '/srv/dokuwiki/';
$conf['superuser'] = '@admin';
$conf['title'] = 'Wiki';
$conf['useacl'] = 1;
$conf['userewrite'] = 1;

I have to set scopes._raw = ''array("email", "openid", "profile", "offline_access")'' to get the correct output:

$conf['plugin']['oauthgeneric']['scopes'] = array("email", "openid", "profile", "offline_access");

Expected behaviour

Render lists as php arrays.

Screenshots

No response

Relevant log output

Additional context

The conversion happens in

mkPhpValue = v: let
isHasAttr = s: isAttrs v && hasAttr s v;
in
if isString v then toPhpString v
# NOTE: If any value contains a , (comma) this will not get escaped
else if isList v && strings.isConvertibleWithToString v then toPhpString (concatMapStringsSep "," toString v)
else if isInt v then toString v
else if isBool v then toString (if v then 1 else 0)
else if isHasAttr "_file" then "trim(file_get_contents(${toPhpString (toString v._file)}))"
else if isHasAttr "_raw" then v._raw
else abort "The dokuwiki localConf value ${lib.generators.toPretty {} v} can not be encoded."
;

If this conversation was used because other list options require it, would it be possible to make the rendering for list configurable? Maybe a special _array attribute?

System metadata

  • system: "x86_64-linux"
  • host os: Linux 6.6.74, NixOS, 24.11 (Vicuna), 24.11.20250129.59e618d
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.24.12
  • nixpkgs: /nix/store/y43mj3x0256cm2siypjb3jpk96g0sx9p-source

Notify maintainers

@1000101
@onny
@dandellion
@e1mo


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction to issues you find important.

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions