summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services
diff options
context:
space:
mode:
authorMasum Reza <50095635+JohnRTitor@users.noreply.github.com>2024-06-29 00:02:35 +0530
committerGitHub <noreply@github.com>2024-06-29 00:02:35 +0530
commit383744754ed3bf2cfb6cf6ab108bb12b804f8737 (patch)
tree92a23a9a7b21de51e1b89d5e68cbd18bcb096f8f /nixos/modules/services
parentdbc930602f6d36ed2fba4bb14c51868ef42ff68d (diff)
parent3f0bd8ab85bf448bd7aee7c78a0ac128350a6568 (diff)
Merge pull request #314798 from yomaq/healthchecks-settingsFile
nixos/healthchecks: add settingsFile option
Diffstat (limited to 'nixos/modules/services')
-rw-r--r--nixos/modules/services/web-apps/healthchecks.nix18
1 files changed, 15 insertions, 3 deletions
diff --git a/nixos/modules/services/web-apps/healthchecks.nix b/nixos/modules/services/web-apps/healthchecks.nix
index 5562b37e502c..c7db999a62c2 100644
--- a/nixos/modules/services/web-apps/healthchecks.nix
+++ b/nixos/modules/services/web-apps/healthchecks.nix
@@ -11,7 +11,7 @@ let
environment = {
PYTHONPATH = pkg.pythonPath;
STATIC_ROOT = cfg.dataDir + "/static";
- } // cfg.settings;
+ } // lib.filterAttrs (_: v: !builtins.isNull v) cfg.settings;
environmentFile = pkgs.writeText "healthchecks-environment" (lib.generators.toKeyValue { } environment);
@@ -21,6 +21,7 @@ let
sudo='exec /run/wrappers/bin/sudo -u ${cfg.user} --preserve-env --preserve-env=PYTHONPATH'
fi
export $(cat ${environmentFile} | xargs)
+ ${lib.optionalString (cfg.settingsFile != null) "export $(cat ${cfg.settingsFile} | xargs)"}
$sudo ${pkg}/opt/healthchecks/manage.py "$@"
'';
in
@@ -89,6 +90,12 @@ in
'';
};
+ settingsFile = lib.mkOption {
+ type = lib.types.nullOr lib.types.path;
+ default = null;
+ description = opt.settings.description;
+ };
+
settings = lib.mkOption {
description = ''
Environment variables which are read by healthchecks `(local)_settings.py`.
@@ -109,6 +116,8 @@ in
have support for a `_FILE` variant, run:
- `nix-instantiate --eval --expr '(import <nixpkgs> {}).healthchecks.secrets'`
- or `nix eval 'nixpkgs#healthchecks.secrets'` if the flake support has been enabled.
+
+ If the same variable is set in both `settings` and `settingsFile` the value from `settingsFile` has priority.
'';
type = types.submodule (settings: {
freeformType = types.attrsOf types.str;
@@ -121,8 +130,9 @@ in
};
SECRET_KEY_FILE = mkOption {
- type = types.path;
+ type = types.nullOr types.path;
description = "Path to a file containing the secret key.";
+ default = null;
};
DEBUG = mkOption {
@@ -186,7 +196,9 @@ in
WorkingDirectory = cfg.dataDir;
User = cfg.user;
Group = cfg.group;
- EnvironmentFile = [ environmentFile ];
+ EnvironmentFile = [
+ environmentFile
+ ] ++ lib.optional (cfg.settingsFile != null) cfg.settingsFile;
StateDirectory = mkIf (cfg.dataDir == "/var/lib/healthchecks") "healthchecks";
StateDirectoryMode = mkIf (cfg.dataDir == "/var/lib/healthchecks") "0750";
};