Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
cd5b2528e9
|
|||
d53405e39e
|
|||
f3424680f2
|
23
flake.nix
23
flake.nix
@ -68,27 +68,16 @@
|
|||||||
helios = nixosSystem { system = "x86_64-linux"; name = "helios"; };
|
helios = nixosSystem { system = "x86_64-linux"; name = "helios"; };
|
||||||
odyssey = nixosSystem { system = "x86_64-linux"; name = "odyssey"; };
|
odyssey = nixosSystem { system = "x86_64-linux"; name = "odyssey"; };
|
||||||
pi = nixosSystem { system = "aarch64-linux"; name = "pi"; extraModules = [ nixos-hardware.nixosModules.raspberry-pi-4 ]; };
|
pi = nixosSystem { system = "aarch64-linux"; name = "pi"; extraModules = [ nixos-hardware.nixosModules.raspberry-pi-4 ]; };
|
||||||
vps1 = nixosSystem { system = "x86_64-linux"; name = "vps1"; };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
deploy.nodes = {
|
deploy.nodes.pi = {
|
||||||
pi = {
|
hostname = "10.0.1.191";
|
||||||
hostname = "10.0.1.191";
|
sshUser = "root";
|
||||||
sshUser = "jordan";
|
|
||||||
user = "root";
|
|
||||||
|
|
||||||
profiles.system = {
|
profiles.system = {
|
||||||
user = "root";
|
user = "root";
|
||||||
path = deploy-rs.lib.aarch64-linux.activate.nixos self.nixosConfigurations.pi;
|
path = deploy-rs.lib.aarch64-linux.activate.nixos self.nixosConfigurations.pi;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
vps1 = {
|
|
||||||
magicRollback = true;
|
|
||||||
autoRollback = true;
|
|
||||||
hostname = "vps1.mesh.vimium.net";
|
|
||||||
profiles.system = {
|
|
||||||
user = "root";
|
|
||||||
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.vps1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
|
# checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
|
||||||
|
30
hosts/new.md
Normal file
30
hosts/new.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Steps to add a new host
|
||||||
|
|
||||||
|
1. Generate an SSH host key to be used for secrets
|
||||||
|
`ssh-keygen -t ed25519 -f /tmp/ssh_host_ed25519_key -C ""`
|
||||||
|
1. Go to borgmatic.com, add the generated SSH key and create a new
|
||||||
|
repository
|
||||||
|
1. Add a new host entry to nix-secrets/secrets.nix
|
||||||
|
1. Generate a repository passphrase in nix-secrets
|
||||||
|
1. Commit nix-secrets and run `nix flake update` in nix-config
|
||||||
|
1. Add a README.md and default.nix suited to the host
|
||||||
|
1. Define (or generate with `nixos-generate-config`) a
|
||||||
|
hardware-configuration.nix
|
||||||
|
1. Define the disk layout to be used by disko
|
||||||
|
1. Commit nix-config
|
||||||
|
1. Boot the NixOS installer
|
||||||
|
1. Copy the generated SSH host key to `/etc/ssh`
|
||||||
|
1. Run `nix run github:nix-community/nixos-anywhere -- --flake .#<hostname> root@<ip address>`
|
||||||
|
|
||||||
|
## Post install
|
||||||
|
> The backup and Tailscale modules won't work until the following steps are
|
||||||
|
> completed.
|
||||||
|
|
||||||
|
1. Run `sudo borgmatic init --encryption repokey-blake2`
|
||||||
|
1. Restart `borgmatic`
|
||||||
|
1. Run `sudo tailscale up --login-server https://headscale.vimium.net`
|
||||||
|
1. Visit the URL, then SSH onto `vps1` and run
|
||||||
|
`headscale --user mesh nodes register --key <key>`
|
||||||
|
1. (Optionally) Give the Tailscale node a friendly name with
|
||||||
|
`headscale node rename -i <index> <hostname>`
|
||||||
|
|
@ -1,17 +0,0 @@
|
|||||||
# vps1
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
VPS hosted in OVH.
|
|
||||||
|
|
||||||
## Specs
|
|
||||||
* CPU - ??
|
|
||||||
* Memory - ??
|
|
||||||
|
|
||||||
### Disks
|
|
||||||
Device | Partitions _(filesystem, usage)_
|
|
||||||
--- | ---
|
|
||||||
NVMe | `/dev/sda1` (ext4, NixOS Root)
|
|
||||||
|
|
||||||
### Networks
|
|
||||||
- DHCP on `10.0.1.0/24` subnet.
|
|
||||||
- Tailscale on `100.64.0.0/10` subnet. FQDN: `vps1.mesh.vimium.net`.
|
|
@ -1,195 +0,0 @@
|
|||||||
{ config, lib, pkgs, inputs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
./hardware-configuration.nix
|
|
||||||
../server.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
networking = {
|
|
||||||
hostId = "???";
|
|
||||||
hostName = "vps1";
|
|
||||||
domain = "mesh.vimium.net";
|
|
||||||
firewall = {
|
|
||||||
enable = true;
|
|
||||||
allowedTCPPorts = [
|
|
||||||
22 # SSH
|
|
||||||
8448 # Matrix federation
|
|
||||||
80 # HTTP
|
|
||||||
443 # HTTPS
|
|
||||||
5349 # STUN TLS
|
|
||||||
5350 # STUN TLS alt
|
|
||||||
];
|
|
||||||
allowedUDPPortRanges = [
|
|
||||||
{ from = 49152; to = 49999; } # TURN relay
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
users.users = {
|
|
||||||
git = {
|
|
||||||
isSystemUser = true;
|
|
||||||
useDefaultShell = true;
|
|
||||||
group = "git";
|
|
||||||
extraGroups = [ "gitea" ];
|
|
||||||
home = config.services.gitea.stateDir;
|
|
||||||
};
|
|
||||||
jellyfin = {
|
|
||||||
isSystemUser = true;
|
|
||||||
group = "jellyfin";
|
|
||||||
shell = "/bin/sh";
|
|
||||||
openssh.authorizedKeys.keys = [
|
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOaaS+KMAEAymZhIJGC4LK8aMhUzhpmloUgvP2cxeBH4 jellyfin"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
root = {
|
|
||||||
openssh.authorizedKeys.keys = [
|
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILVHTjsyMIV4THNw6yz0OxAxGnC+41gX72UrPqTzR+OS jordan@vimium.com"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
users.groups = {
|
|
||||||
git = { };
|
|
||||||
jellyfin = { };
|
|
||||||
};
|
|
||||||
|
|
||||||
age.secrets."passwords/services/borg/vps1-passphrase" = {
|
|
||||||
file = "${inputs.secrets}/passwords/services/borg/vps1-passphrase.age";
|
|
||||||
};
|
|
||||||
|
|
||||||
services.borgmatic = {
|
|
||||||
enable = true;
|
|
||||||
settings = {
|
|
||||||
source_directories = [
|
|
||||||
"/home"
|
|
||||||
"/var/lib"
|
|
||||||
"/var/www"
|
|
||||||
];
|
|
||||||
repositories = [
|
|
||||||
{ label = "borgbase"; path = "ssh://p91y8oh7@p91y8oh7.repo.borgbase.com/./repo"; }
|
|
||||||
];
|
|
||||||
storage = {
|
|
||||||
encryption_passcommand = "cat ${config.age.secrets."passwords/services/borg/vps1-passphrase".path}";
|
|
||||||
ssh_command = "ssh -i /etc/ssh/ssh_host_ed25519_key";
|
|
||||||
};
|
|
||||||
retention = {
|
|
||||||
keep_daily = 7;
|
|
||||||
keep_weekly = 4;
|
|
||||||
keep_monthly = 6;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# Without this override, `cat` is unavailable for `encryption_passcommand`
|
|
||||||
systemd.services.borgmatic.confinement.fullUnit = true;
|
|
||||||
|
|
||||||
age.secrets."passwords/services/coturn/shared-secret" = {
|
|
||||||
file = "${inputs.secrets}/passwords/services/coturn/shared-secret.age";
|
|
||||||
};
|
|
||||||
|
|
||||||
services.coturn = {
|
|
||||||
enable = true;
|
|
||||||
lt-cred-mech = true;
|
|
||||||
use-auth-secret = true;
|
|
||||||
static-auth-secret = "???";
|
|
||||||
realm = "turn.vimium.com";
|
|
||||||
relay-ips = [
|
|
||||||
"198.244.190.160"
|
|
||||||
];
|
|
||||||
no-tcp-relay = true;
|
|
||||||
extraConfig = ''
|
|
||||||
cipher-list="HIGH"
|
|
||||||
no-loopback-peers
|
|
||||||
no-multicast-peers
|
|
||||||
'';
|
|
||||||
secure-stun = true;
|
|
||||||
cert = "/var/lib/acme/turn.vimium.com/fullchain.pem";
|
|
||||||
pkey = "/var/lib/acme/turn.vimium.com/key.pem";
|
|
||||||
min-port = 49152;
|
|
||||||
max-port = 49999;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.gitea = rec {
|
|
||||||
package = pkgs.gitea;
|
|
||||||
enable = true;
|
|
||||||
user = "git";
|
|
||||||
appName = "Vimium Git";
|
|
||||||
stateDir = "/var/lib/gitea";
|
|
||||||
repositoryRoot = "${stateDir}/repositories";
|
|
||||||
database = {
|
|
||||||
type = "sqlite3";
|
|
||||||
inherit user;
|
|
||||||
path = "${stateDir}/gitea.db";
|
|
||||||
};
|
|
||||||
lfs = {
|
|
||||||
enable = true;
|
|
||||||
contentDir = "${stateDir}/lfs";
|
|
||||||
};
|
|
||||||
settings = {
|
|
||||||
server = {
|
|
||||||
SSH_USER = "git";
|
|
||||||
SSH_DOMAIN = "git.vimium.com";
|
|
||||||
SSH_PORT = lib.head config.services.openssh.ports;
|
|
||||||
OFFLINE_MODE = true;
|
|
||||||
PROTOCOL = "http+unix";
|
|
||||||
DOMAIN = config.networking.domain;
|
|
||||||
ROOT_URL = "https://git.vimium.com/";
|
|
||||||
};
|
|
||||||
service.DISABLE_REGISTRATION = true;
|
|
||||||
session.COOKIE_SECURE = true;
|
|
||||||
log.ROOT_PATH = "${stateDir}/log";
|
|
||||||
ui = {
|
|
||||||
THEMES = "gitea,arc-green,github-dark,bthree-dark";
|
|
||||||
DEFAULT_THEME = "github-dark";
|
|
||||||
};
|
|
||||||
actions.ENABLED = true;
|
|
||||||
indexer = {
|
|
||||||
REPO_INDEXER_ENABLED = true;
|
|
||||||
};
|
|
||||||
packages.CHUNKED_UPLOAD_PATH = lib.mkForce "${stateDir}/data/tmp/package-upload";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services.headscale = {
|
|
||||||
enable = true;
|
|
||||||
port = 8080;
|
|
||||||
settings = {
|
|
||||||
server_url = "https://headscale.vimium.net";
|
|
||||||
dns_config = {
|
|
||||||
base_domain = "vimium.net";
|
|
||||||
};
|
|
||||||
logtail.enabled = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services.matrix-synapse = {
|
|
||||||
enable = true;
|
|
||||||
settings = {
|
|
||||||
database.name = "sqlite3";
|
|
||||||
enable_registration = false;
|
|
||||||
server_name = "vimium.com";
|
|
||||||
turn_shared_secret = "???";
|
|
||||||
turn_uris = [
|
|
||||||
"turn:turn.vimium.com:5349?transport=udp"
|
|
||||||
"turn:turn.vimium.com:5350?transport=udp"
|
|
||||||
"turn:turn.vimium.com:5349?transport=tcp"
|
|
||||||
"turn:turn.vimium.com:5350?transport=tcp"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services.tailscale.enable = true;
|
|
||||||
networking.firewall = {
|
|
||||||
checkReversePath = "loose";
|
|
||||||
trustedInterfaces = [ "tailscale0" ];
|
|
||||||
allowedUDPPorts = [ config.services.tailscale.port ];
|
|
||||||
};
|
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
config.services.headscale.package
|
|
||||||
];
|
|
||||||
|
|
||||||
system.stateVersion = "22.11";
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
|||||||
{ config, lib, pkgs, modulesPath, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
(modulesPath + "/profiles/qemu-guest.nix")
|
|
||||||
];
|
|
||||||
|
|
||||||
boot = {
|
|
||||||
initrd = {
|
|
||||||
availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi" ];
|
|
||||||
kernelModules = [ "nvme" ];
|
|
||||||
};
|
|
||||||
loader.grub.device = "/dev/sda";
|
|
||||||
tmp.cleanOnBoot = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
zramSwap.enable = true;
|
|
||||||
|
|
||||||
fileSystems = {
|
|
||||||
"/" = {
|
|
||||||
device = "/dev/sda1";
|
|
||||||
fsType = "ext4";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
Reference in New Issue
Block a user