treewide: Reformat project with alejandra
This commit is contained in:
		
							parent
							
								
									58e52dd119
								
							
						
					
					
						commit
						046a88905d
					
				
					 17 changed files with 405 additions and 353 deletions
				
			
		|  | @ -1,9 +1,6 @@ | |||
| { lib, ... }: | ||||
| 
 | ||||
| with lib; | ||||
| 
 | ||||
| { | ||||
|   imports = [ ./virtualisation/pods.nix ]; | ||||
| {lib, ...}: | ||||
| with lib; { | ||||
|   imports = [./virtualisation/pods.nix]; | ||||
| 
 | ||||
|   options.services.nginx.domain = mkOption { | ||||
|     type = types.str; | ||||
|  |  | |||
|  | @ -1,20 +1,21 @@ | |||
| { lib, config, options, ... }: | ||||
| 
 | ||||
| with lib; | ||||
| 
 | ||||
| let | ||||
| { | ||||
|   lib, | ||||
|   config, | ||||
|   options, | ||||
|   ... | ||||
| }: | ||||
| with lib; let | ||||
|   cfg = config.virtualisation.pods; | ||||
|   list-to-args = arg: list: | ||||
|     concatStringsSep " " (map (e: "--${arg}=${escapeShellArg e}") list); | ||||
|   possibly-unset-arg = arg: val: | ||||
|     (optionalString (val != null) "--${arg}=${escapeShellArg val}"); | ||||
|   possibly-unset-arg = arg: val: (optionalString (val != null) "--${arg}=${escapeShellArg val}"); | ||||
| 
 | ||||
|   mkPod = name: pod: rec { | ||||
|     path = [ config.virtualisation.podman.package ]; | ||||
|     path = [config.virtualisation.podman.package]; | ||||
| 
 | ||||
|     wants = [ "network.target" ]; | ||||
|     after = [ "network-online.target" ]; | ||||
|     wantedBy = [ "multi-user.target" "default.target" ]; | ||||
|     wants = ["network.target"]; | ||||
|     after = ["network-online.target"]; | ||||
|     wantedBy = ["multi-user.target" "default.target"]; | ||||
| 
 | ||||
|     environment.PODMAN_SYSTEMD_UNIT = "%n"; | ||||
| 
 | ||||
|  | @ -55,7 +56,6 @@ let | |||
|       PIDFile = "/run/podman/pods/${name}.pid"; | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
| in { | ||||
|   options.virtualisation.pods = mkOption { | ||||
|     type = with types; | ||||
|  | @ -63,9 +63,8 @@ in { | |||
|         options = { | ||||
|           added-hosts = mkOption { | ||||
|             type = listOf str; | ||||
|             default = [ ]; | ||||
|             description = | ||||
|               "Additional hosts to add to /etc/hosts for each container."; | ||||
|             default = []; | ||||
|             description = "Additional hosts to add to /etc/hosts for each container."; | ||||
|             example = literalExample '' | ||||
|               [ "database:10.0.0.1" ] | ||||
|             ''; | ||||
|  | @ -74,25 +73,24 @@ in { | |||
|           cgroup-parent = mkOption { | ||||
|             type = nullOr str; | ||||
|             default = null; | ||||
|             description = | ||||
|               "The cgroups path under which the pod cgroup will be created."; | ||||
|             description = "The cgroups path under which the pod cgroup will be created."; | ||||
|           }; | ||||
| 
 | ||||
|           dns = mkOption { | ||||
|             type = listOf str; | ||||
|             default = [ ]; | ||||
|             default = []; | ||||
|             description = "The dns servers to set in /etc/resolv.conf."; | ||||
|           }; | ||||
| 
 | ||||
|           dns-opt = mkOption { | ||||
|             type = listOf str; | ||||
|             default = [ ]; | ||||
|             default = []; | ||||
|             description = "dns options to set in /etc/resolv.conf."; | ||||
|           }; | ||||
| 
 | ||||
|           dns-search = mkOption { | ||||
|             type = listOf str; | ||||
|             default = [ ]; | ||||
|             default = []; | ||||
|             description = "Search domains to set in /etc/resolv.conf."; | ||||
|           }; | ||||
| 
 | ||||
|  | @ -156,20 +154,20 @@ in { | |||
| 
 | ||||
|           publish = mkOption { | ||||
|             type = listOf str; | ||||
|             default = [ ]; | ||||
|             default = []; | ||||
|             description = "List of ports to publish from the pod."; | ||||
|           }; | ||||
| 
 | ||||
|           share = mkOption { | ||||
|             type = listOf str; | ||||
|             default = [ ]; | ||||
|             default = []; | ||||
|             description = "List of kernel namespaces to share."; | ||||
|           }; | ||||
| 
 | ||||
|           containers = options.virtualisation.oci-containers.containers; | ||||
|         }; | ||||
|       }); | ||||
|     default = { }; | ||||
|     default = {}; | ||||
|     description = "Podman pods to run as systemd services."; | ||||
|   }; | ||||
| 
 | ||||
|  | @ -178,7 +176,7 @@ in { | |||
|     # | ||||
|     # TODO: See if there's a generic version for this somewhere in the | ||||
|     # pkgs lib? | ||||
|     mergeAttrs = attrList: foldr (a: b: a // b) { } attrList; | ||||
|     mergeAttrs = attrList: foldr (a: b: a // b) {} attrList; | ||||
| 
 | ||||
|     # Create services for all defined pods | ||||
|     pod-services = mapAttrs' (n: v: nameValuePair "pod-${n}" (mkPod n v)) cfg; | ||||
|  | @ -190,31 +188,35 @@ in { | |||
|     pod-container-services = mergeAttrs (mapAttrsToList (pname: pod: | ||||
|       mapAttrs' (cname: container: | ||||
|         nameValuePair "podman-${pname}-${cname}" rec { | ||||
|           after = [ "pod-${pname}.service" ]; | ||||
|           after = ["pod-${pname}.service"]; | ||||
|           requires = after; | ||||
|         }) pod.containers) cfg); | ||||
|         }) | ||||
|       pod.containers) | ||||
|     cfg); | ||||
| 
 | ||||
|     # Override the oci-container settings for containers defined in pods. | ||||
|     # | ||||
|     # I.e., set the --pod=podname setting, and update the dependsOn so | ||||
|     # it points to containers in the same pod. | ||||
|     podifyContainer = container: podname: | ||||
|       container // { | ||||
|       container | ||||
|       // { | ||||
|         dependsOn = | ||||
|           map (dependency: "${podname}-${dependency}") container.dependsOn; | ||||
|         extraOptions = container.extraOptions ++ [ "--pod=${podname}" ]; | ||||
|         extraOptions = container.extraOptions ++ ["--pod=${podname}"]; | ||||
|       }; | ||||
|   in | ||||
|     lib.mkIf (cfg != {}) { | ||||
|       virtualisation.podman.enable = true; | ||||
|       virtualisation.oci-containers.backend = "podman"; | ||||
| 
 | ||||
|   in lib.mkIf (cfg != { }) { | ||||
|     virtualisation.podman.enable = true; | ||||
|     virtualisation.oci-containers.backend = "podman"; | ||||
|       systemd.services = pod-services // pod-container-services; | ||||
| 
 | ||||
|     systemd.services = pod-services // pod-container-services; | ||||
| 
 | ||||
|     virtualisation.oci-containers.containers = mergeAttrs (mapAttrsToList | ||||
|       (pname: pod: | ||||
|         mapAttrs' (cname: container: | ||||
|           nameValuePair "${pname}-${cname}" (podifyContainer container pname)) | ||||
|         pod.containers) cfg); | ||||
|   }; | ||||
|       virtualisation.oci-containers.containers = mergeAttrs (mapAttrsToList | ||||
|         (pname: pod: | ||||
|           mapAttrs' (cname: container: | ||||
|             nameValuePair "${pname}-${cname}" (podifyContainer container pname)) | ||||
|           pod.containers) | ||||
|         cfg); | ||||
|     }; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue