feat: add initial config

This commit is contained in:
Katharina Heidenreich 2026-04-04 22:19:24 +02:00
commit fb98563bb6
26 changed files with 576 additions and 0 deletions

7
services/default.nix Normal file
View file

@ -0,0 +1,7 @@
{ ... }:
{
imports = [
./openssh.nix
./nginx.nix
];
}

25
services/nginx.nix Normal file
View file

@ -0,0 +1,25 @@
{ config, lib, ... }:
let
serviceConfig = import ../config/services.nix;
nginxModel = import ../intermediate/nginx.nix;
in
{
assertions = [
{
assertion = nginxModel.validatedEndpoints != [];
message = "No endpoints configured. Add endpoint declarations under config/endpoints/.";
}
];
services.nginx = {
enable = serviceConfig.nginx.enable;
recommendedProxySettings = true;
recommendedTlsSettings = true;
recommendedOptimisation = true;
recommendedGzipSettings = true;
streamConfig = nginxModel.streamConfig;
};
networking.firewall.allowedTCPPorts = nginxModel.nginxUsedPorts;
}

32
services/openssh.nix Normal file
View file

@ -0,0 +1,32 @@
{ ... }:
let
lib = import <nixpkgs/lib>;
opensshConfig = import ../config/openssh.nix;
userExtraConfig =
if opensshConfig ? extraConfig && opensshConfig.extraConfig ? users && builtins.isAttrs opensshConfig.extraConfig.users then
opensshConfig.extraConfig.users
else
{};
renderedUserMatches = lib.concatStringsSep "\n" (
lib.mapAttrsToList (user: cfg: ''
Match User ${user}
${cfg}
'') userExtraConfig
);
in
{
services.openssh = {
enable = true;
settings = {
PasswordAuthentication = true;
PermitRootLogin = "no";
GatewayPorts = "no";
AllowUsers = opensshConfig.ssh_users;
};
extraConfig = renderedUserMatches;
};
networking.firewall.allowedTCPPorts = [ 22 ];
}