1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-10 14:50:40 +02:00

feat(topology): add icons and service info

This commit is contained in:
oddlama 2024-03-16 20:28:50 +01:00
parent 25a864b1e8
commit 11562ead05
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
10 changed files with 173 additions and 15 deletions

View file

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg fill="#000000" height="800px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 512 512" xml:space="preserve">
<g>
<g>
<path d="M168,184.036c-6.632,0-12,5.376-12,12v23.752c0,6.628,5.368,12,12,12c6.624,0,12-5.372,12-12v-23.752
C180,189.412,174.624,184.036,168,184.036z"/>
</g>
</g>
<g>
<g>
<path d="M256,184.036c-6.632,0-12,5.376-12,12v23.752c0,6.628,5.368,12,12,12c6.624,0,12-5.372,12-12v-23.752
C268,189.412,262.624,184.036,256,184.036z"/>
</g>
</g>
<g>
<g>
<path d="M212,184.036c-6.632,0-12,5.376-12,12v23.752c0,6.628,5.368,12,12,12c6.624,0,12-5.372,12-12v-23.752
C224,189.412,218.624,184.036,212,184.036z"/>
</g>
</g>
<g>
<g>
<path d="M460,0H52C23.28,0,0,23.28,0,52v408c0,28.72,23.28,52,52,52h408c28.72,0,52-23.28,52-52V52C512,23.28,488.72,0,460,0z
M444,284h-88.024c-2.212,0-3.976,1.64-3.976,3.848V348H160v-60.152c0-2.208-1.616-3.848-3.828-3.848H68V68h44v92.184
c0,6.624,5.368,12,12,12c6.624,0,12-5.376,12-12V68h20v92.184c0,6.624,5.368,12,12,12c6.624,0,12-5.376,12-12V68h20v92.184
c0,6.624,5.368,12,12,12c6.624,0,12-5.376,12-12V68h20v92.184c0,6.624,5.368,12,12,12c6.624,0,12-5.376,12-12V68h20v92.184
c0,6.624,5.368,12,12,12c6.624,0,12-5.376,12-12V68h20v92.184c0,6.624,5.368,12,12,12c6.624,0,12-5.376,12-12V68h20v92.184
c0,6.624,5.368,12,12,12c6.624,0,12-5.376,12-12V68h44V284z"/>
</g>
</g>
<g>
<g>
<path d="M124,184.036c-6.632,0-12,5.376-12,12v23.752c0,6.628,5.368,12,12,12c6.624,0,12-5.372,12-12v-23.752
C136,189.412,130.624,184.036,124,184.036z"/>
</g>
</g>
<g>
<g>
<path d="M388,184.036c-6.632,0-12,5.376-12,12v23.752c0,6.628,5.368,12,12,12c6.624,0,12-5.372,12-12v-23.752
C400,189.412,394.624,184.036,388,184.036z"/>
</g>
</g>
<g>
<g>
<path d="M344,184.036c-6.632,0-12,5.376-12,12v23.752c0,6.628,5.368,12,12,12c6.624,0,12-5.372,12-12v-23.752
C356,189.412,350.624,184.036,344,184.036z"/>
</g>
</g>
<g>
<g>
<path d="M300,184.036c-6.632,0-12,5.376-12,12v23.752c0,6.628,5.368,12,12,12c6.624,0,12-5.372,12-12v-23.752
C312,189.412,306.624,184.036,300,184.036z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg xmlns="http://www.w3.org/2000/svg"
aria-label="WireGuard" role="img"
viewBox="0 0 512 512"><rect
width="512" height="512"
rx="15%"
fill="#88171a"/><path d="m238 53l35 8 0 2c-15 2-30-4-45-5 11 7 23 11 35 15-19 16-35-5-56 9 20 10 19 8 21 27-9 1-24 10-27 16 13 3 28 0 41 8-4 3-14 7-18 10 9 2 20-2 25 1 19 16 54 38 64 60 17 37-22 77-60 83-53 11-83 66-64 117 19 50 78 72 125 46 66-40 56-108 16-145-2-2-4-2-6 0-14 9-29 17-45 24 36 8 41 35 37 54-13 48-78 37-85-4-3-19 7-38 24-46 59-26 87-30 104-97 6-38-3-58-31-80-11-11-33-18-40-35-1-2 1-6 3-6 10-2 49-3 49-1 7 7 13-4 16-9-10-2-21-1-29-1-1 0-3-2-4-3 1 -1 3-2 4-2h41c0-7-9-17-18-19v3c-8 1-16-1-24-4-4-3-7-9-11-11-16-9-33-16-54-16-10 0-17 1-23 1zm74 30l3 3-4 2c-2 1-3 0-4-1-2-3 4-5 5-4zm-120 96c-54 33-51 109-3 139 4 2 6 2 8-1 12-15 23-22 36-30-25-4-38-16-37-33-4-60 83-54 74 2-2 10-8 19-16 25 27-6 47-21 55-48 2-8 2-19-2-26-30-44-75-53-115-28zm-62 195c16-7 33-10 49-13 1-13 5-26 13-36-30 0-55 20-62 49z" fill="#ffffff"/></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg xmlns="http://www.w3.org/2000/svg"
aria-label="WireGuard" role="img"
viewBox="0 0 512 512"><rect
width="512" height="512"
rx="15%"
fill="#88171a"/><path d="m238 53l35 8 0 2c-15 2-30-4-45-5 11 7 23 11 35 15-19 16-35-5-56 9 20 10 19 8 21 27-9 1-24 10-27 16 13 3 28 0 41 8-4 3-14 7-18 10 9 2 20-2 25 1 19 16 54 38 64 60 17 37-22 77-60 83-53 11-83 66-64 117 19 50 78 72 125 46 66-40 56-108 16-145-2-2-4-2-6 0-14 9-29 17-45 24 36 8 41 35 37 54-13 48-78 37-85-4-3-19 7-38 24-46 59-26 87-30 104-97 6-38-3-58-31-80-11-11-33-18-40-35-1-2 1-6 3-6 10-2 49-3 49-1 7 7 13-4 16-9-10-2-21-1-29-1-1 0-3-2-4-3 1 -1 3-2 4-2h41c0-7-9-17-18-19v3c-8 1-16-1-24-4-4-3-7-9-11-11-16-9-33-16-54-16-10 0-17 1-23 1zm74 30l3 3-4 2c-2 1-3 0-4-1-2-3 4-5 5-4zm-120 96c-54 33-51 109-3 139 4 2 6 2 8-1 12-15 23-22 36-30-25-4-38-16-37-33-4-60 83-54 74 2-2 10-8 19-16 25 27-6 47-21 55-48 2-8 2-19-2-26-30-44-75-53-115-28zm-62 195c16-7 33-10 49-13 1-13 5-26 13-36-30 0-55 20-62 49z" fill="#ffffff"/></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -1,7 +1,6 @@
{
config,
lib,
pkgs,
...
}: let
inherit
@ -12,7 +11,8 @@ in {
topology.self.services = {
vaultwarden = mkIf config.services.vaultwarden.enable {
name = "Vaultwarden";
icon = "${pkgs.vaultwarden.webvault}/share/vaultwarden/vault/images/safari-pinned-tab.svg";
info = "https://pw.example.com";
details.listen.text = "[::]:3000";
};
};
}

View file

@ -9,10 +9,12 @@
attrValues
concatLists
flip
listToAttrs
mapAttrsToList
mkDefault
mkIf
mkMerge
nameValuePair
optional
;
in {
@ -25,6 +27,7 @@ in {
optional (netdev ? netdevConfig.Name) {
${netdev.netdevConfig.Name} = {
virtual = mkDefault true;
type = mkIf (netdev ? netdevConfig.Kind) netdev.netdevConfig.Kind;
};
}
)
@ -34,9 +37,11 @@ in {
flip mapAttrsToList config.systemd.network.networks (
_unit: network: let
# FIXME: TODO renameInterfacesByMac is not a standard option!
macToName = listToAttrs (mapAttrsToList (k: v: nameValuePair v k) config.networking.renameInterfacesByMac);
nameFromMac =
optional (network ? matchConfig.MACAddress && config.networking.renameInterfacesByMac ? ${network.matchConfig.MACAddress})
config.networking.renameInterfacesByMac.${network.matchConfig.MACAddress};
optional (network ? matchConfig.MACAddress && macToName ? ${network.matchConfig.MACAddress})
macToName.${network.matchConfig.MACAddress};
nameFromNetdev =
optional (

View file

@ -0,0 +1,51 @@
f: {
lib,
config,
...
}: let
inherit
(lib)
concatStringsSep
filterAttrs
init
mapAttrs'
mkOption
nameValuePair
splitString
types
;
removeExtension = filename: concatStringsSep "." (init (splitString "." filename));
iconsFromFiles = dir:
mapAttrs' (file: _: nameValuePair (removeExtension file) {file = dir + "/${file}";}) (
filterAttrs (_: type: type == "regular") (builtins.readDir dir)
);
iconType = types.submodule {
options = {
file = mkOption {
description = "The icon file";
type = types.path;
};
};
};
mkIcons = name:
mkOption {
description = "Defines icons for ${name}.";
default = {};
type = types.attrsOf iconType;
};
in
f {
options.icons = {
interfaces = mkIcons "network interface types";
services = mkIcons "services";
};
config.icons = {
interfaces = iconsFromFiles ../icons/interfaces;
services = iconsFromFiles ../icons/services;
};
}

View file

@ -40,6 +40,18 @@ in
type = types.nullOr types.str;
};
type = mkOption {
description = "The type of this interface";
default = "ethernet";
type = types.str;
};
icon = mkOption {
description = "The icon for this interface. If null, an icon will be selected from `icons.interfaces` based on the specified type.";
default = null;
type = types.nullOr types.path;
};
addresses = mkOption {
description = "The configured address(es), or a descriptive string (like DHCP).";
default = [];

View file

@ -12,8 +12,7 @@ in
f {
options.networks = mkOption {
default = {};
description = ''
'';
description = "Defines logical networks that are present in your topology.";
type = types.attrsOf (types.submodule (networkSubmod: {
options = {
id = mkOption {

View file

@ -14,6 +14,8 @@ in
options.nodes = mkOption {
default = {};
description = ''
Defines nodes that are shown in the topology graph.
Nodes usually correspond to nixos hosts or other devices in your network.
'';
type = types.attrsOf (types.submodule (nodeSubmod: {
options = {

View file

@ -14,7 +14,7 @@ in
type = types.attrsOf (types.submodule {
options = {
services = mkOption {
description = "TODO";
description = "Defines a service that is running on this node.";
default = {};
type = types.attrsOf (types.submodule (submod: {
options = {
@ -36,16 +36,34 @@ in
default = null;
};
url = mkOption {
description = "The URL under which the service is reachable, if any.";
type = types.nullOr types.str;
default = null;
info = mkOption {
description = "Additional high-profile information about this service, usually the url or listen address. Most likely shown directly below the name.";
type = types.lines;
};
listenAddresses = mkOption {
description = "The addresses on which this service listens.";
type = types.nullOr types.str;
default = null;
details = mkOption {
description = "Additional detail sections that should be shown to the user.";
type = types.attrsOf (types.submodule (detailSubmod: {
options = {
name = mkOption {
description = "The name of this section";
type = types.str;
readOnly = true;
default = detailSubmod.config._module.args.name;
};
order = mkOption {
description = "The order determines how sections are ordered. Lower numbers first, default is 100.";
type = types.int;
default = 100;
};
text = mkOption {
description = "The additional information to display";
type = types.lines;
};
};
}));
};
};
}));