1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/systems/ful/configuration.nix

161 lines
4.2 KiB
Nix
Raw Normal View History

2022-05-20 23:04:15 +02:00
{
config,
pkgs,
2024-07-10 12:57:07 +02:00
lib,
2022-05-20 23:04:15 +02:00
...
}: let
inherit (import ../../lib) kieran retiolumAddresses restic;
2022-05-20 23:04:15 +02:00
in {
imports = [
./hardware-configuration.nix
2023-02-16 08:46:18 +01:00
./matomo.nix
./radio.nix
2023-03-24 17:00:44 +01:00
./panoptikon.nix
2023-10-30 14:26:50 +01:00
./hledger.nix
2024-11-15 09:48:11 +01:00
./alew.nix
../../configs/monitoring.nix
2025-03-04 21:48:01 +01:00
../../configs/mycelium.nix
2023-03-22 07:47:57 +01:00
../../configs/tor.nix
../../configs/save-space.nix
../../configs/spacetime.nix
../../configs/retiolum.nix
../../configs/sshd.nix
../../configs/nix.nix
../../configs/admin-essentials.nix
2022-05-20 23:04:15 +02:00
];
niveum.passport = {
enable = true;
introductionHTML = ''
'';
virtualHost = "ful.r";
services = [
{
title = "restic backup";
description = "This machine backups its state via restic backup.";
}
];
};
age.secrets = {
2023-02-28 16:45:20 +01:00
retiolum-rsa = {
file = ../../secrets/ful-retiolum-privateKey-rsa.age;
2023-02-28 16:45:20 +01:00
mode = "400";
2024-06-03 07:27:01 +02:00
owner = "tinc-retiolum";
group = "tinc-retiolum";
2023-02-28 16:45:20 +01:00
};
retiolum-ed25519 = {
file = ../../secrets/ful-retiolum-privateKey-ed25519.age;
2023-02-28 16:45:20 +01:00
mode = "400";
2024-06-03 07:27:01 +02:00
owner = "tinc-retiolum";
group = "tinc-retiolum";
2023-02-28 16:45:20 +01:00
};
root.file = ../../secrets/ful-root.age;
restic.file = ../../secrets/restic.age;
};
2023-02-16 08:46:18 +01:00
services.restic.backups.niveum = {
initialize = true;
inherit (restic) repository;
timerConfig = {
OnCalendar = "daily";
RandomizedDelaySec = "1h";
};
passwordFile = config.age.secrets.restic.path;
2023-02-16 08:46:18 +01:00
paths = [
config.services.mysqlBackup.location
];
};
users.users.servant = {
isSystemUser = true;
group = "servant";
};
users.groups.servant = {};
systemd.services.servant = {
enable = true;
environment.PORT = toString 18987;
2024-07-10 12:57:07 +02:00
environment.VIRTUAL_HOST = "https://openapiaiapi.kmein.de";
serviceConfig.ExecStart = pkgs.writers.writeHaskell "server" {
libraries = with pkgs.haskellPackages; [
servant
servant-server
servant-openapi3
servant-swagger-ui
servant-client
aeson
text
warp
uuid
lens
];
ghcArgs = ["-O3" "-threaded"];
} ./servant-openapi.hs;
serviceConfig.User = "servant";
serviceConfig.Group = "servant";
};
2024-07-10 12:57:07 +02:00
services.htgen.openapi-conversion = {
port = 18988;
script = ''. ${pkgs.writers.writeDash "openapi-conversion" ''
case "$Method $Request_URI" in
"GET /openapi-3.1.json")
schema=$(mktemp -d)
trap 'rm -rf $schema' EXIT
${pkgs.wget}/bin/wget http://127.0.0.1:${toString 18987}/openapi.json -O "$schema"/openapi.json
cat "$schema"/openapi.json >&2
PATH=${lib.makeBinPath [pkgs.bashInteractive pkgs.nodejs]} ${pkgs.nodejs}/bin/npx --yes openapi-format "$schema"/openapi.json --convertTo "3.1" -o "$schema"/openapi-new.json
printf 'HTTP/1.1 200 OK\r\n'
printf 'Content-Type: %s\r\n' "$(${pkgs.file}/bin/file -ib "$schema"/openapi-new.json)"
printf 'Server: %s\r\n' "$Server"
printf 'Connection: close\r\n'
printf 'Content-Length: %d\r\n' $(${pkgs.coreutils}/bin/wc -c < "$schema"/openapi-new.json)
printf '\r\n'
cat "$schema"/openapi-new.json
exit
;;
esac
''}'';
};
services.nginx.virtualHosts."openapiaiapi.kmein.de" = {
enableACME = true;
forceSSL = true;
2024-07-10 12:57:07 +02:00
locations."/openapi-3.1.json".proxyPass = "http://127.0.0.1:${toString 18988}";
locations."/".proxyPass = "http://127.0.0.1:${toString 18987}";
};
2022-05-20 23:04:15 +02:00
networking = {
firewall.allowedTCPPorts = [80 443];
hostName = "ful";
interfaces.enp0s3.useDHCP = true;
retiolum = retiolumAddresses.ful;
useDHCP = false;
};
system.stateVersion = "21.11";
services.nginx = {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
sslCiphers = "AES256+EECDH:AES256+EDH:!aNULL";
};
security.acme = {
acceptTerms = true;
2022-07-19 21:33:45 +02:00
defaults.email = kieran.email;
2022-05-20 23:04:15 +02:00
};
2023-12-06 14:41:49 +01:00
users.users.root.hashedPasswordFile = config.age.secrets.root.path;
2022-05-21 23:06:49 +02:00
2022-05-20 23:04:15 +02:00
environment.systemPackages = [pkgs.vim pkgs.git pkgs.tmux pkgs.python3];
# since 22.05 timeout fails?
2023-06-06 19:59:27 +02:00
# systemd.services.systemd-networkd-wait-online.enable = false;
2022-05-20 23:04:15 +02:00
}