Skip to content

Commit f28864e

Browse files
authored
nixos: fix various modules after with lib removal (#370042)
2 parents 470337f + c0f2a3c commit f28864e

File tree

7 files changed

+45
-46
lines changed

7 files changed

+45
-46
lines changed

nixos/modules/services/security/certmgr.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ in
130130
type = addCheck str (
131131
x:
132132
cfg.svcManager == "command"
133-
|| elem x [
133+
|| lib.elem x [
134134
"restart"
135135
"reload"
136136
"nop"

nixos/modules/services/security/cfssl.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ in
193193
ExecStart =
194194
with cfg;
195195
let
196-
opt = n: v: optionalString (v != null) ''-${n}="${v}"'';
196+
opt = n: v: lib.optionalString (v != null) ''-${n}="${v}"'';
197197
in
198198
lib.concatStringsSep " \\\n" [
199199
"${pkgs.cfssl}/bin/cfssl serve"

nixos/modules/services/security/endlessh-go.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ in
9494
Restart = "always";
9595
ExecStart =
9696
with cfg;
97-
concatStringsSep " " (
97+
lib.concatStringsSep " " (
9898
[
9999
(lib.getExe cfg.package)
100100
"-logtostderr"
101101
"-host=${listenAddress}"
102102
"-port=${toString port}"
103103
]
104-
++ optionals prometheus.enable [
104+
++ lib.optionals prometheus.enable [
105105
"-enable_prometheus"
106106
"-prometheus_host=${prometheus.listenAddress}"
107107
"-prometheus_port=${toString prometheus.port}"
@@ -149,7 +149,7 @@ in
149149
};
150150
};
151151

152-
networking.firewall.allowedTCPPorts = with cfg; optionals openFirewall [ port ];
152+
networking.firewall.allowedTCPPorts = with cfg; lib.optionals openFirewall [ port ];
153153
};
154154

155155
meta.maintainers = with lib.maintainers; [ azahi ];

nixos/modules/services/security/endlessh.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ in
6060
Restart = "always";
6161
ExecStart =
6262
with cfg;
63-
concatStringsSep " " (
63+
lib.concatStringsSep " " (
6464
[
6565
"${pkgs.endlessh}/bin/endlessh"
6666
"-p ${toString port}"
@@ -109,7 +109,7 @@ in
109109
};
110110
};
111111

112-
networking.firewall.allowedTCPPorts = with cfg; optionals openFirewall [ port ];
112+
networking.firewall.allowedTCPPorts = with cfg; lib.optionals openFirewall [ port ];
113113
};
114114

115115
meta.maintainers = with lib.maintainers; [ azahi ];

nixos/modules/services/security/tor.nix

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
pkgs,
66
...
77
}:
8-
with builtins;
98
let
109
cfg = config.services.tor;
1110
opt = options.services.tor;
@@ -15,7 +14,7 @@ let
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
@@ -25,7 +24,7 @@ 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
)
@@ -197,7 +196,7 @@ let
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)
@@ -750,7 +749,7 @@ in
750749
]);
751750
apply = map (
752751
v:
753-
if isInt v then
752+
if lib.isInt v then
754753
{
755754
port = v;
756755
target = null;
@@ -816,7 +815,7 @@ in
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 (
@@ -998,7 +997,7 @@ in
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
'')
@@ -1245,7 +1244,7 @@ in
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
@@ -1417,7 +1416,7 @@ in
14171416
BindPaths = [ stateDir ];
14181417
BindReadOnlyPaths =
14191418
[
1420-
storeDir
1419+
builtins.storeDir
14211420
"/etc"
14221421
]
14231422
++ lib.optionals config.services.resolved.enable [

nixos/modules/services/system/cloud-init.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ let
1717
util-linux
1818
busybox
1919
]
20-
++ optional cfg.btrfs.enable btrfs-progs
21-
++ optional cfg.ext4.enable e2fsprogs
22-
++ optional cfg.xfs.enable xfsprogs
20+
++ lib.optional cfg.btrfs.enable btrfs-progs
21+
++ lib.optional cfg.ext4.enable e2fsprogs
22+
++ lib.optional cfg.xfs.enable xfsprogs
2323
++ cfg.extraPackages;
2424
hasFs = fsName: lib.any (fs: fs.fsType == fsName) (lib.attrValues config.fileSystems);
2525
settingsFormat = pkgs.formats.yaml { };

nixos/modules/services/torrent/magnetico.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let
1515
credentialsFile
1616
else
1717
pkgs.writeText "magnetico-credentials" (
18-
concatStrings (mapAttrsToList (user: hash: "${user}:${hash}\n") cfg.web.credentials)
18+
lib.concatStrings (lib.mapAttrsToList (user: hash: "${user}:${hash}\n") cfg.web.credentials)
1919
);
2020

2121
# default options in magneticod/main.go
@@ -28,7 +28,7 @@ let
2828

2929
crawlerArgs =
3030
with cfg.crawler;
31-
escapeShellArgs (
31+
lib.escapeShellArgs (
3232
[
3333
"--database=${dbURI}"
3434
"--indexer-addr=${address}:${toString port}"
@@ -40,7 +40,7 @@ let
4040

4141
webArgs =
4242
with cfg.web;
43-
escapeShellArgs (
43+
lib.escapeShellArgs (
4444
[
4545
"--database=${dbURI}"
4646
(

0 commit comments

Comments
 (0)