treewide: Reformat project with alejandra

This commit is contained in:
Tristan Daniël Maat 2022-10-10 13:03:08 +01:00
parent 58e52dd119
commit 046a88905d
Signed by: tlater
GPG key ID: 49670FD774E43268
17 changed files with 405 additions and 353 deletions

View file

@ -1,6 +1,9 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}: {
imports = [
./services/gitea.nix
./services/minecraft.nix
@ -18,7 +21,7 @@
'';
# Enable remote builds from tlater
trustedUsers = [ "@wheel" ];
trustedUsers = ["@wheel"];
};
nixpkgs.config.allowUnfreePredicate = pkg:
@ -26,10 +29,10 @@
sops = {
defaultSopsFile = ../keys/external.yaml;
secrets.steam = { };
secrets.steam = {};
};
boot.kernelParams = [ "highres=off" "nohz=off" ];
boot.kernelParams = ["highres=off" "nohz=off"];
networking = {
hostName = "tlaternet";
@ -38,15 +41,15 @@
useDHCP = false;
interfaces.eth0.useDHCP = true;
firewall.allowedTCPPorts = [ 80 443 2222 2221 25565 21025 ];
firewall.allowedTCPPorts = [80 443 2222 2221 25565 21025];
};
time.timeZone = "Europe/London";
users.users.tlater = {
isNormalUser = true;
extraGroups = [ "wheel" ];
openssh.authorizedKeys.keyFiles = [ ../keys/tlater.pub ];
extraGroups = ["wheel"];
openssh.authorizedKeys.keyFiles = [../keys/tlater.pub];
};
services.openssh = {
@ -54,7 +57,7 @@
allowSFTP = false;
passwordAuthentication = false;
permitRootLogin = "no";
ports = [ 2222 ];
ports = [2222];
startWhenNeeded = true;
gatewayPorts = "yes";
};
@ -77,12 +80,13 @@
extraConfig = ''
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
'';
} extra;
}
extra;
domain = config.services.nginx.domain;
in {
"${domain}" = host 3002 { serverAliases = [ "www.${domain}" ]; };
"gitea.${domain}" = host 3000 { };
"nextcloud.${domain}" = host 3001 { };
"${domain}" = host 3002 {serverAliases = ["www.${domain}"];};
"gitea.${domain}" = host 3000 {};
"nextcloud.${domain}" = host 3001 {};
};
};

View file

@ -1,6 +1,4 @@
{ ... }:
{
{...}: {
ids.uids = {
# System user ids start at 400 (see nixos/modules/programs/shadow.nix)
webserver = 400;

View file

@ -1,8 +1,11 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}: {
# Required for the lish console
boot.kernelParams = [ "console=ttyS0,19200n8" ];
boot.kernelParams = ["console=ttyS0,19200n8"];
boot.loader = {
# Timeout to allow lish to connect

View file

@ -1,6 +1,4 @@
{ config, ... }:
{
{config, ...}: {
users = {
extraUsers.gitea = {
uid = config.ids.uids.git;
@ -8,19 +6,19 @@
description = "Gitea Service";
group = config.users.extraGroups.gitea.name;
};
extraGroups.gitea = { gid = config.ids.gids.git; };
extraGroups.gitea = {gid = config.ids.gids.git;};
};
virtualisation.pods.gitea = {
hostname = "gitea.tlater.net";
publish = [ "3000:3000" "2221:2221" ];
publish = ["3000:3000" "2221:2221"];
network = "slirp4netns";
containers = {
gitea = {
image = "gitea/gitea:latest";
volumes = [ "gitea:/data:Z" "/etc/localtime:/etc/localtime:ro" ];
dependsOn = [ "postgres" ];
volumes = ["gitea:/data:Z" "/etc/localtime:/etc/localtime:ro"];
dependsOn = ["postgres"];
environment = {
DB_TYPE = "postgres";
@ -43,7 +41,7 @@
POSTGRES_DB = "gitea";
POSTGRES_USER = "gitea";
};
volumes = [ "gitea-postgres-14:/var/lib/postgresql/data" ];
volumes = ["gitea-postgres-14:/var/lib/postgresql/data"];
};
};
};

View file

@ -1,6 +1,9 @@
{ config, pkgs, lib, ... }:
let
{
config,
pkgs,
lib,
...
}: let
minecraft-server-args = [
"-Xms2G"
"-Xmx2G"
@ -24,12 +27,14 @@ let
"-XX:+PerfDisableSharedMem"
"-XX:MaxTenuringThreshold=1"
];
ops = pkgs.writeText "ops.json" (builtins.toJSON [{
uuid = "140d177a-966f-41b8-a4c0-e305babd291b";
name = "TLATER";
level = 4;
bypassesPlayerLimit = true;
}]);
ops = pkgs.writeText "ops.json" (builtins.toJSON [
{
uuid = "140d177a-966f-41b8-a4c0-e305babd291b";
name = "TLATER";
level = 4;
bypassesPlayerLimit = true;
}
]);
whitelist = pkgs.writeText "whitelist.json" (builtins.toJSON [
{
uuid = "59cd1648-14a4-4bcf-8f5a-2e1bde678f2c";
@ -49,7 +54,6 @@ let
}
]);
eula = pkgs.writeText "eula.txt" "eula=true";
in {
users = {
extraUsers.minecraft = {
@ -58,7 +62,7 @@ in {
isSystemUser = true;
description = "Minecraft server user";
};
extraGroups.minecraft = { gid = config.ids.gids.minecraft; };
extraGroups.minecraft = {gid = config.ids.gids.minecraft;};
};
virtualisation.oci-containers.containers.minecraft-voor-kia = let
@ -83,22 +87,22 @@ in {
uid = toString config.users.extraUsers.minecraft.uid;
gid = toString config.users.extraGroups.minecraft.gid;
in {
Cmd = [ "forge-server" ] ++ minecraft-server-args;
Cmd = ["forge-server"] ++ minecraft-server-args;
WorkingDir = "/var/lib/minecraft";
Volumes = {
"/var/lib/minecraft" = { };
"/var/lib/minecraft" = {};
# Required because some things will try to write to /tmp,
# which doesn't exist if it's not defined as a volume.
"/tmp" = { };
"/tmp" = {};
};
ExposedPorts = { "25565" = { }; };
ExposedPorts = {"25565" = {};};
User = "${uid}:${gid}";
};
};
extraOptions = [ "--cpus=1.0" ];
extraOptions = ["--cpus=1.0"];
autoStart = false;
ports = [ "25565:25565" ];
ports = ["25565:25565"];
volumes = [
"minecraft:/var/lib/minecraft"
"${eula}:/var/lib/minecraft/eula.txt:ro"
@ -111,7 +115,7 @@ in {
systemd.timers.podman-minecraft-voor-kia-off = {
description = "Turns off the minecraft server every day at 4 am";
wantedBy = [ "podman-minecraft-voor-kia.service" ];
wantedBy = ["podman-minecraft-voor-kia.service"];
timerConfig = {
Unit = "podman-minecraft-voor-kia-starter@stop.service";
OnCalendar = "04:00:00";
@ -120,7 +124,7 @@ in {
systemd.timers.podman-minecraft-voor-kia-on = {
description = "Turns on the minecraft server every day at 2 pm";
wantedBy = [ "podman-minecraft-voor-kia.service" ];
wantedBy = ["podman-minecraft-voor-kia.service"];
timerConfig = {
Unit = "podman-minecraft-voor-kia-starter@start.service";
OnCalendar = "14:00:00";
@ -130,8 +134,7 @@ in {
systemd.services."podman-minecraft-voor-kia-starter@" = {
description = "Unit to stop/start the minecraft server";
serviceConfig = {
ExecStart =
"${pkgs.systemd}/bin/systemctl %i podman-minecraft-voor-kia.service";
ExecStart = "${pkgs.systemd}/bin/systemctl %i podman-minecraft-voor-kia.service";
Type = "oneshot";
};
};

View file

@ -1,15 +1,13 @@
{ config, ... }:
{
{config, ...}: {
virtualisation.pods.nextcloud = {
hostname = "nextcloud.tlater.net";
publish = [ "3001:80" ];
publish = ["3001:80"];
network = "slirp4netns";
containers = {
nextcloud = {
image = "nextcloud:fpm-alpine";
dependsOn = [ "postgres" ];
dependsOn = ["postgres"];
volumes = [
"nextcloud-root:/var/www/html"
"nextcloud-apps:/var/www/html/custom_apps"
@ -28,18 +26,18 @@
cron = {
image = "nextcloud:fpm-alpine";
entrypoint = "/cron.sh";
dependsOn = [ "postgres" "nextcloud" ];
extraOptions = [ "--volumes-from=nextcloud-nextcloud" ];
dependsOn = ["postgres" "nextcloud"];
extraOptions = ["--volumes-from=nextcloud-nextcloud"];
};
nginx = {
image = "nginx:alpine";
dependsOn = [ "nextcloud" ];
dependsOn = ["nextcloud"];
volumes = [
"nextcloud-root:/var/www/html:ro"
"${./configs/nginx-nextcloud.conf}:/etc/nginx/nginx.conf:ro"
];
extraOptions = [ "--volumes-from=nextcloud-nextcloud" ];
extraOptions = ["--volumes-from=nextcloud-nextcloud"];
};
postgres = {
@ -48,7 +46,7 @@
POSTGRES_DB = "nextcloud";
POSTGRES_USER = "nextcloud";
};
volumes = [ "nextcloud-postgres-14:/var/lib/postgresql/data" ];
volumes = ["nextcloud-postgres-14:/var/lib/postgresql/data"];
};
};
};

View file

@ -1,6 +1,8 @@
{ config, pkgs, ... }:
{
config,
pkgs,
...
}: {
users = {
extraUsers.webserver = {
uid = config.ids.uids.webserver;
@ -8,7 +10,7 @@
isSystemUser = true;
description = "tlater.net web server user";
};
extraGroups.webserver = { gid = config.ids.gids.webserver; };
extraGroups.webserver = {gid = config.ids.gids.webserver;};
};
virtualisation.oci-containers.containers.webserver = {
@ -23,19 +25,19 @@
uid = toString config.users.extraUsers.webserver.uid;
gid = toString config.users.extraGroups.webserver.gid;
in {
Cmd = [ "tlaternet-webserver" ];
Volumes = { "/srv/mail" = { }; };
Cmd = ["tlaternet-webserver"];
Volumes = {"/srv/mail" = {};};
Env = [
"ROCKET_PORT=3002"
"ROCKET_TEMPLATE_DIR=${pkgs.tlaternet-templates.templates}/browser/"
];
ExposedPorts = { "3002" = { }; };
ExposedPorts = {"3002" = {};};
User = "${uid}:${gid}";
};
};
ports = [ "3002:3002" ];
volumes = [ "tlaternet-mail:/srv/mail" ];
ports = ["3002:3002"];
volumes = ["tlaternet-mail:/srv/mail"];
extraOptions = [
"--hostname=tlater.net"
# Rocket 0.4 doesn't support SIGTERM anyway, so SIGKILL is the cleanest exit possible.