- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
{
config,
lib,
pkgs,
...
}:
{
# TODO: Make nix run work more reliably on Hyades
nixpkgs.hostPlatform = "x86_64-linux";
networking = {
# Even though some hex string ends up in /etc/hostname, this is still used for Nix store paths
hostName = "Unnamed-Server";
# No need for a firewall when inside a network namespace on Hyades
firewall.enable = false;
# Disable dhcpcd which makes networking really slow
dhcpcd.enable = false;
# Hardcode the MIT nameservers
nameservers = [
"18.0.70.160"
"18.0.72.3"
"18.0.71.151"
];
};
# The best time zone
time.timeZone = "UTC";
users.users.a = {
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPDLPakDnAelqFTUudQB8X0T7yc/8ekV3jGqpeJb062l anthonywang"
];
# krun virtiofs doesn't support ACLs so manually give myself permission to see the journal
extraGroups = [ "systemd-journal" ];
};
programs.tmux.enable = true;
# Include journal in Podman output
services.journald.console = "/dev/console";
services.openssh = {
enable = true;
ports = [ 2222 ];
settings = {
# https://forgejo.org/docs/latest/admin/recommendations/#git-over-ssh
# https://docs.gitlab.com/administration/git_protocol/
# Test using GIT_TRACE_PACKET=1 git ls-remote
AcceptEnv = [ "GIT_PROTOCOL" ];
# Don't hack me
PasswordAuthentication = false;
PermitRootLogin = "no";
};
# Put host keys in a volume instead
generateHostKeys = false;
extraConfig = ''
HostKey /etc/ssh/keys/ssh_host_rsa_key
HostKey /etc/ssh/keys/ssh_host_ed25519_key
'';
};
# My websites
services.caddy = {
enable = true;
# TLS is handled by Hyades
globalConfig = ''
auto_https off
'';
virtualHosts = {
"http://unnamed.website".extraConfig = ''
root * /srv/http/www
file_server
handle_errors {
rewrite * /{err.status_code}.html
file_server
}
'';
"http://git.unnamed.website".extraConfig = ''
reverse_proxy localhost:5555
'';
"http://*.unnamed.website".extraConfig = ''
root * /srv/http/{labels.2}
# Enable the file browser by default, can disable by creating an empty index.html
file_server browse
'';
"http://a.exozy.me http://ta180m.exozy.me".extraConfig = ''
redir https://unnamed.website{uri} permanent
'';
};
};
# Git server
# It's possible to nuke Python by using fishMinimal and gitMinimal but eh it doesn't save that much space and is a hassle
services.legit = {
enable = true;
config = {
meta = {
title = "Typeclass instance problem is stuck";
description = "It is often due to incompetence";
syntaxHighlight = true;
};
repo = {
diff = "system";
mainBranch = [
"main"
"master"
];
readme = [ "README.md" ];
scanPath = "/srv/git";
trimDotGitSuffix = true;
};
server.name = "git.unnamed.website";
ui.footer.poweredBy = true;
};
};
systemd = {
# Update Git mirrors
services.update-mirrors = {
path = [ pkgs.git ];
serviceConfig = {
User = "a";
Group = "users";
ExecStart = pkgs.writers.writeFish "update-mirrors" ./update-mirrors.fish;
};
};
timers.update-mirrors = {
wantedBy = [ "multi-user.target" ];
timerConfig.OnCalendar = "weekly";
};
};
}