Skip to content
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

Systemd configuration options and list types #37

Open
Bert-Proesmans opened this issue Aug 31, 2024 · 1 comment
Open

Systemd configuration options and list types #37

Bert-Proesmans opened this issue Aug 31, 2024 · 1 comment

Comments

@Bert-Proesmans
Copy link
Contributor

Bert-Proesmans commented Aug 31, 2024

I ran the topology builder on my configurations and the code throws an error processing option systemd.networks.networks..matchConfig.MACAddress; value is list instead of expected string.

The error is thrown specifically on line 82;

# FIXME: TODO renameInterfacesByMac is not a standard option! It's not an issue here but should proabaly not be used anyway.
extraMacToName = listToAttrs (mapAttrsToList (k: v: nameValuePair v k) (config.networking.renameInterfacesByMac or {}));
macToName = recursiveUpdate linkMacToName extraMacToName;
nameFromMac =
optional (network ? matchConfig.MACAddress && macToName ? ${network.matchConfig.MACAddress})
macToName.${network.matchConfig.MACAddress};
nameFromNetdev =
optional (
(nameOrNull != null)
&& flip any (attrValues config.systemd.network.netdevs) (x:
(x ? netdevConfig.Name)
&& (firstValue x.netdevConfig.Name) == nameOrNull)
)
nameOrNull;

The problem boils down to systemd allowing multiple values per statement, and also multiple statements for matchconfig attributes (within unit files). The code assumes a single string is set. This is undefined zone since there is no actual MatchConfig section verification done in the nixos options.
Just letting you know. I'll update my configs to use a single string value (no problem for my use cases)

EDIT; To complete the context; I assigned my MACAddress values as list of strings. The changes done to make the topology work in the current version is this;

Bert-Proesmans/nix@e683a9f#diff-f2581a441054e01442c6112782164ef45409e8fc0dc923090f6574ee057e9d63

@oddlama
Copy link
Owner

oddlama commented Sep 1, 2024

Oh good point, I guess I could disambiguate between single or multiple values here too. In theory we might want to be able to match interface configurations with multiple MacAddress statements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants