Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
19 changes: 19 additions & 0 deletions examples/complex/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions icons/devices/docker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/devices/podman.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions nixos/extractors/oci-container.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}
)
);
};
}
1 change: 1 addition & 0 deletions topology/renderers/svg/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ let
<p tw="text-sm m-0">${guest.guestType}</p>
</div>
</div>
${optionalString (guest.services ? _guestInfo) (serviceDetails guest.services._guestInfo)}
</div>
'';

Expand Down
Loading