From 565fffe39d8bc511fa0feb98a245f20295f806fd Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Thu, 21 Aug 2025 06:38:52 +0200 Subject: refactor: pass lib and pkgs to helpers.nix --- nixos/helpers.nix | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'nixos/helpers.nix') diff --git a/nixos/helpers.nix b/nixos/helpers.nix index c6d1ff8..cadf230 100644 --- a/nixos/helpers.nix +++ b/nixos/helpers.nix @@ -1,8 +1,5 @@ -{ config, ... }: +{ config, lib, pkgs, ... }: -let - nixpkgs = import {}; -in { mkNginxConfig = name: '' access_log /var/log/nginx/${name}.access.log json; @@ -64,7 +61,7 @@ in ''; joinWgNamespace = ns: cfg: - nixpkgs.lib.attrsets.recursiveUpdate cfg { + lib.attrsets.recursiveUpdate cfg { bindsTo = ["netns@${ns}.service"]; after = ["wireguard-wg-${ns}.service"]; unitConfig.JoinsNamespaceOf = "netns@${ns}.service"; @@ -81,13 +78,9 @@ in TimeoutStopSec = 300; }; wantedBy = ["multi-user.target"]; - script = - let - pkgs = nixpkgs.pkgs; - in - '' - ${pkgs.iproute2}/bin/ip netns exec ${ns} ${pkgs.iproute2}/bin/ip link set dev lo up - ${pkgs.socat}/bin/socat tcp-listen:${toString port},fork,reuseaddr exec:'${pkgs.iproute2}/bin/ip netns exec ${ns} ${pkgs.socat}/bin/socat STDIO "tcp-connect:localhost:${toString port}"',nofork - ''; + script = '' + ${pkgs.iproute2}/bin/ip netns exec ${ns} ${pkgs.iproute2}/bin/ip link set dev lo up + ${pkgs.socat}/bin/socat tcp-listen:${toString port},fork,reuseaddr exec:'${pkgs.iproute2}/bin/ip netns exec ${ns} ${pkgs.socat}/bin/socat STDIO "tcp-connect:localhost:${toString port}"',nofork + ''; }; } -- cgit v1.2.3