3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #123834 from bachp/minio-module-update

nixos/minio: replace deprecated variables
This commit is contained in:
Pascal Bach 2021-06-30 08:10:27 +02:00 committed by GitHub
commit 69f2fd9721
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,11 @@ with lib;
let let
cfg = config.services.minio; cfg = config.services.minio;
legacyCredentials = cfg: pkgs.writeText "minio-legacy-credentials" ''
MINIO_ROOT_USER=${cfg.accessKey}
MINIO_ROOT_PASSWORD=${cfg.secretKey}
'';
in in
{ {
meta.maintainers = [ maintainers.bachp ]; meta.maintainers = [ maintainers.bachp ];
@ -49,6 +54,17 @@ in
''; '';
}; };
rootCredentialsFile = mkOption {
type = types.nullOr types.path;
default = null;
description = ''
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";
};
region = mkOption { region = mkOption {
default = "us-east-1"; default = "us-east-1";
type = types.str; type = types.str;
@ -72,6 +88,8 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
warnings = optional ((cfg.accessKey != "") || (cfg.secretKey != "")) "services.minio.`accessKey` and services.minio.`secretKey` are deprecated, please use services.minio.`rootCredentialsFile` instead.";
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = [
"d '${cfg.configDir}' - minio minio - -" "d '${cfg.configDir}' - minio minio - -"
] ++ (map (x: "d '" + x + "' - minio minio - - ") cfg.dataDir); ] ++ (map (x: "d '" + x + "' - minio minio - - ") cfg.dataDir);
@ -86,14 +104,13 @@ in
User = "minio"; User = "minio";
Group = "minio"; Group = "minio";
LimitNOFILE = 65536; LimitNOFILE = 65536;
EnvironmentFile = if (cfg.rootCredentialsFile != null) then cfg.rootCredentialsFile
else if ((cfg.accessKey != "") || (cfg.secretKey != "")) then (legacyCredentials cfg)
else null;
}; };
environment = { environment = {
MINIO_REGION = "${cfg.region}"; MINIO_REGION = "${cfg.region}";
MINIO_BROWSER = "${if cfg.browser then "on" else "off"}"; MINIO_BROWSER = "${if cfg.browser then "on" else "off"}";
} // optionalAttrs (cfg.accessKey != "") {
MINIO_ACCESS_KEY = "${cfg.accessKey}";
} // optionalAttrs (cfg.secretKey != "") {
MINIO_SECRET_KEY = "${cfg.secretKey}";
}; };
}; };