mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-11 07:15:54 +03:00
nixos/traefik: add environmentFiles option
This commit is contained in:
parent
67faa3e9b3
commit
d568766fc7
@ -48,6 +48,11 @@ let
|
|||||||
''
|
''
|
||||||
else
|
else
|
||||||
cfg.staticConfigFile;
|
cfg.staticConfigFile;
|
||||||
|
|
||||||
|
finalStaticConfigFile =
|
||||||
|
if cfg.environmentFiles == []
|
||||||
|
then staticConfigFile
|
||||||
|
else "/run/traefik/config.toml";
|
||||||
in {
|
in {
|
||||||
options.services.traefik = {
|
options.services.traefik = {
|
||||||
enable = mkEnableOption (lib.mdDoc "Traefik web server");
|
enable = mkEnableOption (lib.mdDoc "Traefik web server");
|
||||||
@ -127,6 +132,16 @@ in {
|
|||||||
type = types.package;
|
type = types.package;
|
||||||
description = lib.mdDoc "Traefik package to use.";
|
description = lib.mdDoc "Traefik package to use.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
environmentFiles = mkOption {
|
||||||
|
default = [];
|
||||||
|
type = types.listOf types.path;
|
||||||
|
example = [ "/run/secrets/traefik.env" ];
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Files to load as environment file. Environment variables from this file
|
||||||
|
will be substituted into the static configuration file using envsubst.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
@ -139,8 +154,13 @@ in {
|
|||||||
startLimitIntervalSec = 86400;
|
startLimitIntervalSec = 86400;
|
||||||
startLimitBurst = 5;
|
startLimitBurst = 5;
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart =
|
EnvironmentFile = cfg.environmentFiles;
|
||||||
"${cfg.package}/bin/traefik --configfile=${staticConfigFile}";
|
ExecStartPre = lib.optional (cfg.environmentFiles != [])
|
||||||
|
(pkgs.writeShellScript "pre-start" ''
|
||||||
|
umask 077
|
||||||
|
${pkgs.envsubst}/bin/envsubst -i "${staticConfigFile}" > "${finalStaticConfigFile}"
|
||||||
|
'');
|
||||||
|
ExecStart = "${cfg.package}/bin/traefik --configfile=${finalStaticConfigFile}";
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
User = "traefik";
|
User = "traefik";
|
||||||
Group = cfg.group;
|
Group = cfg.group;
|
||||||
@ -155,6 +175,7 @@ in {
|
|||||||
ProtectHome = true;
|
ProtectHome = true;
|
||||||
ProtectSystem = "full";
|
ProtectSystem = "full";
|
||||||
ReadWriteDirectories = cfg.dataDir;
|
ReadWriteDirectories = cfg.dataDir;
|
||||||
|
RuntimeDirectory = "traefik";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,10 +52,13 @@ import ./make-test-python.nix ({ pkgs, ... }: {
|
|||||||
sendAnonymousUsage = false;
|
sendAnonymousUsage = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
entryPoints.web.address = ":80";
|
entryPoints.web.address = ":\${HTTP_PORT}";
|
||||||
|
|
||||||
providers.docker.exposedByDefault = false;
|
providers.docker.exposedByDefault = false;
|
||||||
};
|
};
|
||||||
|
environmentFiles = [(pkgs.writeText "traefik.env" ''
|
||||||
|
HTTP_PORT=80
|
||||||
|
'')];
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.simplehttp = {
|
systemd.services.simplehttp = {
|
||||||
|
Loading…
Reference in New Issue
Block a user