Fediversity/services/fediversity/garage/options.nix

121 lines
3.3 KiB
Nix
Raw Normal View History

{ config, lib, ... }:
2025-02-14 16:17:07 +01:00
let
inherit (lib) types mkOption mkEnableOption;
in
{
options.fediversity.garage = {
ensureBuckets = mkOption {
type = types.attrsOf (
types.submodule {
options = {
website = mkOption {
type = types.bool;
default = false;
};
# I think setting corsRules should allow another website to show images from your bucket
corsRules = {
enable = mkEnableOption "CORS Rules";
allowedHeaders = mkOption {
type = types.listOf types.str;
default = [ ];
2025-02-14 16:17:07 +01:00
};
allowedMethods = mkOption {
type = types.listOf types.str;
default = [ ];
2025-02-14 16:17:07 +01:00
};
allowedOrigins = mkOption {
2025-02-14 16:17:07 +01:00
type = types.listOf types.str;
default = [ ];
};
};
aliases = mkOption {
type = types.listOf types.str;
default = [ ];
};
};
}
);
default = { };
};
ensureKeys = mkOption {
type = types.attrsOf (
types.submodule {
# TODO: these should be managed as secrets, not in the nix store
options = {
2025-02-14 19:01:54 +01:00
s3AccessKey = mkOption { type = types.str; };
s3SecretKey = mkOption { type = types.str; };
# TODO: assert at least one of these is true
# NOTE: this currently needs to be done at the top level module
ensureAccess = mkOption {
type = types.attrsOf (
types.submodule {
options = {
read = mkOption {
type = types.bool;
default = false;
2025-02-14 16:17:07 +01:00
};
write = mkOption {
type = types.bool;
default = false;
};
owner = mkOption {
type = types.bool;
default = false;
};
};
}
);
default = [ ];
2025-02-14 16:17:07 +01:00
};
};
}
);
default = { };
2025-02-14 16:17:07 +01:00
};
api = {
domain = mkOption {
type = types.str;
default = "s3.garage.${config.fediversity.domain}";
};
port = mkOption {
type = types.int;
default = 3900;
};
url = mkOption {
type = types.str;
default = "http://${config.fediversity.garage.api.domain}:${toString config.fediversity.garage.api.port}";
};
};
rpc = {
port = mkOption {
type = types.int;
default = 3901;
};
};
web = {
rootDomain = mkOption {
type = types.str;
default = "web.garage.${config.fediversity.domain}";
};
internalPort = mkOption {
type = types.int;
default = 3902;
};
domainForBucket = mkOption {
type = types.functionTo types.str;
default = bucket: "${bucket}.${config.fediversity.garage.web.rootDomain}";
};
urlForBucket = mkOption {
type = types.functionTo types.str;
default = bucket: "http://${config.fediversity.garage.web.domainForBucket bucket}";
};
};
2025-02-14 16:17:07 +01:00
};
}