chore(fmt): Run alejandra fmt
This commit is contained in:
@@ -4,10 +4,7 @@
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
with lib; let
|
||||
cfg = config.services.caddy;
|
||||
|
||||
certs = config.security.acme.certs;
|
||||
@@ -17,12 +14,9 @@ let
|
||||
dependentCertNames = filter (cert: certs.${cert}.dnsProvider == null) vhostCertNames; # those that might depend on the HTTP server
|
||||
independentCertNames = filter (cert: certs.${cert}.dnsProvider != null) vhostCertNames; # those that don't depend on the HTTP server
|
||||
|
||||
mkVHostConf =
|
||||
hostOpts:
|
||||
let
|
||||
mkVHostConf = hostOpts: let
|
||||
sslCertDir = config.security.acme.certs.${hostOpts.useACMEHost}.directory;
|
||||
in
|
||||
''
|
||||
in ''
|
||||
${hostOpts.hostName} ${concatStringsSep " " hostOpts.serverAliases} {
|
||||
${optionalString (
|
||||
hostOpts.listenAddresses != []
|
||||
@@ -41,10 +35,9 @@ let
|
||||
settingsFormat = pkgs.formats.json {};
|
||||
|
||||
configFile =
|
||||
if cfg.settings != { } then
|
||||
settingsFormat.generate "caddy.json" cfg.settings
|
||||
else
|
||||
let
|
||||
if cfg.settings != {}
|
||||
then settingsFormat.generate "caddy.json" cfg.settings
|
||||
else let
|
||||
Caddyfile = pkgs.writeTextDir "Caddyfile" ''
|
||||
{
|
||||
${cfg.globalConfig}
|
||||
@@ -58,9 +51,10 @@ let
|
||||
cp --no-preserve=mode ${Caddyfile}/Caddyfile $out/Caddyfile
|
||||
${lib.getExe cfg.package} fmt --overwrite $out/Caddyfile
|
||||
'';
|
||||
in
|
||||
"${
|
||||
if pkgs.stdenv.buildPlatform == pkgs.stdenv.hostPlatform then Caddyfile-formatted else Caddyfile
|
||||
in "${
|
||||
if pkgs.stdenv.buildPlatform == pkgs.stdenv.hostPlatform
|
||||
then Caddyfile-formatted
|
||||
else Caddyfile
|
||||
}/Caddyfile";
|
||||
|
||||
etcConfigFile = "caddy/caddy_config";
|
||||
@@ -68,8 +62,7 @@ let
|
||||
configPath = "/etc/${etcConfigFile}";
|
||||
|
||||
mkCertOwnershipAssertion = import ../../../security/acme/mk-cert-ownership-assertion.nix lib;
|
||||
in
|
||||
{
|
||||
in {
|
||||
imports = [
|
||||
(mkRemovedOptionModule [
|
||||
"services"
|
||||
@@ -183,10 +176,9 @@ in
|
||||
|
||||
adapter = mkOption {
|
||||
default =
|
||||
if ((cfg.configFile != configFile) || (builtins.baseNameOf cfg.configFile) == "Caddyfile") then
|
||||
"caddyfile"
|
||||
else
|
||||
null;
|
||||
if ((cfg.configFile != configFile) || (builtins.baseNameOf cfg.configFile) == "Caddyfile")
|
||||
then "caddyfile"
|
||||
else null;
|
||||
defaultText = literalExpression ''
|
||||
if ((cfg.configFile != configFile) || (builtins.baseNameOf cfg.configFile) == "Caddyfile") then "caddyfile" else null
|
||||
'';
|
||||
@@ -380,8 +372,8 @@ in
|
||||
|
||||
# implementation
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
assertions = [
|
||||
assertions =
|
||||
[
|
||||
{
|
||||
assertion = cfg.configFile == configFile -> cfg.adapter == "caddyfile" || cfg.adapter == null;
|
||||
message = "To specify an adapter other than 'caddyfile' please provide your own configuration via `services.caddy.configFile`";
|
||||
@@ -394,7 +386,8 @@ in
|
||||
groups = config.users.groups;
|
||||
services = [config.systemd.services.caddy];
|
||||
}
|
||||
) vhostCertNames;
|
||||
)
|
||||
vhostCertNames;
|
||||
|
||||
services.caddy.globalConfig = ''
|
||||
${optionalString (cfg.email != null) "email ${cfg.email}"}
|
||||
@@ -422,13 +415,11 @@ in
|
||||
reloadTriggers = optional cfg.enableReload cfg.configFile;
|
||||
restartTriggers = optional (!cfg.enableReload) cfg.configFile;
|
||||
|
||||
serviceConfig =
|
||||
let
|
||||
serviceConfig = let
|
||||
runOptions = ''--config ${configPath} ${
|
||||
optionalString (cfg.adapter != null) "--adapter ${cfg.adapter}"
|
||||
}'';
|
||||
in
|
||||
{
|
||||
in {
|
||||
# Override the `ExecStart` line from upstream's systemd unit file by our own:
|
||||
# https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStart=
|
||||
# If the empty string is assigned to this option, the list of commands to start is reset, prior assignments of this option will have no effect.
|
||||
@@ -437,7 +428,8 @@ in
|
||||
''${lib.getExe cfg.package} run ${runOptions} ${optionalString cfg.resume "--resume"}''
|
||||
];
|
||||
# Validating the configuration before applying it ensures we’ll get a proper error that will be reported when switching to the configuration
|
||||
ExecReload = [
|
||||
ExecReload =
|
||||
[
|
||||
""
|
||||
]
|
||||
++ lib.optional cfg.enableReload "${lib.getExe cfg.package} reload ${runOptions} --force";
|
||||
@@ -470,15 +462,16 @@ in
|
||||
caddy.gid = config.ids.gids.caddy;
|
||||
};
|
||||
|
||||
security.acme.certs =
|
||||
let
|
||||
certCfg = map (
|
||||
security.acme.certs = let
|
||||
certCfg =
|
||||
map (
|
||||
certName:
|
||||
nameValuePair certName {
|
||||
group = mkDefault cfg.group;
|
||||
reloadServices = ["caddy.service"];
|
||||
}
|
||||
) vhostCertNames;
|
||||
)
|
||||
vhostCertNames;
|
||||
in
|
||||
listToAttrs certCfg;
|
||||
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
{ cfg }:
|
||||
{
|
||||
{cfg}: {
|
||||
config,
|
||||
lib,
|
||||
name,
|
||||
...
|
||||
}:
|
||||
let
|
||||
}: let
|
||||
inherit (lib) literalExpression mkOption types;
|
||||
in
|
||||
{
|
||||
in {
|
||||
options = {
|
||||
|
||||
hostName = mkOption {
|
||||
type = types.str;
|
||||
default = name;
|
||||
@@ -83,6 +79,5 @@ in
|
||||
automatically generated `Caddyfile`.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
{config, pkgs, lib, ...}:
|
||||
let
|
||||
cfg = config.services.satisfactory;
|
||||
in
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config.services.satisfactory;
|
||||
in {
|
||||
options.services.satisfactory = {
|
||||
enable = lib.mkEnableOption "Enable Satisfactory Dedicated Server";
|
||||
|
||||
@@ -56,7 +59,12 @@ in
|
||||
networking = {
|
||||
firewall = {
|
||||
allowedUDPPorts = [15777 15000 7777 27015];
|
||||
allowedUDPPortRanges = [ { from = 27031; to = 27036; } ];
|
||||
allowedUDPPortRanges = [
|
||||
{
|
||||
from = 27031;
|
||||
to = 27036;
|
||||
}
|
||||
];
|
||||
allowedTCPPorts = [27015 27036];
|
||||
};
|
||||
};
|
||||
@@ -76,8 +84,16 @@ in
|
||||
ln -sfv /var/lib/satisfactory/.steam/steam/linux64 /var/lib/satisfactory/.steam/sdk64
|
||||
mkdir -p /var/lib/satisfactory/SatisfactoryDedicatedServer/FactoryGame/Saved/Config/LinuxServer
|
||||
${pkgs.crudini}/bin/crudini --set /var/lib/satisfactory/SatisfactoryDedicatedServer/FactoryGame/Saved/Config/LinuxServer/Game.ini '/Script/Engine.GameSession' MaxPlayers ${toString cfg.maxPlayers}
|
||||
${pkgs.crudini}/bin/crudini --set /var/lib/satisfactory/SatisfactoryDedicatedServer/FactoryGame/Saved/Config/LinuxServer/ServerSettings.ini '/Script/FactoryGame.FGServerSubsystem' mAutoPause ${if cfg.autoPause then "True" else "False"}
|
||||
${pkgs.crudini}/bin/crudini --set /var/lib/satisfactory/SatisfactoryDedicatedServer/FactoryGame/Saved/Config/LinuxServer/ServerSettings.ini '/Script/FactoryGame.FGServerSubsystem' mAutoSaveOnDisconnect ${if cfg.autoSaveOnDisconnect then "True" else "False"}
|
||||
${pkgs.crudini}/bin/crudini --set /var/lib/satisfactory/SatisfactoryDedicatedServer/FactoryGame/Saved/Config/LinuxServer/ServerSettings.ini '/Script/FactoryGame.FGServerSubsystem' mAutoPause ${
|
||||
if cfg.autoPause
|
||||
then "True"
|
||||
else "False"
|
||||
}
|
||||
${pkgs.crudini}/bin/crudini --set /var/lib/satisfactory/SatisfactoryDedicatedServer/FactoryGame/Saved/Config/LinuxServer/ServerSettings.ini '/Script/FactoryGame.FGServerSubsystem' mAutoSaveOnDisconnect ${
|
||||
if cfg.autoSaveOnDisconnect
|
||||
then "True"
|
||||
else "False"
|
||||
}
|
||||
'';
|
||||
script = ''
|
||||
/var/lib/satisfactory/SatisfactoryDedicatedServer/Engine/Binaries/Linux/UnrealServer-Linux-Shipping FactoryGame -multihome=${cfg.address}
|
||||
|
||||
@@ -12,12 +12,6 @@
|
||||
./apps
|
||||
];
|
||||
|
||||
# sops = {
|
||||
# defaultSopsFile = ../../secrets/secrets.yaml;
|
||||
# defaultSopsFormat = "yaml";
|
||||
# age.keyFile = "/home/${device.user}/.config/sops/age/keys.txt";
|
||||
# };
|
||||
|
||||
security.tpm2 = {
|
||||
enable = true;
|
||||
pkcs11.enable = true;
|
||||
|
||||
Reference in New Issue
Block a user