Skip to content

Commit

Permalink
nixos/matrix-synapse: fix recursive filtering of null values
Browse files Browse the repository at this point in the history
Using `filterAttrsRecursive` is not sufficient to account for a nested
attribute set with list values, like used for listeners.
  • Loading branch information
mweinelt committed Feb 5, 2024
1 parent dbb175c commit 6f3bb46
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion nixos/modules/services/matrix/synapse.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ let
cfg = config.services.matrix-synapse;
format = pkgs.formats.yaml { };

filterRecursiveNull = o:
if isAttrs o then
mapAttrs (_: v: filterRecursiveNull v) (filterAttrs (_: v: v != null) o)
else if isList o then
map filterRecursiveNull (filter (v: v != null) o)
else
o;

# remove null values from the final configuration
finalSettings = lib.filterAttrsRecursive (_: v: v != null) cfg.settings;
finalSettings = filterRecursiveNull cfg.settings;
configFile = format.generate "homeserver.yaml" finalSettings;

usePostgresql = cfg.settings.database.name == "psycopg2";
Expand Down

0 comments on commit 6f3bb46

Please sign in to comment.