NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.58k stars 13.73k forks source link

Prosody extraConfig prints readFile functions wrong #265251

Open gianmarcogg03 opened 11 months ago

gianmarcogg03 commented 11 months ago

Describe the bug

In my Prosody configuration I have set a secret for a module that goes like this:

turn_external_secret = "secretgoeshere"

However, if I put a builtins.readFile function to read the secret file, since I don't want to hardcode the secret here, the system fails to rebuild with this error:

Error: /etc/prosody/prosody.cfg.lua:93: unfinished string near '"secretgoeshere'

When I go and check that lua file, I see that the closing apostrophe (or quotation mark) goes on a new line for some reason:

turn_external_secret = 'secretgoeshere
'

This does not happen when I hardcode the secret in the configuration file and the service runs fine.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Set up Prosody with Coturn
  2. Enable the turn_external community module
  3. Set in extraConfig the turn secret

Expected behavior

The secret should be printed in the lua config file without the closing apostrophe/quotation mark going on a new line.

Notify maintainers

@globin

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[gianmarco@artemis:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.55, NixOS, 23.05 (Stoat), 23.05.4392.b5f8ec6be261`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.5`
 - channels(root): `"nixos-23.05"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
eclairevoyant commented 11 months ago

FYI, readFile-ing a secret wil put it in the (world-readable) store, so this doesn't sound like the best approach

amalgame21 commented 9 months ago

This rewritten prosody module provide a new option environmentFile, I think that is what you want. You can look at the description to see how to use it.