Commit d6af0cf084d3

Vincent Demeester <vincent@sbr.pm>
2020-12-18 14:48:31
systems: do not start docker/buildkitd/containerd…
… at boot. Only start on demand. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent e76f08b
Changed files (4)
systems/hosts/naruhodo.nix
@@ -140,6 +140,10 @@ in
       endpointPublicKey = endpointPublicKey;
     };
   };
+  systemd.services.buildkitd.wantedBy = lib.mkForce [ ];
+  systemd.services.containerd.wantedBy = lib.mkForce [ ];
+  systemd.services.docker.wantedBy = lib.mkForce [ ];
+  systemd.services.docker.requires = [ "containerd.socket" ];
 
   virtualisation.podman.enable = true;
   virtualisation.containers = {
systems/modules/profiles/docker.nix
@@ -22,9 +22,13 @@ in
   };
   config = mkIf cfg.enable {
     virtualisation = {
-      containerd.enable = true;
+      containerd = {
+        enable = true;
+        autostart = false;
+      };
       buildkitd = {
         enable = true;
+        autostart = false;
         extraOptions = "--oci-worker=false --containerd-worker=true";
       };
       docker = {
systems/modules/buildkit.nix
@@ -14,6 +14,14 @@ in
         '';
     };
 
+    autostart = mkOption {
+      type = types.bool;
+      default = true;
+      description = ''
+        Start buildkitd automatically.
+      '';
+    };
+
     package = mkOption {
       default = pkgs.buildkit;
       type = types.package;
@@ -48,7 +56,7 @@ in
     systemd.services.buildkitd = {
       wants = [ "containerd.service" ];
       after = [ "containerd.service" ];
-      wantedBy = [ "multi-user.target" ];
+      wantedBy = lib.optional cfg.autostart [ "multi-user.target" ];
       serviceConfig = {
         ExecStart = [
           ""
systems/modules/containerd.nix
@@ -14,6 +14,14 @@ in
       '';
     };
 
+    autostart = mkOption {
+      type = types.bool;
+      default = true;
+      description = ''
+        Start containerd automatically.
+      '';
+    };
+
     package = mkOption {
       default = pkgs.containerd;
       type = types.package;
@@ -45,7 +53,7 @@ in
     systemd.packages = [ cfg.package ];
 
     systemd.services.containerd = {
-      wantedBy = [ "multi-user.target" ];
+      wantedBy = lib.optional cfg.autostart [ "multi-user.target" ];
       serviceConfig = {
         ExecStart = [
           ""