nixfiles/hosts/hetzner-arm/containers/storage/storage.nix

112 lines
2.6 KiB
Nix
Raw Normal View History

{
2023-09-18 03:56:58 +01:00
self,
tree,
lib,
inputs,
pkgs,
...
}: let
2023-09-18 03:56:58 +01:00
inherit (lib.attrsets) attrValues;
2024-07-24 14:32:44 +01:00
inherit (lib.lists) flatten;
2023-09-18 03:56:58 +01:00
2024-07-24 17:00:54 +01:00
containerAddresses = import "${self}/hosts/hetzner-arm/data/containerAddresses.nix";
2023-09-18 03:56:58 +01:00
hostIP = containerAddresses.host;
containerIP = containerAddresses.containers.storage;
2023-09-02 16:10:12 +01:00
# 32GB
clientMaxBodySize = "${toString (8192 * 4)}M";
2023-09-18 03:56:58 +01:00
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;
2023-09-18 03:56:58 +01:00
inherit self;
};
config = {...}: {
nixpkgs.pkgs = pkgs;
2024-07-24 14:32:44 +01:00
imports = flatten (with tree; [
presets.nixos.containerBase
(with hosts.hetzner-arm.containers.storage.profiles; [
2023-09-18 03:56:58 +01:00
rcloneConfigs
rcloneServe
rcloneSync
users
2024-07-24 14:32:44 +01:00
])
./secrets.nix
]);
environment.systemPackages = with pkgs; [
rclone
2024-07-24 14:32:44 +01:00
fuse
fuse3
];
networking.firewall = {
enable = true;
2023-09-18 03:56:58 +01:00
allowedTCPPorts = attrValues ports;
};
home-manager.users.root.home.stateVersion = "24.05";
system.stateVersion = "24.05";
};
};
services.nginx.virtualHosts."storage-webdav.owo.monster" = {
forceSSL = true;
enableACME = true;
locations = {
"/Main/".proxyPass = "http://${containerIP}:${toString ports.webdav_main}";
"/MusicRO/".proxyPass = "http://${containerIP}:${toString ports.webdav_music_ro}";
"/Uploads/".proxyPass = "http://${containerIP}:${toString ports.webdav_uploads}";
2024-04-26 19:58:03 +01:00
"/Notes/".proxyPass = "http://${containerIP}:${toString ports.webdav_notes}";
};
2023-09-02 16:10:12 +01:00
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}";
};
2023-09-02 16:10:12 +01:00
extraConfig = ''
client_max_body_size ${clientMaxBodySize};
'';
};
}