55 pkgs ,
66 ...
77} :
8- with builtins ;
98let
109 cfg = config . services . tor ;
1110 opt = options . services . tor ;
1514 See [torrc manual](https://2019.www.torproject.org/docs/tor-manual.html.en#${ option } ).
1615 '' ;
1716 bindsPrivilegedPort =
18- any
17+ lib . any
1918 (
2019 p0 :
2120 let
2524 false
2625 else
2726 let
28- p2 = if isInt p1 then p1 else toInt p1 ;
27+ p2 = if lib . isInt p1 then p1 else lib . toInt p1 ;
2928 in
3029 p1 != null && 0 < p2 && p2 < 1024
3130 )
197196 config = lib . mkIf doConfig {
198197 # Only add flags in SOCKSPort to avoid duplicates
199198 flags =
200- filter ( name : config . ${ name } == true ) flags
199+ lib . filter ( name : config . ${ name } == true ) flags
201200 ++ lib . optional ( config . SessionGroup != null ) "SessionGroup=${ toString config . SessionGroup } " ;
202201 } ;
203202 }
@@ -272,16 +271,16 @@ let
272271 k : v :
273272 if v == null then
274273 ""
275- else if isBool v then
274+ else if lib . isBool v then
276275 ( if v then "1" else "0" )
277276 else if v ? "unix" && v . unix != null then
278- "unix:" + v . unix + lib . optionalString ( v ? "flags" ) ( " " + concatStringsSep " " v . flags )
277+ "unix:" + v . unix + lib . optionalString ( v ? "flags" ) ( " " + lib . concatStringsSep " " v . flags )
279278 else if v ? "port" && v . port != null then
280279 lib . optionalString ( v ? "addr" && v . addr != null ) "${ v . addr } :"
281280 + toString v . port
282- + lib . optionalString ( v ? "flags" ) ( " " + concatStringsSep " " v . flags )
281+ + lib . optionalString ( v ? "flags" ) ( " " + lib . concatStringsSep " " v . flags )
283282 else if k == "ServerTransportPlugin" then
284- lib . optionalString ( v . transports != [ ] ) "${ concatStringsSep "," v . transports } exec ${ v . exec } "
283+ lib . optionalString ( v . transports != [ ] ) "${ lib . concatStringsSep "," v . transports } exec ${ v . exec } "
285284 else if k == "HidServAuth" then
286285 v . onion + " " + v . auth
287286 else
@@ -298,15 +297,15 @@ let
298297 k : v :
299298 # Not necesssary, but prettier rendering
300299 if
301- elem k [
300+ lib . elem k [
302301 "AutomapHostsSuffixes"
303302 "DirPolicy"
304303 "ExitPolicy"
305304 "SocksPolicy"
306305 ]
307306 && v != [ ]
308307 then
309- concatStringsSep "," v
308+ lib . concatStringsSep "," v
310309 else
311310 v
312311 ) ( lib . filterAttrs ( k : v : ! ( v == null || v == "" ) ) settings )
750749 ] ) ;
751750 apply = map (
752751 v :
753- if isInt v then
752+ if lib . isInt v then
754753 {
755754 port = v ;
756755 target = null ;
816815 settings . HiddenServiceVersion = config . version ;
817816 settings . HiddenServiceAuthorizeClient =
818817 if config . authorizeClient != null then
819- config . authorizeClient . authType + " " + concatStringsSep "," config . authorizeClient . clientNames
818+ config . authorizeClient . authType + " " + lib . concatStringsSep "," config . authorizeClient . clientNames
820819 else
821820 null ;
822821 settings . HiddenServicePort = map (
998997 }
999998 ) )
1000999 ] ) ;
1001- apply = p : if isInt p || isString p then { port = p ; } else p ;
1000+ apply = p : if lib . isInt p || lib . isString p then { port = p ; } else p ;
10021001 } ;
10031002 options . ExtORPortCookieAuthFile = optionPath "ExtORPortCookieAuthFile" ;
10041003 options . ExtORPortCookieAuthFileGroupReadable = optionBool "ExtORPortCookieAuthFileGroupReadable" ;
@@ -1198,17 +1197,17 @@ in
11981197 lib . mapAttrsToList (
11991198 n : o :
12001199 lib . optionals ( o . settings . HiddenServiceVersion == 2 ) [
1201- ( optional ( o . settings . HiddenServiceExportCircuitID != null ) ''
1200+ ( lib . optional ( o . settings . HiddenServiceExportCircuitID != null ) ''
12021201 HiddenServiceExportCircuitID is used in the HiddenService: ${ n }
12031202 but this option is only for v3 hidden services.
12041203 '' )
12051204 ]
12061205 ++ lib . optionals ( o . settings . HiddenServiceVersion != 2 ) [
1207- ( optional ( o . settings . HiddenServiceAuthorizeClient != null ) ''
1206+ ( lib . optional ( o . settings . HiddenServiceAuthorizeClient != null ) ''
12081207 HiddenServiceAuthorizeClient is used in the HiddenService: ${ n }
12091208 but this option is only for v2 hidden services.
12101209 '' )
1211- ( optional ( o . settings . RendPostPeriod != null ) ''
1210+ ( lib . optional ( o . settings . RendPostPeriod != null ) ''
12121211 RendPostPeriod is used in the HiddenService: ${ n }
12131212 but this option is only for v2 hidden services.
12141213 '' )
12451244 }
12461245 //
12471246 lib . optionalAttrs
1248- ( elem cfg . relay . role [
1247+ ( lib . elem cfg . relay . role [
12491248 "bridge"
12501249 "private-bridge"
12511250 ] )
@@ -1307,13 +1306,13 @@ in
13071306
13081307 networking . firewall = lib . mkIf cfg . openFirewall {
13091308 allowedTCPPorts =
1310- concatMap
1309+ lib . concatMap
13111310 (
13121311 o :
1313- if isInt o && o > 0 then
1312+ if lib . isInt o && o > 0 then
13141313 [ o ]
13151314 else
1316- lib . optionals ( o ? "port" && isInt o . port && o . port > 0 ) [ o . port ]
1315+ lib . optionals ( o ? "port" && lib . isInt o . port && o . port > 0 ) [ o . port ]
13171316 )
13181317 (
13191318 lib . flatten [
@@ -1341,40 +1340,40 @@ in
13411340 (
13421341 "+"
13431342 + pkgs . writeShellScript "ExecStartPre" (
1344- concatStringsSep "\n " (
1343+ lib . concatStringsSep "\n " (
13451344 lib . flatten (
13461345 [ "set -eu" ]
13471346 ++ lib . mapAttrsToList (
13481347 name : onion :
13491348 lib . optional ( onion . authorizedClients != [ ] ) ''
1350- rm -rf ${ escapeShellArg onion . path } /authorized_clients
1351- install -d -o tor -g tor -m 0700 ${ escapeShellArg onion . path } ${ escapeShellArg onion . path } /authorized_clients
1349+ rm -rf ${ lib . escapeShellArg onion . path } /authorized_clients
1350+ install -d -o tor -g tor -m 0700 ${ lib . escapeShellArg onion . path } ${ lib . escapeShellArg onion . path } /authorized_clients
13521351 ''
1353- ++ imap0 ( i : pubKey : ''
1352+ ++ lib . imap0 ( i : pubKey : ''
13541353 echo ${ pubKey } |
1355- install -o tor -g tor -m 0400 /dev/stdin ${ escapeShellArg onion . path } /authorized_clients/${ toString i } .auth
1354+ install -o tor -g tor -m 0400 /dev/stdin ${ lib . escapeShellArg onion . path } /authorized_clients/${ toString i } .auth
13561355 '' ) onion . authorizedClients
13571356 ++ lib . optional ( onion . secretKey != null ) ''
1358- install -d -o tor -g tor -m 0700 ${ escapeShellArg onion . path }
1359- key="$(cut -f1 -d: ${ escapeShellArg onion . secretKey } | head -1)"
1357+ install -d -o tor -g tor -m 0700 ${ lib . escapeShellArg onion . path }
1358+ key="$(cut -f1 -d: ${ lib . escapeShellArg onion . secretKey } | head -1)"
13601359 case "$key" in
13611360 ("== ed25519v"*"-secret")
1362- install -o tor -g tor -m 0400 ${ escapeShellArg onion . secretKey } ${ escapeShellArg onion . path } /hs_ed25519_secret_key;;
1361+ install -o tor -g tor -m 0400 ${ lib . escapeShellArg onion . secretKey } ${ lib . escapeShellArg onion . path } /hs_ed25519_secret_key;;
13631362 (*) echo >&2 "NixOS does not (yet) support secret key type for onion: ${ name } "; exit 1;;
13641363 esac
13651364 ''
13661365 ) cfg . relay . onionServices
13671366 ++ lib . mapAttrsToList (
13681367 name : onion :
1369- imap0 (
1368+ lib . imap0 (
13701369 i : prvKeyPath :
13711370 let
1372- hostname = removeSuffix ".onion" name ;
1371+ hostname = lib . removeSuffix ".onion" name ;
13731372 in
13741373 ''
1375- printf "%s:" ${ escapeShellArg hostname } | cat - ${ escapeShellArg prvKeyPath } |
1374+ printf "%s:" ${ lib . escapeShellArg hostname } | cat - ${ lib . escapeShellArg prvKeyPath } |
13761375 install -o tor -g tor -m 0700 /dev/stdin \
1377- ${ runDir } /ClientOnionAuthDir/${ escapeShellArg hostname } .${ toString i } .auth_private
1376+ ${ runDir } /ClientOnionAuthDir/${ lib . escapeShellArg hostname } .${ toString i } .auth_private
13781377 ''
13791378 ) onion . clientAuthorizations
13801379 ) cfg . client . onionServices
14171416 BindPaths = [ stateDir ] ;
14181417 BindReadOnlyPaths =
14191418 [
1420- storeDir
1419+ builtins . storeDir
14211420 "/etc"
14221421 ]
14231422 ++ lib . optionals config . services . resolved . enable [
0 commit comments