2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.minio;
|
2021-07-03 03:11:41 +00:00
|
|
|
|
|
|
|
legacyCredentials = cfg: pkgs.writeText "minio-legacy-credentials" ''
|
|
|
|
MINIO_ROOT_USER=${cfg.accessKey}
|
|
|
|
MINIO_ROOT_PASSWORD=${cfg.secretKey}
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
meta.maintainers = [ maintainers.bachp ];
|
|
|
|
|
|
|
|
options.services.minio = {
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "Minio Object Storage");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
listenAddress = mkOption {
|
|
|
|
default = ":9000";
|
|
|
|
type = types.str;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "IP address and port of the server.";
|
2021-08-11 14:56:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
consoleAddress = mkOption {
|
|
|
|
default = ":9001";
|
|
|
|
type = types.str;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "IP address and port of the web UI (console).";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = mkOption {
|
2021-04-13 19:44:15 +00:00
|
|
|
default = [ "/var/lib/minio/data" ];
|
|
|
|
type = types.listOf types.path;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "The list of data directories for storing the objects. Use one path for regular operation and the minimum of 4 endpoints for Erasure Code mode.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
configDir = mkOption {
|
|
|
|
default = "/var/lib/minio/config";
|
|
|
|
type = types.path;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "The config directory, for the access keys and other settings.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
accessKey = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.str;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Access key of 5 to 20 characters in length that clients use to access the server.
|
|
|
|
This overrides the access key that is generated by minio on first startup and stored inside the
|
2022-08-12 12:06:08 +00:00
|
|
|
`configDir` directory.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
secretKey = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.str;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Specify the Secret key of 8 to 40 characters in length that clients use to access the server.
|
|
|
|
This overrides the secret key that is generated by minio on first startup and stored inside the
|
2022-08-12 12:06:08 +00:00
|
|
|
`configDir` directory.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-07-03 03:11:41 +00:00
|
|
|
rootCredentialsFile = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-07-03 03:11:41 +00:00
|
|
|
File containing the MINIO_ROOT_USER, default is "minioadmin", and
|
|
|
|
MINIO_ROOT_PASSWORD (length >= 8), default is "minioadmin"; in the format of
|
|
|
|
an EnvironmentFile=, as described by systemd.exec(5).
|
|
|
|
'';
|
|
|
|
example = "/etc/nixos/minio-root-credentials";
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
region = mkOption {
|
|
|
|
default = "us-east-1";
|
|
|
|
type = types.str;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The physical location of the server. By default it is set to us-east-1, which is same as AWS S3's and Minio's default region.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
browser = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Enable or disable access to web UI.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
default = pkgs.minio;
|
2021-10-06 13:57:05 +00:00
|
|
|
defaultText = literalExpression "pkgs.minio";
|
2020-04-24 23:36:52 +00:00
|
|
|
type = types.package;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Minio package to use.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-07-03 03:11:41 +00:00
|
|
|
warnings = optional ((cfg.accessKey != "") || (cfg.secretKey != "")) "services.minio.`accessKey` and services.minio.`secretKey` are deprecated, please use services.minio.`rootCredentialsFile` instead.";
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${cfg.configDir}' - minio minio - -"
|
2021-04-13 19:44:15 +00:00
|
|
|
] ++ (map (x: "d '" + x + "' - minio minio - - ") cfg.dataDir);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
systemd.services.minio = {
|
|
|
|
description = "Minio Object Storage";
|
2022-08-21 13:32:41 +00:00
|
|
|
after = [ "network-online.target" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
2021-08-11 14:56:57 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/minio server --json --address ${cfg.listenAddress} --console-address ${cfg.consoleAddress} --config-dir=${cfg.configDir} ${toString cfg.dataDir}";
|
2020-04-24 23:36:52 +00:00
|
|
|
Type = "simple";
|
|
|
|
User = "minio";
|
|
|
|
Group = "minio";
|
|
|
|
LimitNOFILE = 65536;
|
2021-07-03 03:11:41 +00:00
|
|
|
EnvironmentFile = if (cfg.rootCredentialsFile != null) then cfg.rootCredentialsFile
|
|
|
|
else if ((cfg.accessKey != "") || (cfg.secretKey != "")) then (legacyCredentials cfg)
|
|
|
|
else null;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
environment = {
|
|
|
|
MINIO_REGION = "${cfg.region}";
|
|
|
|
MINIO_BROWSER = "${if cfg.browser then "on" else "off"}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users.minio = {
|
|
|
|
group = "minio";
|
|
|
|
uid = config.ids.uids.minio;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups.minio.gid = config.ids.uids.minio;
|
|
|
|
};
|
|
|
|
}
|