-
-
Notifications
You must be signed in to change notification settings - Fork 36
Add OCI container extractor #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| in | ||
| mkIf (specNix != null && specNix.path != []) ( | ||
| let | ||
| cfg = attrByPath specNix.path {} config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Match the NixOS services by the option path
| # The config should only be applied on the toplevel topology module, | ||
| # not for each nixos node. | ||
| config = {}; | ||
| config.topology.serviceRegistry = serviceDefs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this line but it was the only way I could make it to work (I needed to expose the service registry to the NixOS configurations)
| }; | ||
| in | ||
| f { | ||
| options.serviceRegistry = mkOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expose the service registry as an option (for overriding and customizations)
| map (svc: {inherit node svc;}) visible | ||
| ) (attrValues config.nodes); | ||
|
|
||
| # Deduplicate services by serviceId in overview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the (supposedly rare) case when the same service deployed both as a container and a NixOS service display it only once in the overview
| repoLower = strings.toLower repo; | ||
| in | ||
| canon == repoLower || strings.hasSuffix ("/" + repoLower) canon; | ||
| matchesRepos = img: repos: builtins.any (suffixMatch img) repos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Match the containerized services by the image reference
| builtins.trace | ||
| ("oci-container extractor: UNMATCHED containers → " | ||
| + (concatStringsSep ", " | ||
| (map (c: "${c._name} (${c.image})") unmatched))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Output the unmatched containers
I deploy services as OCI containers on NixOS, so I wanted to create an extractor for
virtualisation.oci-containers.containers. I had to do a little refactoring and extract the service registry so that the service extractors could share the service names and icons.It works by matching the
virtualisation.oci-containers.containers.<name>.imageoption with a list of known service container repository references (mostly official ones), e.g.jellyfin/jellyfinandlinuxserver/jellyfinfor Jellyfin.Users can define custom functions to extract info and details from their container configurations, as well as override and update the service registry.