|
11 | 11 | environment = { |
12 | 12 | PYTHONPATH = pkg.pythonPath; |
13 | 13 | STATIC_ROOT = cfg.dataDir + "/static"; |
14 | | - } // cfg.settings; |
| 14 | + } // lib.filterAttrs (_: v: !builtins.isNull v) cfg.settings; |
15 | 15 |
|
16 | 16 | environmentFile = pkgs.writeText "healthchecks-environment" (lib.generators.toKeyValue { } environment); |
17 | 17 |
|
|
21 | 21 | sudo='exec /run/wrappers/bin/sudo -u ${cfg.user} --preserve-env --preserve-env=PYTHONPATH' |
22 | 22 | fi |
23 | 23 | export $(cat ${environmentFile} | xargs) |
| 24 | + ${lib.optionalString (cfg.settingsFile != null) "export $(cat ${cfg.settingsFile} | xargs)"} |
24 | 25 | $sudo ${pkg}/opt/healthchecks/manage.py "$@" |
25 | 26 | ''; |
26 | 27 | in |
|
89 | 90 | ''; |
90 | 91 | }; |
91 | 92 |
|
| 93 | + settingsFile = lib.mkOption { |
| 94 | + type = lib.types.nullOr lib.types.path; |
| 95 | + default = null; |
| 96 | + description = opt.settings.description; |
| 97 | + }; |
| 98 | + |
92 | 99 | settings = lib.mkOption { |
93 | 100 | description = '' |
94 | 101 | Environment variables which are read by healthchecks `(local)_settings.py`. |
|
109 | 116 | have support for a `_FILE` variant, run: |
110 | 117 | - `nix-instantiate --eval --expr '(import <nixpkgs> {}).healthchecks.secrets'` |
111 | 118 | - or `nix eval 'nixpkgs#healthchecks.secrets'` if the flake support has been enabled. |
| 119 | +
|
| 120 | + If the same variable is set in both `settings` and `settingsFile` the value from `settingsFile` has priority. |
112 | 121 | ''; |
113 | 122 | type = types.submodule (settings: { |
114 | 123 | freeformType = types.attrsOf types.str; |
|
121 | 130 | }; |
122 | 131 |
|
123 | 132 | SECRET_KEY_FILE = mkOption { |
124 | | - type = types.path; |
| 133 | + type = types.nullOr types.path; |
125 | 134 | description = "Path to a file containing the secret key."; |
| 135 | + default = null; |
126 | 136 | }; |
127 | 137 |
|
128 | 138 | DEBUG = mkOption { |
|
186 | 196 | WorkingDirectory = cfg.dataDir; |
187 | 197 | User = cfg.user; |
188 | 198 | Group = cfg.group; |
189 | | - EnvironmentFile = [ environmentFile ]; |
| 199 | + EnvironmentFile = [ |
| 200 | + environmentFile |
| 201 | + ] ++ lib.optional (cfg.settingsFile != null) cfg.settingsFile; |
190 | 202 | StateDirectory = mkIf (cfg.dataDir == "/var/lib/healthchecks") "healthchecks"; |
191 | 203 | StateDirectoryMode = mkIf (cfg.dataDir == "/var/lib/healthchecks") "0750"; |
192 | 204 | }; |
|
0 commit comments