Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openvpn3: v20 -> v22_dev #326623

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 86 additions & 21 deletions nixos/modules/programs/openvpn3.nix
Original file line number Diff line number Diff line change
@@ -1,43 +1,108 @@
{ config, lib, pkgs, ... }:

let
json = pkgs.formats.json { };
cfg = config.programs.openvpn3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cfg = config.programs.openvpn3;
cfg = config.programs.openvpn3;
inherit (lib) mkEnableOption mkPackageOption mkOption literalExpression max options lists;
inherit (lib.types) bool submodule ints;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that all of this imports are specific to building module options, is it worth importing them for the whole module?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using imports for the entire module is more readable, because you don't use nested let statements. It's also easier to understand - I mean, you don't usually scope the stdlib to module options, so choosing to do that raises some questions.

in
{

inherit (lib) mkEnableOption mkPackageOption mkOption literalExpression max options lists;
inherit (lib.types) bool submodule ints;
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;
enable = mkEnableOption "the openvpn3 client";
package = mkPackageOption pkgs "openvpn3" { };
netcfg = mkOption {
description = "Network configuration";
default = { };
type = submodule {
options = {
settings = mkOption {
description = "Options stored in {file}`/etc/openvpn3/netcfg.json` 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 {file}`/etc/openvpn3/log-service.json` 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 = false;
example = true;
};
};
};
};
};
};
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 = {
isSystemUser = true;
uid = config.ids.uids.openvpn;
group = "openvpn";
};

users.groups.openvpn = {
gid = config.ids.gids.openvpn;
users.groups.openvpn = { gid = config.ids.gids.openvpn; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to use static gids here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think that it is a requirement now, but since it was part of the previous module version, I kept it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we are breaking backwards compat anyway, since NixOS rebuild will fail due to the old config file (generated by the binary) already existing, preventing NixOS creating the symlink to NixOS-generated file. And since backwards compat is broken already, we might as well stop using static gid (unless dbus needs static).

Speaking of backwards compat, we probably want to add this notice (as well as the info about the module and binary being updated) to the release notes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since NixOS rebuild will fail due to the old config file (generated by the binary) already existing, preventing NixOS creating the symlink to NixOS-generated file

Actually, it won't since the default path is different from /etc/openvpn3 (to which I do the explicit override when building the package now) thus the updating clients will simply have the new config path without any effect on the old one.


environment = {
systemPackages = [ cfg.package ];
etc = {
"openvpn3/netcfg.json".source =
json.generate "netcfg.json" cfg.netcfg.settings;
"openvpn3/log-service.json".source =
json.generate "log-service.json" cfg.log-service.settings;
};
};

environment.systemPackages = [
cfg.package
];
systemd.packages = [ cfg.package ];
};

meta.maintainers = with lib.maintainers; [ shamilton kfears progrm_jarvis ];
}
45 changes: 45 additions & 0 deletions pkgs/by-name/gd/gdbuspp/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
lib,
stdenv,
fetchgit,
meson,
ninja,
glib,
pkg-config,
}:

stdenv.mkDerivation rec {
pname = "gdbuspp";
version = "1";
src = fetchgit {
url = "https://codeberg.org/OpenVPN/gdbuspp.git";
rev = "refs/tags/v${version}";
hash = "sha256-vw+37RbKRsB+DUyQU+ibwBHCj4jH/FaGl/bGSx7nrwY=";
};

postPatch = ''
patchShebangs --build ./scripts/get-git-ref
'';

nativeBuildInputs = [
meson
ninja
pkg-config
];

buildInputs = [ glib ];

meta = {
description = "GDBus++ - a glib2 D-Bus wrapper for C++";
longDescription = ''
This library provides a simpler C++ based interface to implement D-Bus
into applications in a more C++ approach, based on the C++17 standard.
'';
homepage = "https://codeberg.org/OpenVPN/gdbuspp";
changelog = "https://codeberg.org/OpenVPN/gdbuspp/releases/tag/v${version}";
license = lib.licenses.agpl3Only;
sourceProvenance = [ lib.sourceTypes.fromSource ];
maintainers = [ lib.maintainers.progrm_jarvis ];
platforms = lib.platforms.linux;
};
}
13 changes: 13 additions & 0 deletions pkgs/by-name/op/openvpn3/0001-customizable-asio-path.patch
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')
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
diff --git a/distro/systemd/meson.build b/distro/systemd/meson.build
index 36d556c..9c636b6 100644
--- a/distro/systemd/meson.build
+++ b/distro/systemd/meson.build
@@ -15,12 +15,17 @@ systemd_cfg = configuration_data({

systemd_service_cfg = dependency('systemd')

+systemd_system_unit_dir = get_option('systemd_system_unit_dir')
+if systemd_system_unit_dir == ''
+ systemd_system_unit_dir = systemd_service_cfg.get_variable('systemdsystemunitdir')
+endif
+
configure_file(
input: 'openvpn3-autoload.service.in',
output: 'openvpn3-autoload.service',
configuration: systemd_cfg,
install: true,
- install_dir: systemd_service_cfg.get_variable('systemdsystemunitdir'),
+ install_dir: systemd_system_unit_dir,
)

configure_file(
@@ -28,7 +33,7 @@ configure_file(
output: 'openvpn3-session@.service',
configuration: systemd_cfg,
install: true,
- install_dir: systemd_service_cfg.get_variable('systemdsystemunitdir'),
+ install_dir: systemd_system_unit_dir,
)

custom_target('openvpn3-systemd',
diff --git a/meson.build b/meson.build
index 092b4ce..e1ec8c1 100644
--- a/meson.build
+++ b/meson.build
@@ -180,8 +180,16 @@ message('OpenVPN 3 Linux service binary directory: ' + get_option('prefix') / li

#
# D-Bus configuration
-dbus_policy_dir = dep_dbus.get_variable('datadir') / 'dbus-1' / 'system.d'
-dbus_service_dir = dep_dbus.get_variable('system_bus_services_dir')
+dbus_policy_dir = get_option('dbus_policy_dir')
+if dbus_policy_dir == ''
+ dbus_policy_dir = dep_dbus.get_variable('datadir') / 'dbus-1' / 'system.d'
+endif
+
+dbus_service_dir = get_option('dbus_system_service_dir')
+if dbus_service_dir == ''
+ dbus_service_dir = dep_dbus.get_variable('system_bus_services_dir')
+endif
+
dbus_config = {
'OPENVPN_USERNAME': get_option('openvpn_username'),
'LIBEXEC_PATH': get_option('prefix') / libexec_dir,
diff --git a/meson_options.txt b/meson_options.txt
index e9e759e..68fec37 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -81,6 +81,16 @@ option('use-legacy-polkit-pkla', type: 'feature', value: 'disabled',
option('polkit_pkla_rulesdir', type: 'string', value: '',
description: 'Override PolicyKit PKLA rules directory')

+#
+# Installation paths
+#
+option('dbus_policy_dir', type: 'string',
+ description: 'D-Bus policy directory')
+option('dbus_system_service_dir', type: 'string',
+ description: 'D-Bus system service directory')
+option('systemd_system_unit_dir', type: 'string',
+ description: 'Path to systemd system unit directory')
+
#
# Testing tools
#
diff --git a/src/configmgr/meson.build b/src/configmgr/meson.build
index 5d0a649..b949394 100644
--- a/src/configmgr/meson.build
+++ b/src/configmgr/meson.build
@@ -52,7 +52,3 @@ configure_file(
install_dir: dbus_service_dir,
)

-# Create the configs directory for persistent configuration profiles
-# NOTE: Can be replaced with install_emptydir() when Meson 0.60 or newer
-# is available on all supported distros
-meson.add_install_script('sh','-c', 'mkdir -p $DESTDIR@0@'.format(openvpn3_statedir / 'configs'))
Loading