nix/moduler/services/filebrowser/default.nix
2026-02-18 17:36:16 +01:00

52 lines
1.2 KiB
Nix

{
lib,
pkgs,
config,
...
}:
with lib;
{
options = {
filebrowser = {
enable = mkEnableOption "enables filebrowser";
port = lib.mkOption {
type = lib.types.int;
default = 8887;
description = "The port filebrowser listens on.";
};
host = mkOption {
type = types.str;
defaultText = literalExpression "127.0.0.1";
description = "The hostname that filebrowser binds to";
};
domain = mkOption {
type = types.str;
defaultText = literalExpression "files.wastring.com";
description = "The hostname that filebrowser binds to";
};
};
};
config = mkMerge [
(mkIf config.filebrowser.enable {
services.filebrowser = {
enable = true;
settings = {
address = config.filebrowser.host;
port = config.filebrowser.port;
};
};
services.nginx.virtualHosts.${config.filebrowser.domain} = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://${toString config.filebrowser.host}:${toString config.filebrowser.port}";
proxyWebsockets = true;
};
};
})
];
}