summary refs log tree commit diff
path: root/nixos
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
parente5def4442e6d4ce66bf66716dc85c97481fce156 (diff)
downloadnixpkgs-aa66c9ad372448277ff113bd78039e6a30034662.tar
nixpkgs-aa66c9ad372448277ff113bd78039e6a30034662.tar.gz
nixpkgs-aa66c9ad372448277ff113bd78039e6a30034662.tar.bz2
nixpkgs-aa66c9ad372448277ff113bd78039e6a30034662.tar.lz
nixpkgs-aa66c9ad372448277ff113bd78039e6a30034662.tar.xz
nixpkgs-aa66c9ad372448277ff113bd78039e6a30034662.tar.zst
nixpkgs-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')
-rw-r--r--nixos/modules/misc/ids.nix2
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/web-servers/minio.nix69
-rw-r--r--nixos/tests/minio.nix19
4 files changed, 91 insertions, 0 deletions
diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix
index d7459e3fe91..22059bb7fbb 100644
--- a/nixos/modules/misc/ids.nix
+++ b/nixos/modules/misc/ids.nix
@@ -295,6 +295,7 @@
       aria2 = 277;
       clickhouse = 278;
       rslsync = 279;
+      minio = 280;
 
       # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
 
@@ -559,6 +560,7 @@
       aria2 = 277;
       clickhouse = 278;
       rslsync = 279;
+      minio = 280;
 
       # When adding a gid, make sure it doesn't match an existing
       # uid. Users and groups with the same name should have equal
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 07be6555b23..5d9b062f204 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -588,6 +588,7 @@
   ./services/web-servers/lighttpd/default.nix
   ./services/web-servers/lighttpd/gitweb.nix
   ./services/web-servers/lighttpd/inginious.nix
+  ./services/web-servers/minio.nix
   ./services/web-servers/nginx/default.nix
   ./services/web-servers/phpfpm/default.nix
   ./services/web-servers/shellinabox.nix
diff --git a/nixos/modules/services/web-servers/minio.nix b/nixos/modules/services/web-servers/minio.nix
new file mode 100644
index 00000000000..1893edf3a77
--- /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;
+  };
+}
diff --git a/nixos/tests/minio.nix b/nixos/tests/minio.nix
new file mode 100644
index 00000000000..462a3bc4768
--- /dev/null
+++ b/nixos/tests/minio.nix
@@ -0,0 +1,19 @@
+import ./make-test.nix ({ pkgs, ...} : {
+  name = "minio";
+  meta = with pkgs.stdenv.lib.maintainers; {
+    maintainers = [ bachp ];
+  };
+
+  machine = { config, pkgs, ... }: {
+    services.minio.enable = true;
+  };
+
+  testScript =
+    ''
+      startAll;
+      $machine->waitForUnit("minio.service");
+      $machine->waitForOpenPort(9000);
+      $machine->succeed("curl --fail http://localhost:9000/minio/index.html");
+      $machine->shutdown;
+    '';
+})