Commit 5ba834e0665e

Vincent Demeester <vincent@sbr.pm>
2018-08-06 19:20:47
Add a packages options to containerd service…
… that way it's easy to add external packages to the path. It's mainly there to be able to define multiple oci runtime. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 453925d
Changed files (2)
profiles/containerd.nix
@@ -6,6 +6,7 @@
   virtualisation = {
     containerd = {
       enable = true;
+      packages = [ pkgs.runc ];
     };
   };
 }
service/containerd.nix
@@ -1,5 +1,4 @@
 # Systemd services for containerd.
-
 { config, lib, pkgs, ... }:
 
 with lib;
@@ -17,77 +16,80 @@ in
   options.virtualisation.containerd = {
     enable =
       mkOption {
-        type = types.bool;
-        default = false;
-        description =
-          ''
-            This option enables containerd, a daemon that manages
-            linux containers.
-          '';
-      };
+      type = types.bool;
+      default = false;
+      description =
+      ''
+        This option enables containerd, a daemon that manages
+        linux containers.
+      '';
+    };
+
+    packages = mkOption {
+      type = types.listOf types.package;
+      default = [];
+      description = "List of packages to be added to apparmor's include path";
+    };
 
     listenOptions =
       mkOption {
-        type = types.listOf types.str;
-        default = ["/run/containerd/containerd.sock"];
-        description =
-          ''
-            A list of unix and tcp containerd should listen to. The format follows
-            ListenStream as described in systemd.socket(5).
-          '';
-      };
+      type = types.listOf types.str;
+      default = ["/run/containerd/containerd.sock"];
+      description =
+      ''
+        A list of unix and tcp containerd should listen to. The format follows
+        ListenStream as described in systemd.socket(5).
+      '';
+    };
 
     extraOptions =
       mkOption {
-        type = types.separatedString " ";
-        default = "";
-        description =
-          ''
-            The extra command-line options to pass to
-            <command>containerd</command> daemon.
-          '';
-      };
+      type = types.separatedString " ";
+      default = "";
+      description =
+      ''
+        The extra command-line options to pass to
+        <command>containerd</command> daemon.
+      '';
+    };
   };
 
   ###### implementation
 
   config = mkIf cfg.enable {
-      environment.systemPackages = [ pkgs.containerd ];
+    environment.systemPackages = [ pkgs.containerd ];
     #   users.extraGroups.docker.gid = config.ids.gids.docker;
-      systemd.packages = [ pkgs.containerd ];
+    systemd.packages = [ pkgs.containerd ];
 
-      systemd.services.containerd = {
-        wantedBy = [ "multi-user.target" ];
-        serviceConfig = {
-          ExecStart = [
-            ""
-            ''
-              ${pkgs.containerd}/bin/containerd \
-                ${cfg.extraOptions}
-            ''];
-            /*
-          ExecReload=[
-            ""
-            "${pkgs.procps}/bin/kill -s HUP $MAINPID"
-          ];
-          */
+    systemd.services.containerd = {
+      wantedBy = [ "multi-user.target" ];
+      serviceConfig = {
+        ExecStart = [
+          ""
+        ''
+          ${pkgs.containerd}/bin/containerd \
+          ${cfg.extraOptions}
+        ''];
+        /*
+        ExecReload=[
+        ""
+        "${pkgs.procps}/bin/kill -s HUP $MAINPID"
+        ];
+        */
         };
-        path = [ pkgs.containerd pkgs.runc ];
-      };
-
-      
-      systemd.sockets.containerd = {
-        description = "Containerd Socket for the API";
-        wantedBy = [ "sockets.target" ];
-        socketConfig = {
-          ListenStream = cfg.listenOptions;
-          SocketMode = "0660";
-          SocketUser = "root";
-          SocketGroup = "root";
-        };
-      };
-      
+      path = [ pkgs.containerd ] ++ cfg.packages;
     };
-  
 
+    systemd.sockets.containerd = {
+      description = "Containerd Socket for the API";
+      wantedBy = [ "sockets.target" ];
+      socketConfig = {
+        ListenStream = cfg.listenOptions;
+        SocketMode = "0660";
+        SocketUser = "root";
+        SocketGroup = "root";
+      };
+    };
+    
+  };
 }