minio service: add additional config options

Set access and secret key and disable browser.
Tests extended to do real operations against minio.

+57 -2
+42
nixos/modules/services/web-servers/minio.nix
··· 29 29 description = "The config directory, for the access keys and other settings."; 30 30 }; 31 31 32 + accessKey = mkOption { 33 + default = ""; 34 + type = types.str; 35 + description = '' 36 + Access key of 5 to 20 characters in length that clients use to access the server. 37 + This overrides the access key that is generated by minio on first startup and stored inside the 38 + <literal>configDir</literal> directory. 39 + ''; 40 + }; 41 + 42 + secretKey = mkOption { 43 + default = ""; 44 + type = types.str; 45 + description = '' 46 + Specify the Secret key of 8 to 40 characters in length that clients use to access the server. 47 + This overrides the secret key that is generated by minio on first startup and stored inside the 48 + <literal>configDir</literal> directory. 49 + ''; 50 + }; 51 + 52 + region = mkOption { 53 + default = "us-east-1"; 54 + type = types.str; 55 + description = '' 56 + 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. 57 + ''; 58 + }; 59 + 60 + browser = mkOption { 61 + default = true; 62 + type = types.bool; 63 + description = "Enable or disable access to web UI."; 64 + }; 65 + 32 66 package = mkOption { 33 67 default = pkgs.minio; 34 68 defaultText = "pkgs.minio"; ··· 56 90 User = "minio"; 57 91 Group = "minio"; 58 92 LimitNOFILE = 65536; 93 + }; 94 + environment = { 95 + MINIO_REGION = "${cfg.region}"; 96 + MINIO_BROWSER = "${if cfg.browser then "on" else "off"}"; 97 + } // optionalAttrs (cfg.accessKey != "") { 98 + MINIO_ACCESS_KEY = "${cfg.accessKey}"; 99 + } // optionalAttrs (cfg.secretKey != "") { 100 + MINIO_SECRET_KEY = "${cfg.secretKey}"; 59 101 }; 60 102 }; 61 103
+15 -2
nixos/tests/minio.nix
··· 4 4 maintainers = [ bachp ]; 5 5 }; 6 6 7 - machine = { config, pkgs, ... }: { 8 - services.minio.enable = true; 7 + nodes = { 8 + machine = { config, pkgs, ... }: { 9 + services.minio = { 10 + enable = true; 11 + accessKey = "BKIKJAA5BMMU2RHO6IBB"; 12 + secretKey = "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12"; 13 + }; 14 + environment.systemPackages = [ pkgs.minio-client ]; 15 + }; 9 16 }; 10 17 11 18 testScript = ··· 14 21 $machine->waitForUnit("minio.service"); 15 22 $machine->waitForOpenPort(9000); 16 23 $machine->succeed("curl --fail http://localhost:9000/minio/index.html"); 24 + 25 + # Create a test bucket on the server 26 + $machine->succeed("mc config host add minio http://localhost:9000 BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 S3v4"); 27 + $machine->succeed("mc mb minio/test-bucket"); 28 + $machine->succeed("mc ls minio") =~ /test-bucket/ or die; 17 29 $machine->shutdown; 30 + 18 31 ''; 19 32 })