about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/ki
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2024-05-03 15:14:25 +0200
committerAlyssa Ross <hi@alyssa.is>2024-05-07 11:19:19 +0200
commitd92b2b6a1bbd322dd65a8b6f51019610d350046e (patch)
tree7f7c21927b9cc05676501f297c51eb76b49e326c /nixpkgs/pkgs/by-name/ki
parent93c9e56b40530cc627d921cfc255c05b495d4017 (diff)
parent49050352f602fe87d16ff7b2b6a05b79eb20dc6f (diff)
downloadnixlib-d92b2b6a1bbd322dd65a8b6f51019610d350046e.tar
nixlib-d92b2b6a1bbd322dd65a8b6f51019610d350046e.tar.gz
nixlib-d92b2b6a1bbd322dd65a8b6f51019610d350046e.tar.bz2
nixlib-d92b2b6a1bbd322dd65a8b6f51019610d350046e.tar.lz
nixlib-d92b2b6a1bbd322dd65a8b6f51019610d350046e.tar.xz
nixlib-d92b2b6a1bbd322dd65a8b6f51019610d350046e.tar.zst
nixlib-d92b2b6a1bbd322dd65a8b6f51019610d350046e.zip
Merge remote-tracking branch 'nixpkgs/nixos-unstable-small'
Conflicts:
	nixpkgs/nixos/modules/services/mail/mailman.nix
	nixpkgs/nixos/modules/services/mail/public-inbox.nix
	nixpkgs/pkgs/build-support/go/module.nix
Diffstat (limited to 'nixpkgs/pkgs/by-name/ki')
-rw-r--r--nixpkgs/pkgs/by-name/ki/ki/package.nix69
-rw-r--r--nixpkgs/pkgs/by-name/ki/ki/replace-deprecated-distutils-with-setuptools.patch13
-rw-r--r--nixpkgs/pkgs/by-name/ki/ki/update-to-newer-anki-versions.patch141
-rw-r--r--nixpkgs/pkgs/by-name/ki/kittysay/package.nix28
4 files changed, 251 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/by-name/ki/ki/package.nix b/nixpkgs/pkgs/by-name/ki/ki/package.nix
new file mode 100644
index 000000000000..549f60acd8bf
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/ki/ki/package.nix
@@ -0,0 +1,69 @@
+{ lib
+, fetchFromGitHub
+, python3Packages
+, cmake
+, anki
+}:
+
+python3Packages.buildPythonApplication rec {
+  pname = "ki";
+  version = "0-unstable-2023-11-08";
+
+  pyproject = true;
+
+  disabled = python3Packages.pythonOlder "3.9";
+
+  src = fetchFromGitHub {
+    owner = "langfield";
+    repo = pname;
+    rev = "eb32fbd3229dc1a60bcc76a937ad63f3eb869f65";
+    sha256 = "sha256-5mQhJhvJQC9835goL3t3DRbD+c4P3KxnOflxvqmxL58=";
+  };
+
+  patches = [
+    ./update-to-newer-anki-versions.patch
+    ./replace-deprecated-distutils-with-setuptools.patch
+  ];
+
+  nativeBuildInputs = [ cmake ];
+
+  propagatedBuildInputs = with python3Packages; [
+    beartype
+    click
+    colorama
+    git-filter-repo
+    gitpython
+    lark
+    tqdm
+    whatthepatch
+  ] ++ [
+    anki
+  ];
+
+  nativeCheckInputs = with python3Packages; [
+    bitstring
+    checksumdir
+    gitpython
+    loguru
+    pytest-mock
+    pytestCheckHook
+  ];
+
+  disabledTests = [
+    # requires git to not be in path, but git is needed for other tests
+    "test_clone_cleans_up_on_error"
+    "test_clone_clean_up_preserves_directories_that_exist_a_priori"
+  ];
+
+  dontCheckRuntimeDeps = true;
+
+  # CMake needs to be run by pyproject rather than by its hook
+  dontConfigure = true;
+
+  meta = with lib; {
+    description = "Version control for Anki collections";
+    homepage = "https://github.com/langfield/ki";
+    license = licenses.agpl3Only;
+    maintainers = with maintainers; [ eljamm ];
+  };
+}
diff --git a/nixpkgs/pkgs/by-name/ki/ki/replace-deprecated-distutils-with-setuptools.patch b/nixpkgs/pkgs/by-name/ki/ki/replace-deprecated-distutils-with-setuptools.patch
new file mode 100644
index 000000000000..0a47f1a731e2
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/ki/ki/replace-deprecated-distutils-with-setuptools.patch
@@ -0,0 +1,13 @@
+diff --git a/tests/test_integration.py b/tests/test_integration.py
+index 93d3661..ef24fca 100644
+--- a/tests/test_integration.py
++++ b/tests/test_integration.py
+@@ -7,7 +7,7 @@ import sqlite3
+ import tempfile
+ import subprocess
+ from pathlib import Path
+-from distutils.dir_util import copy_tree
++from setuptools._distutils.dir_util import copy_tree
+ from importlib.metadata import version
+ 
+ import git
diff --git a/nixpkgs/pkgs/by-name/ki/ki/update-to-newer-anki-versions.patch b/nixpkgs/pkgs/by-name/ki/ki/update-to-newer-anki-versions.patch
new file mode 100644
index 000000000000..e0f8549f120d
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/ki/ki/update-to-newer-anki-versions.patch
@@ -0,0 +1,141 @@
+diff --git a/ki/__init__.py b/ki/__init__.py
+index 3f29c1a..f4ad950 100644
+--- a/ki/__init__.py
++++ b/ki/__init__.py
+@@ -1321,7 +1321,7 @@ def _clone1(collection: str, directory: str = "") -> git.Repo:
+     try:
+         col = M.collection(col_file)
+         _, _ = _clone2(col, targetdir, msg="Initial commit", silent=False)
+-        col.close(save=False)
++        col.close()
+         kirepo: KiRepo = M.kirepo(targetdir)
+         kirepo.repo.create_tag(LCA)
+         kirepo.repo.close()
+@@ -1404,11 +1404,11 @@ def _pull1() -> None:
+     hashes = list(filter(lambda l: l != "", hashes))
+     if md5sum in hashes[-1]:
+         echo("ki pull: up to date.")
+-        col.close(save=False)
++        col.close()
+         return
+ 
+     col = _pull2(kirepo, col)
+-    col.close(save=False)
++    col.close()
+ 
+ 
+ @beartype
+@@ -1545,7 +1545,7 @@ def _push() -> PushResult:
+     # If there are no changes, quit.
+     if len(set(deltas)) == 0:
+         echo("ki push: up to date.")
+-        col.close(save=False)
++        col.close()
+         return PushResult.UP_TO_DATE
+ 
+     echo(f"Pushing to '{kirepo.col_file}'")
+@@ -1603,7 +1603,7 @@ def write_collection(
+     do(warn, F.cat(map(push_note(tempcol, timestamp_ns, guids, new_nids), decknotes)))
+ 
+     # It is always safe to save changes to the DB, since the DB is a copy.
+-    tempcol.close(save=True)
++    tempcol.close()
+ 
+     # Backup collection file and overwrite collection.
+     backup(kirepo)
+@@ -1621,7 +1621,7 @@ def write_collection(
+     renames = filter(lambda a: a.file.name != a.new_name, map(addmedia(col), mbytes))
+     warnings = map(lambda r: RenamedMediaFileWarning(r.file.name, r.new_name), renames)
+     do(warn, warnings)
+-    col.close(save=True)
++    col.close()
+ 
+     # Append and commit collection checksum to hashes file.
+     append_md5sum(kirepo.ki, kirepo.col_file.name, F.md5(kirepo.col_file))
+diff --git a/tests/test_integration.py b/tests/test_integration.py
+index e046b8c..93d3661 100644
+--- a/tests/test_integration.py
++++ b/tests/test_integration.py
+@@ -320,7 +320,7 @@ def test_clone_generates_deck_tree_correctly():
+     # Create empty decks.
+     col = opencol(a)
+     do(col.decks.id, [":a:::b:", "blank::blank", "blank::Hello"])
+-    col.close(save=True)
++    col.close()
+ 
+     os.chdir(F.mkdtemp())
+     clone(a)
+@@ -401,7 +401,7 @@ def test_clone_writes_media_files():
+     a: File = mkcol([("Basic", ["Default"], 1, ["a", "b[sound:1sec.mp3]"])])
+     col = opencol(a)
+     col.media.add_file(DATA / "media/1sec.mp3")
+-    col.close(save=True)
++    col.close()
+     clone(a)
+     assert (Path(MEDIA) / "1sec.mp3").is_file()
+ 
+@@ -883,7 +883,7 @@ def test_push_writes_media():
+     write_basic("Default", ("air", '<img src="bullhorn-lg.png">'))
+     col = opencol(a)
+     col.media.add_file(DATA / "media/bullhorn-lg.png")
+-    col.close(save=True)
++    col.close()
+     F.commitall(repo, ".")
+     repo.close()
+     out = push()
+@@ -987,7 +987,7 @@ def test_push_doesnt_unnecessarily_deduplicate_notetypes():
+ 
+     col = opencol(a)
+     models = col.models.all_names_and_ids()
+-    col.close(save=False)
++    col.close()
+ 
+     # Remove a note.
+     assert os.path.isfile("Default/a.md")
+@@ -1012,7 +1012,7 @@ def test_push_doesnt_unnecessarily_deduplicate_notetypes():
+ 
+     col = opencol(a)
+     assert len(models) == len(col.models.all_names_and_ids())
+-    col.close(save=False)
++    col.close()
+ 
+ 
+ def test_push_is_nontrivial_when_pushed_changes_are_reverted_in_repository():
+diff --git a/tests/test_ki.py b/tests/test_ki.py
+index 5270b56..e5f3297 100644
+--- a/tests/test_ki.py
++++ b/tests/test_ki.py
+@@ -482,7 +482,7 @@ def mkcol(ns: List[NoteSpec]) -> File:
+     file = F.touch(F.mkdtemp(), "a.anki2")
+     col = opencol(file)
+     do(addnote(col), ns)
+-    col.close(save=True)
++    col.close()
+     return F.chk(file)
+ 
+ 
+@@ -491,7 +491,7 @@ def rm(f: File, nid: int) -> File:
+     """Remove note with given `nid`."""
+     col = opencol(f)
+     col.remove_notes([nid])
+-    col.close(save=True)
++    col.close()
+     return f
+ 
+ 
+@@ -514,7 +514,7 @@ def edit(f: File, spec: NoteSpec) -> File:
+     """Edit a note with specified nid."""
+     col = opencol(f)
+     editnote(col, spec)
+-    col.close(save=True)
++    col.close()
+     return f
+ 
+ 
+@@ -531,7 +531,7 @@ def editcol(
+     do(addnote(col), adds)
+     do(editnote(col), edits)
+     col.remove_notes(deletes)
+-    col.close(save=True)
++    col.close()
+     return f
diff --git a/nixpkgs/pkgs/by-name/ki/kittysay/package.nix b/nixpkgs/pkgs/by-name/ki/kittysay/package.nix
new file mode 100644
index 000000000000..27433adcc99c
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/ki/kittysay/package.nix
@@ -0,0 +1,28 @@
+{
+  lib,
+  rustPlatform,
+  fetchFromGitHub,
+}: let
+  version = "0.5.0";
+in
+  rustPlatform.buildRustPackage {
+    pname = "kittysay";
+    inherit version;
+
+    src = fetchFromGitHub {
+      owner = "uncenter";
+      repo = "kittysay";
+      rev = "v${version}";
+      sha256 = "sha256-eOcHrEvU3nBKFokwE8CyDOUYoBA1+gBlnl7VRUuoFfE=";
+    };
+
+    cargoHash = "sha256-dVgPp5jY3ii8mO/HLTDESQzQyZXzqut8Bjm2KfWD0+U=";
+
+    meta = {
+      description = "Cowsay, but with a cute kitty :3";
+      homepage = "https://github.com/uncenter/kittysay";
+      license = lib.licenses.gpl3Only;
+      maintainers = with lib.maintainers; [isabelroses uncenter];
+      mainProgram = "kittysay";
+    };
+  }