From 7a564cf0cd0efc816fa1a5579d3655948cd822a5 Mon Sep 17 00:00:00 2001 From: Patrick Date: Thu, 2 Jan 2025 20:50:29 +0100 Subject: [PATCH] nixos/networkd-dispatcher: use writeShellApplication to ease use --- .../networking/networkd-dispatcher.nix | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/nixos/modules/services/networking/networkd-dispatcher.nix b/nixos/modules/services/networking/networkd-dispatcher.nix index 99b56609a70f..eb874447bb3a 100644 --- a/nixos/modules/services/networking/networkd-dispatcher.nix +++ b/nixos/modules/services/networking/networkd-dispatcher.nix @@ -103,21 +103,29 @@ in services.networkd-dispatcher.extraArgs = let - scriptDir = pkgs.symlinkJoin { - name = "networkd-dispatcher-script-dir"; - paths = lib.mapAttrsToList ( - name: cfg: - (map ( - state: - pkgs.writeTextFile { - inherit name; - text = cfg.script; - destination = "/${state}.d/${name}"; - executable = true; - } - ) cfg.onState) - ) cfg.rules; - }; + scriptDir = pkgs.runCommand "networkd-dispatcher-script-dir" { } ( + '' + mkdir $out + '' + + (lib.concatStrings ( + lib.mapAttrsToList ( + name: cfg: + (lib.concatStrings ( + map (state: '' + mkdir -p $out/${state}.d + ln -s ${ + lib.getExe ( + pkgs.writeShellApplication { + inherit name; + text = cfg.script; + } + ) + } $out/${state}.d/${name} + '') cfg.onState + )) + ) cfg.rules + )) + ); in [ "--verbose"