Files
nixpkgs/nixos/modules/services/networking/netplan.nix
Mario Vitale ab20775a17 nixos/netplan: init module
nixos/netplan: init nixosTests.netplan
netplan: 0.106.1 -> 1.2.2

Notable changes across the two netplan versions:
- Build settings are now handled by Meson, rather than Make
- netplan now depends on systemd generators for the transient units
- netplan now installs `netplan-configure.service`
2026-07-27 20:53:43 +02:00

62 lines
1.7 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
cfg = config.networking.netplan;
networkdEnabled = (config.networking.useNetworkd || config.systemd.network.enable);
networkmanagerEnabled = config.networking.networkmanager.enable;
in
{
options = {
networking.netplan = {
enable = lib.mkEnableOption "Whether to enable the netplan-configure service at boot";
package = lib.mkPackageOption pkgs "netplan" { };
configFiles = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
default = { };
example = ''
{
"10-example.yaml" = \'\'
---
network:
version: 2
dummy-devices:
example:
addresses: ["fd00::feed:cafe/32"]
\'\'
}
'';
description = "Netplan YAML configuration files to write under /etc/netplan/";
};
};
};
config = lib.mkIf cfg.enable {
warnings = lib.optionals (!(networkdEnabled || networkmanagerEnabled)) [
"You enabled the netplan-configure service, but you haven't enabled a backend for it. It's likely you want to enable either networkd or NetworkManager."
];
environment = {
systemPackages = [ cfg.package ];
etc = builtins.listToAttrs (
builtins.map (key: {
name = "netplan/" + key;
value = {
text = cfg.configFiles."${key}";
user = "root";
group = "root";
mode = "0600";
};
}) (pkgs.lib.attrNames cfg.configFiles)
);
};
systemd = {
packages = [ cfg.package ];
services.netplan-configure.wantedBy = [ "sysinit.target" ];
};
};
}