diff options
author | Pascal Bach <pascal.bach@nextrem.ch> | 2021-06-02 22:34:06 +0200 |
---|---|---|
committer | Pascal Bach <pascal.bach@nextrem.ch> | 2021-06-04 23:27:12 +0200 |
commit | b1b9e003dcc41e4c9f9672fc5cd4a66fea3a98e5 (patch) | |
tree | e93c1a379dd228b2ead55582124a971ddd0e52e7 /nixos/modules/services/web-servers/minio.nix | |
parent | 9cd41d69a184c933735ebe34b1c7daadf1309ed4 (diff) | |
download | nixpkgs-b1b9e003dcc41e4c9f9672fc5cd4a66fea3a98e5.tar nixpkgs-b1b9e003dcc41e4c9f9672fc5cd4a66fea3a98e5.tar.gz nixpkgs-b1b9e003dcc41e4c9f9672fc5cd4a66fea3a98e5.tar.bz2 nixpkgs-b1b9e003dcc41e4c9f9672fc5cd4a66fea3a98e5.tar.lz nixpkgs-b1b9e003dcc41e4c9f9672fc5cd4a66fea3a98e5.tar.xz nixpkgs-b1b9e003dcc41e4c9f9672fc5cd4a66fea3a98e5.tar.zst nixpkgs-b1b9e003dcc41e4c9f9672fc5cd4a66fea3a98e5.zip |
nixos/minio: credentialfile
Diffstat (limited to 'nixos/modules/services/web-servers/minio.nix')
-rw-r--r-- | nixos/modules/services/web-servers/minio.nix | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/nixos/modules/services/web-servers/minio.nix b/nixos/modules/services/web-servers/minio.nix index 381a55faff1..d075449012f 100644 --- a/nixos/modules/services/web-servers/minio.nix +++ b/nixos/modules/services/web-servers/minio.nix @@ -4,6 +4,11 @@ with lib; let cfg = config.services.minio; + + legacyCredentials = cfg: pkgs.writeText "minio-legacy-credentials" '' + MINIO_ROOT_USER=${cfg.accessKey} + MINIO_ROOT_PASSWORD=${cfg.secretKey} + ''; in { 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 { default = "us-east-1"; type = types.str; @@ -72,6 +88,8 @@ in }; 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 = [ "d '${cfg.configDir}' - minio minio - -" ] ++ (map (x: "d '" + x + "' - minio minio - - ") cfg.dataDir); @@ -86,14 +104,13 @@ in User = "minio"; Group = "minio"; LimitNOFILE = 65536; + EnvironmentFile = if (cfg.rootCredentialsFile != null) then cfg.rootCredentialsFile + else if ((cfg.accessKey != "") || (cfg.secretKey != "")) then (legacyCredentials cfg) + else null; }; environment = { MINIO_REGION = "${cfg.region}"; 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}"; }; }; |