summary refs log tree commit diff
path: root/nixos/modules/system/boot/networkd.nix
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@higgsboson.tk>2016-11-16 21:47:11 +0000
committerJörg Thalheim <joerg@higgsboson.tk>2016-12-17 15:23:34 +0100
commitd49e0d5fa5c245ab4e8675ba7fd286d848484fb2 (patch)
tree9edca3ccb594d50f94c5f2d91383cc7f17b644e8 /nixos/modules/system/boot/networkd.nix
parent45c1c50dddc76ed8f205c7d23ea7e1418fc67055 (diff)
downloadnixlib-d49e0d5fa5c245ab4e8675ba7fd286d848484fb2.tar
nixlib-d49e0d5fa5c245ab4e8675ba7fd286d848484fb2.tar.gz
nixlib-d49e0d5fa5c245ab4e8675ba7fd286d848484fb2.tar.bz2
nixlib-d49e0d5fa5c245ab4e8675ba7fd286d848484fb2.tar.lz
nixlib-d49e0d5fa5c245ab4e8675ba7fd286d848484fb2.tar.xz
nixlib-d49e0d5fa5c245ab4e8675ba7fd286d848484fb2.tar.zst
nixlib-d49e0d5fa5c245ab4e8675ba7fd286d848484fb2.zip
networkd: allow to supply own unit files
Networkd units can contain secrets. In future also wireguard vpn will be supported by
networkd. To avoid leakage of private keys, those could be then also put outside
of the /nix/store

Having a writeable /etc/systemd/network also allows to quick fix network issues,
when upgrading `nixos-rebuild switch` would require network on its own (due
updates).
Diffstat (limited to 'nixos/modules/system/boot/networkd.nix')
-rw-r--r--nixos/modules/system/boot/networkd.nix12
1 files changed, 7 insertions, 5 deletions
diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix
index e5ec70d8690b..86237ea6ac7c 100644
--- a/nixos/modules/system/boot/networkd.nix
+++ b/nixos/modules/system/boot/networkd.nix
@@ -606,6 +606,10 @@ let
         '';
     };
 
+  unitFiles = map (name: {
+    target = "systemd/network/${name}";
+    source = "${cfg.units.${name}.unit}/${name}";
+  }) (attrNames cfg.units);
 in
 
 {
@@ -657,17 +661,15 @@ in
     systemd.additionalUpstreamSystemUnits =
       [ "systemd-networkd.service" "systemd-networkd-wait-online.service" ];
 
-    systemd.network.units =
-      mapAttrs' (n: v: nameValuePair "${n}.link" (linkToUnit n v)) cfg.links
+    systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.link" (linkToUnit n v)) cfg.links
       // mapAttrs' (n: v: nameValuePair "${n}.netdev" (netdevToUnit n v)) cfg.netdevs
       // mapAttrs' (n: v: nameValuePair "${n}.network" (networkToUnit n v)) cfg.networks;
 
-    environment.etc."systemd/network".source =
-      generateUnits "network" cfg.units [] [];
+    environment.etc = unitFiles;
 
     systemd.services.systemd-networkd = {
       wantedBy = [ "multi-user.target" ];
-      restartTriggers = [ config.environment.etc."systemd/network".source ];
+      restartTriggers = map (f: f.source) (unitFiles);
     };
 
     systemd.services.systemd-networkd-wait-online = {