diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 744857c5901c..963daf721ad3 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -508,6 +508,7 @@
./virtualisation/amazon-options.nix
./virtualisation/openvswitch.nix
./virtualisation/parallels-guest.nix
+ ./virtualisation/rkt.nix
./virtualisation/virtualbox-guest.nix
./virtualisation/virtualbox-host.nix
./virtualisation/vmware-guest.nix
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
+ systemd.time
+ 5) of the time at
+ which the garbage collector will run.
+ '';
+ };
+
+ options = mkOption {
+ default = "--grace-period=24h";
+ type = types.str;
+ description = ''
+ Options given to rkt gc 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}";
+ };
+ };
+ };
+}