Nextcloud extraoptions conversion issues

I’ve ran into several issues where my configuration in NixOS is resulting in a malformed Nextcloud config.php

This is how it should be according to Nextclouds documentation

'filelocking.enabled' = true,
'enabledPreviewProviders' => [
    'OC\Preview\MP3',
    'OC\Preview\TXT',
    'OC\Preview\Imaginary',
],

I’ve got three problems:

  1. Parameter with dot is converted to an array
    filelocking.enabled > 'filelocking' => array ( 'enabled' => true, ),
  2. Backslash \ in list item strings were stripped or erroneously escaped ending up as double backslash \\ in the config.php.
    since single quoted strings in php doesn’t need escaping of special chars the \\ were treated literally as \\
    Example: "OC\Preview\MP3" > "OCPreviewMP3"
    OR "OC\\Preview\\MP3" > "OC\\Preview\\MP3"
    This is related to an unresolved topic: Nextlcoud with Redis distributed cashing and file locking - #2 by Smithoo4
  3. List items were converted into an array
Frist try

Input
This is what I’ve configured in NixOS

extraOptions = {
      filelocking.enabled = true;
      enabledPreviewProviders = [
        "OC\Preview\MP3"
        "OC\Preview\TXT"
        "OC\Preview\Imaginary"
      ];
    };

Output this is what I get after NixOs rebuild (the generated Nextcloud config.php):

'filelocking' =>                                                                                   
   array (                                                                                            
     'enabled' => true,                                                                               
  ),
'enabledPreviewProviders' =>                                                                       
   array (                                                                                            
    0 => 'OCPreviewMP3',                                                                         
    1 => 'OCPreviewTXT',                                                                                                                                           
    2 => 'OCPreviewImaginary',                                                                   
  ),                                                                   
Second try

Input
This is what I’ve configured in NixOS

extraOptions = {
      "filelocking.enabled" = "true";
      enabledPreviewProviders = [
        "OC\\Preview\\MP3"
        "OC\\Preview\\TXT"
        "OC\\Preview\\Imaginary"
      ];
    };

Output this is what I get after NixOs rebuild (the generated Nextcloud config.php):

'filelocking.enabled' => 'true',
'enabledPreviewProviders' =>                                                                       
   array (                                                                                            
    0 => 'OC\\Preview\\MP3',                                                                         
    1 => 'OC\\Preview\\TXT',                                                                                                                                           
    2 => 'OC\\Preview\\Imaginary',                                                                   
  ),                                                                   
Third try

Input
This is what I’ve configured in NixOS

extraOptions = {
      "filelocking.enabled" = true;
      enabledPreviewProviders = [
        ''OC\Preview\MP3''
        ''OC\Preview\TXT''
        ''OC\Preview\Imaginary''
      ];
    };

Output this is what I get after NixOs rebuild (the generated Nextcloud config.php):

'filelocking.enabled' => true,
'enabledPreviewProviders' =>                                                                       
   array (                                                                                            
    0 => 'OC\\Preview\\MP3',                                                                         
    1 => 'OC\\Preview\\TXT',                                                                                                                                           
    2 => 'OC\\Preview\\Imaginary',                                                                   
  ),                                                                   

Summary

  1. Parameter with dot is converted to an array filelocking.enabled > issue solved by transform input to "filelocking.enabled" = true;
  2. Backslash \ in list item strings were stripped or erroneously escaped ending up as double backslash \\ not resolved ending up in not applied configuration
  3. List items were converted into an array > seems only be an cosmetical issue

Maybe the conversion in the NixOS Nextcloud module via JSON causes this unintended conversion. Does anyone have an idea how to circumvent this without rewriting the NixOS Nextcloud module?

$CONFIG = array_replace_recursive($CONFIG, nix_decode_json_file(
              "${jsonFormat.generate "nextcloud-extraOptions.json" cfg.extraOptions}",
              "impossible: this should never happen (decoding generated extraOptions file %s failed)"
            ));

Since I think this is a bug rather than indented behavior, I submitted an issue on GitHub
https://github.com/NixOS/nixpkgs/issues/252445