summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatt Snider <matt.snider@protonmail.com>2020-03-09 22:08:44 +0100
committerMatt Snider <matt.snider@protonmail.com>2020-03-10 20:37:51 +0100
commit1968755fff9c5673b9436dbe3f5c952c5bf359ef (patch)
tree0757297442b6336ced95faf0ee66bba5c330362d
parent98bd9f51fc493af5a83a593e8c956bba5c7fd078 (diff)
downloadnixpkgs-1968755fff9c5673b9436dbe3f5c952c5bf359ef.tar
nixpkgs-1968755fff9c5673b9436dbe3f5c952c5bf359ef.tar.gz
nixpkgs-1968755fff9c5673b9436dbe3f5c952c5bf359ef.tar.bz2
nixpkgs-1968755fff9c5673b9436dbe3f5c952c5bf359ef.tar.lz
nixpkgs-1968755fff9c5673b9436dbe3f5c952c5bf359ef.tar.xz
nixpkgs-1968755fff9c5673b9436dbe3f5c952c5bf359ef.tar.zst
nixpkgs-1968755fff9c5673b9436dbe3f5c952c5bf359ef.zip
ankisyncd: init at 2.1.0
-rw-r--r--pkgs/servers/ankisyncd/default.nix67
-rw-r--r--pkgs/top-level/all-packages.nix2
2 files changed, 69 insertions, 0 deletions
diff --git a/pkgs/servers/ankisyncd/default.nix b/pkgs/servers/ankisyncd/default.nix
new file mode 100644
index 00000000000..e1098670123
--- /dev/null
+++ b/pkgs/servers/ankisyncd/default.nix
@@ -0,0 +1,67 @@
+{ lib
+, fetchFromGitHub
+, python3
+, anki
+}:
+
+python3.pkgs.buildPythonApplication rec {
+  pname = "ankisyncd";
+  version = "2.1.0";
+  src = fetchFromGitHub {
+    owner = "tsudoko";
+    repo = "anki-sync-server";
+    rev = version;
+    sha256 = "6a140afa94fdb1725fed716918875e3d2ad0092cb955136e381c9d826cc4927c";
+  };
+  format = "other";
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/${python3.sitePackages}
+
+    cp -r ankisyncd utils ankisyncd.conf $out/${python3.sitePackages}
+    mkdir $out/share
+    cp ankisyncctl.py $out/share/
+
+    runHook postInstall
+  '';
+
+  fixupPhase = ''
+    PYTHONPATH="$PYTHONPATH:$out/${python3.sitePackages}:${anki}"
+
+    makeWrapper "${python3.interpreter}" "$out/bin/ankisyncd" \
+          --set PYTHONPATH $PYTHONPATH \
+          --add-flags "-m ankisyncd"
+
+    makeWrapper "${python3.interpreter}" "$out/bin/ankisyncctl" \
+          --set PYTHONPATH $PYTHONPATH \
+          --add-flags "$out/share/ankisyncctl.py"
+  '';
+
+  checkInputs = with python3.pkgs; [
+    pytest
+    webtest
+  ];
+
+  buildInputs = [ ];
+
+  propagatedBuildInputs = [ anki ];
+
+  checkPhase = ''
+    # Exclude tests that require sqlite's sqldiff command, since
+    # it isn't yet packaged for NixOS, although 2 PRs exist:
+    # - https://github.com/NixOS/nixpkgs/pull/69112
+    # - https://github.com/NixOS/nixpkgs/pull/75784
+    # Once this is merged, these tests can be run as well.
+    pytest --ignore tests/test_web_media.py tests/
+  '';
+
+  meta = with lib; {
+    description = "Self-hosted Anki sync server";
+    maintainers = with maintainers; [ matt-snider ];
+    homepage = "https://github.com/tsudoko/anki-sync-server";
+    license = licenses.agpl3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 68851738f9e..51d5b8a0126 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -126,6 +126,8 @@ in
 
   addOpenGLRunpath = callPackage ../build-support/add-opengl-runpath { };
 
+  ankisyncd = callPackage ../servers/ankisyncd { };
+
   avro-tools = callPackage ../development/tools/avro-tools { };
 
   # Zip file format only allows times after year 1980, which makes e.g. Python wheel building fail with: