aboutsummaryrefslogtreecommitdiff
path: root/modules/apps
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2016-10-05 21:11:40 +0300
committerIgor Pashev <pashev.igor@gmail.com>2016-10-05 21:14:45 +0300
commit885edd78d67656f6f3aee02e6457d9290075638e (patch)
tree8e04e41b76088fcf3f15c8fd9672b267d500befc /modules/apps
parent643e4576e293f48d1b69eb705df0eede223c3655 (diff)
downloadnixsap-885edd78d67656f6f3aee02e6457d9290075638e.tar.gz
postgresql: refactor keyrings code
Several instances can run as the same user.
Diffstat (limited to 'modules/apps')
-rw-r--r--modules/apps/postgresql/default.nix15
1 files changed, 9 insertions, 6 deletions
diff --git a/modules/apps/postgresql/default.nix b/modules/apps/postgresql/default.nix
index 847fc75..bfbf4bd 100644
--- a/modules/apps/postgresql/default.nix
+++ b/modules/apps/postgresql/default.nix
@@ -5,9 +5,9 @@ let
match toString ;
inherit (lib)
- concatMapStrings concatStringsSep filter filterAttrs foldl hasPrefix
- isBool isInt isList isString length mapAttrs' mapAttrsToList mkDefault
- mkIf mkOption nameValuePair types ;
+ concatMapStrings concatStringsSep filter filterAttrs foldAttrs foldl
+ hasPrefix isBool isInt isList isString length mapAttrs' mapAttrsToList
+ mkDefault mkIf mkOption nameValuePair types ;
inherit (types)
attrsOf lines listOf nullOr package path str submodule ;
@@ -19,10 +19,13 @@ let
users = mapAttrsToList (_: v: v.user) instances;
isFloat = x: match "^[0-9]+(\\.[0-9]+)?$" (toString x) != null;
- isKey = s: s != null && hasPrefix "/run/keys/" s;
- keyrings = mapAttrs' (_: i: nameValuePair "${i.user}" [ i.server.ssl_key_file ]
- ) (filterAttrs (_: i: isKey i.server.ssl_key_file) instances);
+ keyrings =
+ let
+ isKey = s: s != null && hasPrefix "/run/keys/" s;
+ keys = i: filter isKey [ i.server.ssl_key_file ];
+ ik = mapAttrsToList (_: i: { "${i.user}" = keys i; } ) instances;
+ in foldAttrs (l: r: l ++ r) [] ik;
mkService = name: opts:
let