infrastructure

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 78ddb8cbef88016bf348b777f404f2be44443ad4
parent 6d52016d9f9d152cf629fa5146ee7429ec1c6013
Author: Silas Brack <silasbrack@gmail.com>
Date:   Sat,  7 Mar 2026 18:58:44 +0100

Add mkv support

Diffstat:
Mflake.lock | 45++++++++++++++++++++++++++++++++++++++++-----
Mflake.nix | 4+++-
Mnixos/configuration-debian-2gb-hel1-1.nix | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
3 files changed, 106 insertions(+), 22 deletions(-)

diff --git a/flake.lock b/flake.lock @@ -1,7 +1,41 @@ { "nodes": { + "mkv": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1772902815, + "narHash": "sha256-/NwbSIDQbpqiIDkHpYXxiN4ivZBZxJ3pvW6JktWMkzY=", + "ref": "refs/heads/main", + "rev": "c4c8fdd735b3cb9e47de6307032ef43d0a7a8c9d", + "revCount": 24, + "type": "git", + "url": "ssh://git@github.com/silasbrack/mkv" + }, + "original": { + "type": "git", + "url": "ssh://git@github.com/silasbrack/mkv" + } + }, "nixpkgs": { "locked": { + "lastModified": 1772773019, + "narHash": "sha256-E1bxHxNKfDoQUuvriG71+f+s/NT0qWkImXsYZNFFfCs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "aca4d95fce4914b3892661bcb80b8087293536c6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { "lastModified": 1767313136, "narHash": "sha256-16KkgfdYqjaeRGBaYsNrhPRRENs0qzkQVUooNHtoy2w=", "owner": "NixOS", @@ -16,7 +50,7 @@ "type": "github" } }, - "nixpkgs_2": { + "nixpkgs_3": { "locked": { "lastModified": 1757347588, "narHash": "sha256-tLdkkC6XnsY9EOZW9TlpesTclELy8W7lL2ClL+nma8o=", @@ -32,7 +66,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1769740369, "narHash": "sha256-xKPyJoMoXfXpDM5DFDZDsi9PHArf2k5BJjvReYXoFpM=", @@ -100,14 +134,15 @@ }, "root": { "inputs": { - "nixpkgs": "nixpkgs", + "mkv": "mkv", + "nixpkgs": "nixpkgs_2", "simple-web-app": "simple-web-app", "sops-nix": "sops-nix" } }, "simple-web-app": { "inputs": { - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "pyproject-build-systems": "pyproject-build-systems", "pyproject-nix": "pyproject-nix", "uv2nix": "uv2nix" @@ -128,7 +163,7 @@ }, "sops-nix": { "inputs": { - "nixpkgs": "nixpkgs_3" + "nixpkgs": "nixpkgs_4" }, "locked": { "lastModified": 1770145881, diff --git a/flake.nix b/flake.nix @@ -3,12 +3,14 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; sops-nix.url = "github:Mic92/sops-nix"; simple-web-app.url = "github:silasbrack/simple-web-app"; + mkv.url = "git+ssh://git@github.com/silasbrack/mkv"; }; outputs = { nixpkgs, sops-nix, simple-web-app, + mkv, ... }: let @@ -34,7 +36,7 @@ system, ... }: - import ./nixos/configuration-debian-2gb-hel1-1.nix (inputs // { inherit simple-web-app; }) + import ./nixos/configuration-debian-2gb-hel1-1.nix (inputs // { inherit simple-web-app mkv; }) ) ]; }; diff --git a/nixos/configuration-debian-2gb-hel1-1.nix b/nixos/configuration-debian-2gb-hel1-1.nix @@ -2,6 +2,7 @@ pkgs, config, simple-web-app, + mkv, ... }: { @@ -71,22 +72,22 @@ restartUnits = [ "wg-quick-wg0.service" ]; }; - # networking.wg-quick.interfaces = { - # wg0 = { - # address = [ "10.100.0.7/24" ]; - # dns = [ "10.100.0.1" ]; - # listenPort = 10232; - # privateKeyFile = "/run/secrets/hetzner_wireguard_key"; - # peers = [ - # { - # publicKey = "2jWfr5UmACvuS+0HOfSNgEUYqoqVNnfVDoaatmgEykw="; - # allowedIPs = [ "0.0.0.0/0" ]; - # endpoint = "188.166.127.72:51820"; - # persistentKeepalive = 25; - # } - # ]; - # }; - # }; + networking.wg-quick.interfaces = { + wg0 = { + address = [ "10.100.0.7/24" ]; + dns = [ "10.100.0.1" ]; + listenPort = 10232; + privateKeyFile = "/run/secrets/hetzner_wireguard_key"; + peers = [ + { + publicKey = "2jWfr5UmACvuS+0HOfSNgEUYqoqVNnfVDoaatmgEykw="; + allowedIPs = [ "10.100.0.0/24" ]; + endpoint = "188.166.127.72:51820"; + persistentKeepalive = 25; + } + ]; + }; + }; users.users = { root.openssh.authorizedKeys.keys = [ @@ -159,4 +160,50 @@ # }; # }; # }; + + # Create mkv volume directory + systemd.tmpfiles.rules = [ + "d /mnt/volume-hel1-1/mkv 0755 nginx nginx -" + ]; + + # mkv key-value store + systemd.services.mkv = { + description = "mkv distributed key-value store"; + wantedBy = [ "multi-user.target" ]; + after = [ "network-online.target" "wg-quick-wg0.service" "nginx.service" ]; + wants = [ "network-online.target" ]; + requires = [ "wg-quick-wg0.service" ]; + environment = { + MKV_DB = "/var/lib/mkv/index.db"; + MKV_VOLUMES = "http://10.100.0.7:8081,http://10.100.0.4:8081"; + MKV_REPLICAS = "2"; + MKV_PORT = "3000"; + }; + serviceConfig = { + Type = "simple"; + DynamicUser = true; + StateDirectory = "mkv"; + ExecStart = "${mkv.packages.x86_64-linux.default}/bin/mkv serve"; + Restart = "on-failure"; + RestartSec = 5; + }; + }; + + # nginx WebDAV volume server for mkv (VPN only) + services.nginx.virtualHosts."mkv-volume" = { + listen = [ + { addr = "10.100.0.7"; port = 8081; } + ]; + root = "/mnt/volume-hel1-1/mkv"; + extraConfig = '' + autoindex on; + autoindex_format json; + dav_methods PUT DELETE; + create_full_put_path on; + client_max_body_size 256M; + ''; + }; + + # Allow mkv and volume ports on VPN interface only + networking.firewall.interfaces.wg0.allowedTCPPorts = [ 3000 8081 ]; }