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 ++++++------------- nixos/hosts/ev/torrent.nix | 2 +- nixos/hosts/tente/default.nix | 2 +- nixos/hosts/tente/git.nix | 2 +- nixos/hosts/tente/matrix.nix | 2 +- nixos/hosts/tente/web-personal.nix | 2 +- 6 files changed, 11 insertions(+), 18 deletions(-) (limited to 'nixos') 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 + ''; }; } diff --git a/nixos/hosts/ev/torrent.nix b/nixos/hosts/ev/torrent.nix index ddc4dcb..a09c507 100644 --- a/nixos/hosts/ev/torrent.nix +++ b/nixos/hosts/ev/torrent.nix @@ -1,7 +1,7 @@ { config, lib, pkgs, ... }: let - helpers = import { inherit config; }; + helpers = import { inherit config lib pkgs; }; cfg = config.torrent; in { diff --git a/nixos/hosts/tente/default.nix b/nixos/hosts/tente/default.nix index 23e94bc..ac8f438 100644 --- a/nixos/hosts/tente/default.nix +++ b/nixos/hosts/tente/default.nix @@ -8,7 +8,7 @@ let baseDomain = "push-f.com"; acmeEmail = "martin@push-f.com"; sources = import ; - helpers = import { inherit config; }; + helpers = import { inherit config lib pkgs; }; in { imports = [ diff --git a/nixos/hosts/tente/git.nix b/nixos/hosts/tente/git.nix index ee10a43..c5c6478 100644 --- a/nixos/hosts/tente/git.nix +++ b/nixos/hosts/tente/git.nix @@ -2,7 +2,7 @@ let cfg = config.git; - helpers = import { inherit config; }; + helpers = import { inherit config lib pkgs; }; in { options.git = { diff --git a/nixos/hosts/tente/matrix.nix b/nixos/hosts/tente/matrix.nix index cf0f09a..2eb8673 100644 --- a/nixos/hosts/tente/matrix.nix +++ b/nixos/hosts/tente/matrix.nix @@ -2,7 +2,7 @@ let cfg = config.matrix; - helpers = import { inherit config; }; + helpers = import { inherit config lib pkgs; }; in { options.matrix = { diff --git a/nixos/hosts/tente/web-personal.nix b/nixos/hosts/tente/web-personal.nix index 109a87d..d706b9d 100644 --- a/nixos/hosts/tente/web-personal.nix +++ b/nixos/hosts/tente/web-personal.nix @@ -2,7 +2,7 @@ let cfg = config.web-personal; - helpers = import { inherit config; }; + helpers = import { inherit config lib pkgs; }; in { options.web-personal = { -- cgit v1.2.3