Skip to content

Instantly share code, notes, and snippets.

@WolfangAukang
Last active May 9, 2022 15:56
Show Gist options
  • Save WolfangAukang/ae5530af0919dd0f750d3130dfa6a493 to your computer and use it in GitHub Desktop.
Save WolfangAukang/ae5530af0919dd0f750d3130dfa6a493 to your computer and use it in GitHub Desktop.
Patch to enable test `protonvpn-nm-lib`. Currently, it fails because it needs to use DBus and can't be found in Nix sandbox. Credits to @NKJe for providing the patches at https://github.com/NixOS/nixpkgs/pull/129333
--- a/protonvpn_nm_lib/core/subprocess_wrapper.py
+++ b/protonvpn_nm_lib/core/subprocess_wrapper.py
@@ -44,11 +44,9 @@
binary_short_name => full secure path.
"""
# Look for root-owned directories in the system path in order
- for path in os.environ.get('PATH', '').split(os.path.pathsep):
+ for path in "@path@".split(os.path.pathsep):
if not os.path.isdir(path):
continue
- if not self.is_root_owned(path):
- continue
# Check for all the binaries that we haven't matched yet
for binary in self._acceptable_binaries.difference(
@@ -58,9 +56,6 @@
if not os.path.isfile(binary_path_candidate):
continue
- if not self.is_root_owned(binary_path_candidate):
- continue
-
# We're happy with that one, store it
self._path_to_binaries[binary] = binary_path_candidate
{ lib
, buildPythonPackage
, fetchFromGitHub
, pythonOlder
, substituteAll
, distro
, jinja2
, keyring
, proton-client
, pygobject3
, pyxdg
, systemd
, networkmanager
, ncurses
, systemd-pkg
, xdg-utils
}:
buildPythonPackage rec {
pname = "protonvpn-nm-lib";
version = "3.9.0";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "ProtonVPN";
repo = pname;
rev = version;
sha256 = "sha256-yV3xeIyPc2DJj5DOa5PA1MHt00bjJ/Y9zZK77s/XRAA=";
};
propagatedBuildInputs = [
distro
jinja2
keyring
proton-client
pygobject3
pyxdg
systemd
];
checkInputs = [
ncurses
networkmanager
systemd-pkg
xdg-utils
];
patches = [
(substituteAll {
src = ./0001-Patching-GIRepository.patch;
networkmanager_path = "${networkmanager}/lib/girepository-1.0";
})
(substituteAll {
src = ./binary-paths.patch;
path = lib.makeBinPath checkInputs;
})
];
# Checks cannot be run in the sandbox
# "Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory"
#doCheck = false;
pythonImportsCheck = [ "protonvpn_nm_lib" ];
meta = with lib; {
description = "ProtonVPN NetworkManager Library intended for every ProtonVPN service user";
homepage = "https://github.com/ProtonVPN/protonvpn-nm-lib";
license = licenses.gpl3Only;
maintainers = with maintainers; [ wolfangaukang ];
platforms = platforms.linux;
};
}
protonvpn-nm-lib = callPackage ../development/python-modules/protonvpn-nm-lib {
systemd-pkg = pkgs.systemd
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment