-
-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Yaroslav Bolyukin <[email protected]>
- Loading branch information
1 parent
5d8362b
commit 661c581
Showing
4 changed files
with
268 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,114 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
let | ||
json = pkgs.formats.json { }; | ||
cfg = config.programs.openvpn3; | ||
in | ||
{ | ||
options.programs.openvpn3 = { | ||
enable = lib.mkEnableOption "the openvpn3 client"; | ||
package = lib.mkOption { | ||
type = lib.types.package; | ||
default = pkgs.openvpn3.override { | ||
enableSystemdResolved = config.services.resolved.enable; | ||
user = "openvpn"; | ||
group = "openvpn"; | ||
netcfg-config = "netcfg.json"; | ||
log-service-config = "log-service.json"; | ||
in { | ||
options.programs.openvpn3 = let | ||
inherit (lib) | ||
mkEnableOption mkPackageOption mkOption literalExpression max options | ||
lists; | ||
inherit (lib.types) bool submodule ints; | ||
in { | ||
enable = mkEnableOption "the openvpn3 client"; | ||
package = mkPackageOption pkgs "openvpn3" { }; | ||
netcfg = mkOption { | ||
description = "Network configuration"; | ||
default = { }; | ||
type = submodule { | ||
options = { | ||
settings = mkOption { | ||
description = | ||
"Options stored in `${netcfg-config}` configuration file"; | ||
default = { }; | ||
type = submodule { | ||
freeformType = json.type; | ||
options = { | ||
systemd_resolved = mkOption { | ||
type = bool; | ||
description = "Whether to use systemd-resolved integration"; | ||
default = config.services.resolved.enable; | ||
defaultText = | ||
literalExpression "config.services.resolved.enable"; | ||
example = false; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
log-service = mkOption { | ||
description = "Log service configuration"; | ||
default = { }; | ||
type = submodule { | ||
options = { | ||
settings = mkOption { | ||
description = | ||
"Options stored in `${log-service-config}` configuration file"; | ||
default = { }; | ||
type = submodule { | ||
freeformType = json.type; | ||
options = { | ||
journald = mkOption { | ||
description = "Use systemd-journald"; | ||
type = bool; | ||
default = true; | ||
example = false; | ||
}; | ||
log_dbus_details = mkOption { | ||
description = "Add D-Bus details in log file/syslog"; | ||
type = bool; | ||
default = true; | ||
example = false; | ||
}; | ||
log_level = mkOption { | ||
description = "How verbose should the logging be"; | ||
type = (ints.between 0 7) // { | ||
merge = _loc: defs: | ||
lists.foldl max 0 (options.getValues defs); | ||
}; | ||
default = 3; | ||
example = 6; | ||
}; | ||
timestamp = mkOption { | ||
description = "Add timestamp log file"; | ||
type = bool; | ||
default = true; | ||
example = false; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
defaultText = lib.literalExpression ''pkgs.openvpn3.override { | ||
enableSystemdResolved = config.services.resolved.enable; | ||
}''; | ||
description = '' | ||
Which package to use for `openvpn3`. | ||
''; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
services.dbus.packages = [ | ||
cfg.package | ||
]; | ||
services.dbus.packages = [ cfg.package ]; | ||
|
||
users.users.openvpn = { | ||
users.users."${user}" = { | ||
isSystemUser = true; | ||
uid = config.ids.uids.openvpn; | ||
group = "openvpn"; | ||
uid = config.ids.uids."${user}"; | ||
inherit group; | ||
}; | ||
|
||
users.groups.openvpn = { | ||
gid = config.ids.gids.openvpn; | ||
users.groups."${group}" = { gid = config.ids.gids."${group}"; }; | ||
|
||
environment = { | ||
systemPackages = [ cfg.package ]; | ||
etc = let | ||
genConfig = name: options: { | ||
"openvpn3/${name}".source = json.generate name options; | ||
}; | ||
in (genConfig netcfg-config cfg.netcfg.settings) | ||
// (genConfig log-service-config cfg.log-service.settings); | ||
}; | ||
|
||
environment.systemPackages = [ | ||
cfg.package | ||
]; | ||
systemd.packages = [ cfg.package ]; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
pkgs/tools/networking/openvpn3/patches/0001-customizable-asio-path.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/meson.build b/meson.build | ||
index 2bba337..092b4ce 100644 | ||
--- a/meson.build | ||
+++ b/meson.build | ||
@@ -68,7 +68,7 @@ endif | ||
# | ||
# Setup additional include header dirs | ||
# | ||
-asio_inc = get_option('asio_path') / 'asio' / 'include' | ||
+asio_inc = get_option('asio_path') / 'include' | ||
message ('ASIO library: ' + asio_inc) | ||
|
||
openvpn3_core_inc = get_option('openvpn3_core_path') |
Oops, something went wrong.