about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/backup/gphotos-sync
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/backup/gphotos-sync')
-rw-r--r--nixpkgs/pkgs/tools/backup/gphotos-sync/default.nix62
-rw-r--r--nixpkgs/pkgs/tools/backup/gphotos-sync/skip-network-tests.patch21
2 files changed, 83 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/tools/backup/gphotos-sync/default.nix b/nixpkgs/pkgs/tools/backup/gphotos-sync/default.nix
new file mode 100644
index 000000000000..461931b1b991
--- /dev/null
+++ b/nixpkgs/pkgs/tools/backup/gphotos-sync/default.nix
@@ -0,0 +1,62 @@
+{ lib
+, fetchFromGitHub
+, python3
+, ffmpeg
+}:
+python3.pkgs.buildPythonApplication rec {
+  pname = "gphotos-sync";
+  version = "3.2.1";
+  format = "pyproject";
+
+  src = fetchFromGitHub {
+    owner = "gilesknap";
+    repo = "gphotos-sync";
+    rev = version;
+    hash = "sha256-iTqD/oUQqC7Fju8SEPkSZX7FC9tE4eRCewiJR8STmEw=";
+  };
+
+  patches = [
+    ./skip-network-tests.patch
+  ];
+
+  nativeBuildInputs = with python3.pkgs; [
+    setuptools
+    setuptools-scm
+    wheel
+  ];
+
+  propagatedBuildInputs = with python3.pkgs; [
+    appdirs
+    attrs
+    exif
+    google-auth-oauthlib
+    psutil
+    pyyaml
+    psutil
+    requests-oauthlib
+    types-pyyaml
+    types-requests
+  ];
+
+  buildInputs = [
+    ffmpeg
+  ];
+
+  nativeCheckInputs = with python3.pkgs; [
+    mock
+    pytestCheckHook
+  ];
+
+  preCheck = ''
+    export PY_IGNORE_IMPORTMISMATCH=1
+    export HOME=$(mktemp -d)
+  '';
+
+  meta = with lib; {
+    description = "Google Photos and Albums backup with Google Photos Library API";
+    mainProgram = "gphotos-sync";
+    homepage = "https://github.com/gilesknap/gphotos-sync";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ dnr ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/backup/gphotos-sync/skip-network-tests.patch b/nixpkgs/pkgs/tools/backup/gphotos-sync/skip-network-tests.patch
new file mode 100644
index 000000000000..6f78ed7db3f2
--- /dev/null
+++ b/nixpkgs/pkgs/tools/backup/gphotos-sync/skip-network-tests.patch
@@ -0,0 +1,21 @@
+diff --git a/tests/test_setup.py b/tests/test_setup.py
+index 085b110..ea4a7d2 100644
+--- a/tests/test_setup.py
++++ b/tests/test_setup.py
+@@ -45,7 +45,8 @@ class SetupDbAndCredentials:
+         return self
+ 
+     def __exit__(self, exc_type=None, exc_value=None, traceback=None):
+-        self.gp.google_photos_down.close()
++        if hasattr(self.gp, 'google_photos_down'):
++            self.gp.google_photos_down.close()
+ 
+     def test_setup(self, test_name, args=None, trash_db=False, trash_files=False):
+         self.root = Path("/tmp/gpTests/{}".format(test_name))
+@@ -76,3 +77,6 @@ class SetupDbAndCredentials:
+ 
+     def test_done(self):
+         self.gp.data_store.store()
++
++import pytest, requests
++requests.Session.__init__ = lambda *args, **kwargs: pytest.skip("no network access")