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:
- Parameter with dot is converted to an array
filelocking.enabled>'filelocking' => array ( 'enabled' => true, ), - Backslash
\in list item strings were stripped or erroneously escaped ending up as double backslash\\in theconfig.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 - 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
- Parameter with dot is converted to an array
filelocking.enabled> issue solved by transform input to"filelocking.enabled" = true; - Backslash
\in list item strings were stripped or erroneously escaped ending up as double backslash\\not resolved ending up in not applied configuration - 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)"
));