Skip to content

Commit 6840ba2

Browse files
committed
nixos/networkmanager: set up /etc/ipsec.secrets as required by the L2TP plugin
The networkmanager-l2tp plugin expects /etc/ipsec.secrets to include /etc/ipsec.d/ipsec.nm-l2tp.secrets; see #64965 In order for this to continue working if the strongswan module is enabled, we use `"ipsec.secrets".text` instead of `.source` so that the configurations of both modules are concatenated.
1 parent d1f2bc2 commit 6840ba2

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

nixos/modules/services/networking/networkmanager.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,12 @@ in
514514

515515
environment.etc = {
516516
"NetworkManager/NetworkManager.conf".source = configFile;
517+
518+
# The networkmanager-l2tp plugin expects /etc/ipsec.secrets to include /etc/ipsec.d/ipsec.nm-l2tp.secrets;
519+
# see https://github.com/NixOS/nixpkgs/issues/64965
520+
"ipsec.secrets".text = ''
521+
include ipsec.d/ipsec.nm-l2tp.secrets
522+
'';
517523
}
518524
// builtins.listToAttrs (map
519525
(pkg: nameValuePair "NetworkManager/${pkg.networkManagerPlugin}" {

nixos/modules/services/networking/strongswan.nix

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
let
44

55
inherit (builtins) toFile;
6-
inherit (lib) concatMapStringsSep concatStringsSep mapAttrsToList
6+
inherit (lib) concatMapStrings concatStringsSep mapAttrsToList
77
mkIf mkEnableOption mkOption types literalExpression optionalString;
88

99
cfg = config.services.strongswan;
1010

11-
ipsecSecrets = secrets: toFile "ipsec.secrets" (
12-
concatMapStringsSep "\n" (f: "include ${f}") secrets
13-
);
11+
ipsecSecrets = secrets: concatMapStrings (f: "include ${f}\n") secrets;
1412

1513
ipsecConf = {setup, connections, ca}:
1614
let
@@ -138,16 +136,12 @@ in
138136
};
139137

140138

141-
config = with cfg;
142-
let
143-
secretsFile = ipsecSecrets cfg.secrets;
144-
in
145-
mkIf enable
139+
config = with cfg; mkIf enable
146140
{
147141

148142
# here we should use the default strongswan ipsec.secrets and
149143
# append to it (default one is empty so not a pb for now)
150-
environment.etc."ipsec.secrets".source = secretsFile;
144+
environment.etc."ipsec.secrets".text = ipsecSecrets cfg.secrets;
151145

152146
systemd.services.strongswan = {
153147
description = "strongSwan IPSec Service";
@@ -156,7 +150,10 @@ in
156150
wants = [ "network-online.target" ];
157151
after = [ "network-online.target" ];
158152
environment = {
159-
STRONGSWAN_CONF = strongswanConf { inherit setup connections ca secretsFile managePlugins enabledPlugins; };
153+
STRONGSWAN_CONF = strongswanConf {
154+
inherit setup connections ca managePlugins enabledPlugins;
155+
secretsFile = "/etc/ipsec.secrets";
156+
};
160157
};
161158
serviceConfig = {
162159
ExecStart = "${pkgs.strongswan}/sbin/ipsec start --nofork";

0 commit comments

Comments
 (0)