summary refs log tree commit diff
path: root/nixos/modules/services/web-servers/minio.nix
diff options
context:
space:
mode:
authorPascal Bach <pascal.bach@nextrem.ch>2017-06-25 18:43:10 +0200
committerFranz Pletz <fpletz@fnordicwalking.de>2017-06-26 04:07:37 +0200
commitaa66c9ad372448277ff113bd78039e6a30034662 (patch)
tree1fc60c55a9484cf4821b58f17e454f08deaac12b /nixos/modules/services/web-servers/minio.nix
parente5def4442e6d4ce66bf66716dc85c97481fce156 (diff)
downloadnixlib-aa66c9ad372448277ff113bd78039e6a30034662.tar
nixlib-aa66c9ad372448277ff113bd78039e6a30034662.tar.gz
nixlib-aa66c9ad372448277ff113bd78039e6a30034662.tar.bz2
nixlib-aa66c9ad372448277ff113bd78039e6a30034662.tar.lz
nixlib-aa66c9ad372448277ff113bd78039e6a30034662.tar.xz
nixlib-aa66c9ad372448277ff113bd78039e6a30034662.tar.zst
nixlib-aa66c9ad372448277ff113bd78039e6a30034662.zip
minio service: add inital service
features:
- change listen port and address
- configure config and data directory
- basic test to check if minio server starts
Diffstat (limited to 'nixos/modules/services/web-servers/minio.nix')
-rw-r--r--nixos/modules/services/web-servers/minio.nix69
1 files changed, 69 insertions, 0 deletions
diff --git a/nixos/modules/services/web-servers/minio.nix b/nixos/modules/services/web-servers/minio.nix
new file mode 100644
index 000000000000..1893edf3a776
--- /dev/null
+++ b/nixos/modules/services/web-servers/minio.nix
@@ -0,0 +1,69 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.minio;
+in
+{
+  meta.maintainers = [ maintainers.bachp ];
+
+  options.services.minio = {
+    enable = mkEnableOption "Minio Object Storage";
+
+    listenAddress = mkOption {
+      default = ":9000";
+      type = types.str;
+      description = "Listen on a specific IP address and port.";
+    };
+
+    dataDir = mkOption {
+      default = "/var/lib/minio/data";
+      type = types.path;
+      description = "The data directory, for storing the objects.";
+    };
+
+    configDir = mkOption {
+      default = "/var/lib/minio/config";
+      type = types.path;
+      description = "The config directory, for the access keys and other settings.";
+    };
+
+    package = mkOption {
+      default = pkgs.minio;
+      defaultText = "pkgs.minio";
+      type = types.package;
+      description = "Minio package to use.";
+    };
+  };
+
+  config = mkIf cfg.enable {
+    systemd.services.minio = {
+      description = "Minio Object Storage";
+      after = [ "network.target" ];
+      wantedBy = [ "multi-user.target" ];
+      preStart = ''
+        # Make sure directories exist with correct owner
+        mkdir -p ${cfg.configDir}
+        chown -R minio:minio ${cfg.configDir}
+        mkdir -p ${cfg.dataDir}
+        chown minio:minio ${cfg.dataDir}
+      '';
+      serviceConfig = {
+        PermissionsStartOnly = true;
+        ExecStart = "${cfg.package}/bin/minio server --address ${cfg.listenAddress} --config-dir=${cfg.configDir} ${cfg.dataDir}";
+        Type = "simple";
+        User = "minio";
+        Group = "minio";
+        LimitNOFILE = 65536;
+      };
+    };
+
+    users.extraUsers.minio = {
+      group = "minio";
+      uid = config.ids.uids.minio;
+    };
+
+    users.extraGroups.minio.gid = config.ids.uids.minio;
+  };
+}