{ lib, config, ... }:
let
  inherit (lib) mkEnableOption mkOption types;
in
{
  options = {
    valhalla = {
      linux.programs.systemd-networkd = {
        enable = mkEnableOption "systemd-networkd";

        networks = mkOption {
          type = types.attrsOf types.attrs;
          description = "The networks to configure.";
        };

        networkFiles = mkOption {
          type = types.attrsOf types.str;
          description = "The files for configuring the networks.";
          default = builtins.mapAttrs
            (name: network: lib.generators.toINI { listsAsDuplicateKeys = true; } network)
            config.valhalla.linux.programs.systemd-networkd.networks;
        };
      };
    };
  };
}