From ee9d6cd0d3a13427bc989ac8373e6f6ce48265d1 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Sun, 29 Dec 2024 21:50:38 +0100 Subject: [PATCH] nixos/services.tor.torsocks: remove `with lib;` --- nixos/modules/services/security/torsocks.nix | 41 +++++++++----------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/nixos/modules/services/security/torsocks.nix b/nixos/modules/services/security/torsocks.nix index 32047f613d9f..e556ab44e1e2 100644 --- a/nixos/modules/services/security/torsocks.nix +++ b/nixos/modules/services/security/torsocks.nix @@ -1,14 +1,11 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.tor.torsocks; - optionalNullStr = b: v: optionalString (b != null) v; + optionalNullStr = b: v: lib.optionalString (b != null) v; configFile = server: '' - TorAddress ${toString (head (splitString ":" server))} - TorPort ${toString (tail (splitString ":" server))} + TorAddress ${toString (lib.head (lib.splitString ":" server))} + TorPort ${toString (lib.tail (lib.splitString ":" server))} OnionAddrRange ${cfg.onionAddrRange} @@ -34,18 +31,18 @@ in { options = { services.tor.torsocks = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = config.services.tor.enable && config.services.tor.client.enable; - defaultText = literalExpression "config.services.tor.enable && config.services.tor.client.enable"; + defaultText = lib.literalExpression "config.services.tor.enable && config.services.tor.client.enable"; description = '' Whether to build `/etc/tor/torsocks.conf` containing the specified global torsocks configuration. ''; }; - server = mkOption { - type = types.str; + server = lib.mkOption { + type = lib.types.str; default = "127.0.0.1:9050"; example = "192.168.0.20:1234"; description = '' @@ -54,8 +51,8 @@ in ''; }; - fasterServer = mkOption { - type = types.str; + fasterServer = lib.mkOption { + type = lib.types.str; default = "127.0.0.1:9063"; example = "192.168.0.20:1234"; description = '' @@ -64,8 +61,8 @@ in ''; }; - onionAddrRange = mkOption { - type = types.str; + onionAddrRange = lib.mkOption { + type = lib.types.str; default = "127.42.42.0/24"; description = '' Tor hidden sites do not have real IP addresses. This @@ -77,8 +74,8 @@ in ''; }; - socks5Username = mkOption { - type = types.nullOr types.str; + socks5Username = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; example = "bob"; description = '' @@ -87,8 +84,8 @@ in ''; }; - socks5Password = mkOption { - type = types.nullOr types.str; + socks5Password = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; example = "sekret"; description = '' @@ -97,8 +94,8 @@ in ''; }; - allowInbound = mkOption { - type = types.bool; + allowInbound = lib.mkOption { + type = lib.types.bool; default = false; description = '' Set Torsocks to accept inbound connections. If set to @@ -110,7 +107,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ pkgs.torsocks (wrapTorsocks "torsocks-faster" cfg.fasterServer) ]; environment.etc."tor/torsocks.conf" =