From e41918a1a74664ba55aee59c8b390ca05eff3a9e Mon Sep 17 00:00:00 2001 From: ibizaman Date: Sat, 31 Dec 2022 00:35:08 -0800 Subject: [PATCH] merge config with unit for caddy --- caddy/config.nix | 22 ---------------------- caddy/unit.nix | 20 ++++++++++++++------ 2 files changed, 14 insertions(+), 28 deletions(-) delete mode 100644 caddy/config.nix diff --git a/caddy/config.nix b/caddy/config.nix deleted file mode 100644 index 857c0e0..0000000 --- a/caddy/config.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ stdenv -, pkgs -, utils -}: -{ configDir ? "/etc/caddy" -, configFile ? "Caddyfile" -, siteConfigDir -}: - -utils.mkConfigFile { - name = configFile; - dir = configDir; - content = '' - { - # Disable auto https - http_port 10001 - https_port 10002 - } - - import ${siteConfigDir}/* - ''; -} diff --git a/caddy/unit.nix b/caddy/unit.nix index a115af2..526e523 100644 --- a/caddy/unit.nix +++ b/caddy/unit.nix @@ -4,11 +4,21 @@ }: { user ? "http" , group ? "http" -, configDir ? "/etc/caddy" -, configFile ? "Caddyfile" +, siteConfigDir }: {...}: +let + config = pkgs.writeTextDir "Caddyfile" '' + { + # Disable auto https + http_port 10001 + https_port 10002 + } + + import ${siteConfigDir}/* + ''; +in utils.systemd.mkService rec { name = "caddy"; @@ -27,10 +37,8 @@ utils.systemd.mkService rec { Type=notify User=${user} Group=${group} - # Environment=XDG_DATA_HOME=/var/lib - # Environment=XDG_CONFIG_HOME=${configDir} - ExecStart=${pkgs.caddy}/bin/caddy run --environ --config ${configDir}/${configFile} - ExecReload=${pkgs.caddy}/bin/caddy reload --config ${configDir}/${configFile} + ExecStart=${pkgs.caddy}/bin/caddy run --environ --config ${config} + ExecReload=${pkgs.caddy}/bin/caddy reload --config ${config} # Restart=on-abnormal RuntimeDirectory=caddy