diff --git a/README.md b/README.md index 388d0cb..0a0f66d 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,6 @@ Yep, there's still a lot that could be added or improved. #### Information Gathering (Extractors) -- Podman / docker harvesting - networking.interfaces extractor - Disks (from disko) + render - Impermanence render? diff --git a/examples/complex/flake.nix b/examples/complex/flake.nix index 3b576c7..d97c8c8 100644 --- a/examples/complex/flake.nix +++ b/examples/complex/flake.nix @@ -45,6 +45,13 @@ }; }; + virtualisation.oci-containers.backend = "docker"; + virtualisation.oci-containers.containers = { + test = { + image = "test/test:latest"; + }; + }; + # We can change our own node's topology settings from here: topology.self.name = "🧱  Small Firewall"; topology.self.interfaces.wg0 = { @@ -110,6 +117,18 @@ }; }; + virtualisation.oci-containers.backend = "podman"; + virtualisation.oci-containers.containers = { + test = { + image = "test/test@digest"; + + ports = [ "4242:80" ]; + + volumes = [ "/test:/mnt" ]; + + }; + }; + containers.test.config = { imports = [ nix-topology.nixosModules.default ]; networking.hostName = "host2-test"; diff --git a/icons/devices/docker.svg b/icons/devices/docker.svg new file mode 100644 index 0000000..d74b262 --- /dev/null +++ b/icons/devices/docker.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icons/devices/podman.svg b/icons/devices/podman.svg new file mode 100644 index 0000000..ab50aeb --- /dev/null +++ b/icons/devices/podman.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/nixos/extractors/oci-container.nix b/nixos/extractors/oci-container.nix new file mode 100644 index 0000000..e4cf9db --- /dev/null +++ b/nixos/extractors/oci-container.nix @@ -0,0 +1,48 @@ +{ config, lib, ... }: +let + inherit (lib) + concatStringsSep + filter + flip + head + isString + mapAttrsToList + mkEnableOption + mkIf + mkMerge + split + ; + + inherit (config.virtualisation.oci-containers) backend containers; +in +{ + options.topology.extractors.oci-containers.enable = + mkEnableOption "topology OCI container extractor" + // { + default = true; + }; + + config = mkIf (config.topology.extractors.oci-containers.enable && containers != { }) { + topology.nodes = mkMerge ( + flip mapAttrsToList containers ( + containerName: container: { + "${config.topology.id}-${backend}-${containerName}" = { + guestType = backend; + deviceType = "oci-container"; + deviceIcon = "devices.${backend}"; + services._guestInfo = { + name = "Guest Information"; + hidden = true; + details = { + image.text = head (filter (v: isString v && v != "") (split "@|:" container.image)); + ports = mkIf (container.ports != [ ]) { text = concatStringsSep "\n" container.ports; }; + volumes = mkIf (container.volumes != [ ]) { text = concatStringsSep "\n" container.volumes; }; + }; + }; + parent = config.topology.id; + }; + } + ) + ); + }; +} diff --git a/topology/renderers/svg/default.nix b/topology/renderers/svg/default.nix index 485011d..c2b301c 100644 --- a/topology/renderers/svg/default.nix +++ b/topology/renderers/svg/default.nix @@ -217,6 +217,7 @@ let
${guest.guestType}
+ ${optionalString (guest.services ? _guestInfo) (serviceDetails guest.services._guestInfo)} '';