mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
nixos/networkd: get rid of *Config attributes in lists
This patch is about removing `wireguardPeerConfig`, `dhcpServerStaticLeaseConfig` - a.k.a. the AbstractSingletonProxyFactoryBean of nixpkgs - and friends. As a former colleague said > worst abstraction ever I second that. I've written enough networkd config for NixOS systems so far to have a strong dislike. In fact, these don't even make sense: `netdevs.wireguardPeers._.wireguardPeerConfig` will be rendered into the key `[WireGuardPeer]` and every key from `wireguardPeerConfig` is in there. Since it's INI, there's no place where sections on the same level as wireguardPeerConfig fit into. Hence, get rid of it all. For the transition, using the old way is still allowed, but gives a warning. I think we could drop this after one release. The tests of rosenpass and systemd-networkd-dhcpserver-static-leases were broken on the rev before, hence they were updated, but are still not building.
This commit is contained in:
parent
805191d9fb
commit
c4fd7cf16d
13 changed files with 171 additions and 302 deletions
|
@ -182,6 +182,30 @@ in rec {
|
|||
in if errors == [] then true
|
||||
else trace (concatStringsSep "\n" errors) false;
|
||||
|
||||
checkUnitConfigWithLegacyKey = legacyKey: group: checks: attrs:
|
||||
let
|
||||
dump = lib.generators.toPretty { }
|
||||
(lib.generators.withRecursion { depthLimit = 2; throwOnDepthLimit = false; } attrs);
|
||||
attrs' =
|
||||
if legacyKey == null
|
||||
then attrs
|
||||
else if ! attrs?${legacyKey}
|
||||
then attrs
|
||||
else if removeAttrs attrs [ legacyKey ] == {}
|
||||
then attrs.${legacyKey}
|
||||
else throw ''
|
||||
The declaration
|
||||
|
||||
${dump}
|
||||
|
||||
must not mix unit options with the legacy key '${legacyKey}'.
|
||||
|
||||
This can be fixed by moving all settings from within ${legacyKey}
|
||||
one level up.
|
||||
'';
|
||||
in
|
||||
checkUnitConfig group checks attrs';
|
||||
|
||||
toOption = x:
|
||||
if x == true then "true"
|
||||
else if x == false then "false"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue