lol

Merge pull request #39142 from teto/nm_dispatchers

[RDY] networkmanager: enrich dispatcher PATH

authored by

Samuel Dionne-Riel and committed by
GitHub
ca47cc90 4a8a80d9

+27 -2
+27 -2
nixos/modules/services/networking/networkmanager.nix
··· 289 289 source = mkOption { 290 290 type = types.path; 291 291 description = '' 292 - A script. 292 + Path to the hook script. 293 293 ''; 294 294 }; 295 295 ··· 297 297 type = types.enum (attrNames dispatcherTypesSubdirMap); 298 298 default = "basic"; 299 299 description = '' 300 - Dispatcher hook type. Only basic hooks are currently available. 300 + Dispatcher hook type. Look up the hooks described at 301 + <link xlink:href="https://developer.gnome.org/NetworkManager/stable/NetworkManager.html">https://developer.gnome.org/NetworkManager/stable/NetworkManager.html</link> 302 + and choose the type depending on the output folder. 303 + You should then filter the event type (e.g., "up"/"down") from within your script. 301 304 ''; 302 305 }; 303 306 }; 304 307 }); 305 308 default = []; 309 + example = literalExample '' 310 + [ { 311 + source = pkgs.writeText "upHook" ''' 312 + 313 + if [ "$2" != "up" ]; then 314 + logger "exit: event $2 != up" 315 + fi 316 + 317 + # coreutils and iproute are in PATH too 318 + logger "Device $DEVICE_IFACE coming up" 319 + '''; 320 + type = "basic"; 321 + } ]''; 306 322 description = '' 307 323 A list of scripts which will be executed in response to network events. 308 324 ''; ··· 418 434 ++ lib.imap1 (i: s: { 419 435 inherit (s) source; 420 436 target = "NetworkManager/dispatcher.d/${dispatcherTypesSubdirMap.${s.type}}03userscript${lib.fixedWidthNumber 4 i}"; 437 + mode = "0544"; 421 438 }) cfg.dispatcherScripts 422 439 ++ optional (dynamicHostsEnabled) 423 440 { target = "NetworkManager/dnsmasq.d/dyndns.conf"; ··· 473 490 Type = "oneshot"; 474 491 RemainAfterExist = true; 475 492 }; 493 + }; 494 + 495 + systemd.services."NetworkManager-dispatcher" = { 496 + wantedBy = [ "network.target" ]; 497 + restartTriggers = [ configFile ]; 498 + 499 + # useful binaries for user-specified hooks 500 + path = [ pkgs.iproute pkgs.utillinux pkgs.coreutils ]; 476 501 }; 477 502 478 503 # Turn off NixOS' network management