about summary refs log tree commit diff
path: root/nixos/modules/virtualisation
diff options
context:
space:
mode:
authorArseniy Seroka <jagajaga@users.noreply.github.com>2015-12-11 08:04:44 +0300
committerArseniy Seroka <jagajaga@users.noreply.github.com>2015-12-11 08:04:44 +0300
commit79d0fc45a9c72875a9907a20135351ba9169b51d (patch)
treef3ead7fe2b359361b4c15f0ae02b7417b7f9cff1 /nixos/modules/virtualisation
parentebab50992b01020bd25df73d03b059076832d6b1 (diff)
parentc85ada394f495f3a7277253896ecb584dde8d496 (diff)
downloadnixlib-79d0fc45a9c72875a9907a20135351ba9169b51d.tar
nixlib-79d0fc45a9c72875a9907a20135351ba9169b51d.tar.gz
nixlib-79d0fc45a9c72875a9907a20135351ba9169b51d.tar.bz2
nixlib-79d0fc45a9c72875a9907a20135351ba9169b51d.tar.lz
nixlib-79d0fc45a9c72875a9907a20135351ba9169b51d.tar.xz
nixlib-79d0fc45a9c72875a9907a20135351ba9169b51d.tar.zst
nixlib-79d0fc45a9c72875a9907a20135351ba9169b51d.zip
Merge pull request #11565 from jgillich/rkt
rkt: add service
Diffstat (limited to 'nixos/modules/virtualisation')
-rw-r--r--nixos/modules/virtualisation/rkt.nix62
1 files changed, 62 insertions, 0 deletions
diff --git a/nixos/modules/virtualisation/rkt.nix b/nixos/modules/virtualisation/rkt.nix
new file mode 100644
index 000000000000..7b4d46e0749e
--- /dev/null
+++ b/nixos/modules/virtualisation/rkt.nix
@@ -0,0 +1,62 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.virtualisation.rkt;
+in
+{
+  options.virtualisation.rkt = {
+    enable = mkEnableOption "rkt metadata service";
+
+    gc = {
+      automatic = mkOption {
+        default = true;
+        type = types.bool;
+        description = "Automatically run the garbage collector at a specific time.";
+      };
+
+      dates = mkOption {
+        default = "03:15";
+        type = types.str;
+        description = ''
+          Specification (in the format described by
+          <citerefentry><refentrytitle>systemd.time</refentrytitle>
+          <manvolnum>5</manvolnum></citerefentry>) of the time at
+          which the garbage collector will run.
+        '';
+      };
+
+      options = mkOption {
+        default = "--grace-period=24h";
+        type = types.str;
+        description = ''
+          Options given to <filename>rkt gc</filename> when the
+          garbage collector is run automatically.
+        '';
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+    environment.systemPackages = [ pkgs.rkt ];
+
+    systemd.services.rkt = {
+      description = "rkt metadata service";
+      wantedBy = [ "multi-user.target" ];
+      after = [ "network.target" ];
+      serviceConfig = {
+        ExecStart = "${pkgs.rkt}/bin/rkt metadata-service";
+      };
+    };
+
+    systemd.services.rkt-gc = {
+      description = "rkt garbage collection";
+      startAt = optionalString cfg.gc.automatic cfg.gc.dates;
+      serviceConfig = {
+        Type = "oneshot";
+        ExecStart = "${pkgs.rkt}/bin/rkt gc ${cfg.gc.options}";
+      };
+    };
+  };
+}