{ self, tree, lib, inputs, pkgs, ... }: let inherit (lib.attrsets) attrValues; inherit (lib.lists) flatten; containerAddresses = import "${self}/hosts/hetzner-arm/data/containerAddresses.nix"; hostIP = containerAddresses.host; containerIP = containerAddresses.containers.storage; clientMaxBodySize = "${toString (1024 * 128)}M"; ports = import ./data/ports.nix; in { containers.storage = { autoStart = true; privateNetwork = true; hostAddress = hostIP; localAddress = containerIP; bindMounts = { "/dev/fuse" = { hostPath = "/dev/fuse"; isReadOnly = false; }; }; # Allow rclone mount in container allowedDevices = [ { modifier = "rwm"; node = "/dev/fuse"; } { modifier = "rwm"; node = "/dev/mapper/control"; } ]; specialArgs = { inherit inputs; inherit tree; inherit self; }; config = {...}: { nixpkgs.pkgs = pkgs; imports = flatten (with tree; [ presets.nixos.containerBase (with hosts.hetzner-arm.containers.storage.profiles; [ rcloneConfigs rcloneServe users ]) ./secrets.nix ]); environment.systemPackages = with pkgs; [ rclone fuse fuse3 ]; networking.firewall = { enable = true; allowedTCPPorts = flatten [ (attrValues ports.webdav) (attrValues ports.http) ]; }; home-manager.users.root.home.stateVersion = "25.05"; system.stateVersion = "25.05"; }; }; services.nginx.virtualHosts."storage-webdav.owo.monster" = { forceSSL = true; enableACME = true; locations = { "/Public/".proxyPass = "http://${containerIP}:${toString ports.webdav.public}"; "/Uploads/".proxyPass = "http://${containerIP}:${toString ports.webdav.uploads}"; }; extraConfig = '' client_max_body_size ${clientMaxBodySize}; ''; }; services.nginx.virtualHosts."storage-http.owo.monster" = { forceSSL = true; enableACME = true; locations = { "/Music/".proxyPass = "http://${containerIP}:${toString ports.http.music}"; "/Public/".proxyPass = "http://${containerIP}:${toString ports.http.public}"; "/Uploads/".proxyPass = "http://${containerIP}:${toString ports.http.uploads_public}"; }; extraConfig = '' client_max_body_size ${clientMaxBodySize}; ''; }; }