diff options
author | aleksana | 2024-07-19 21:11:15 +0800 |
---|---|---|
committer | aleksana | 2024-07-19 23:56:39 +0800 |
commit | 140b20a5c6cf2aa57bfbcabe9a20554d7fc95e40 (patch) | |
tree | 5f9ac3a79b4da686f5f60adbef72adccd29a6e44 /pkgs/by-name/al/alpaca | |
parent | 74d38fdb308da734ea497aae3b98640b4d8265ca (diff) |
alpaca: init at 0.9.6.1
Diffstat (limited to 'pkgs/by-name/al/alpaca')
-rw-r--r-- | pkgs/by-name/al/alpaca/fix_xdg_path_flatpak.patch | 26 | ||||
-rw-r--r-- | pkgs/by-name/al/alpaca/package.nix | 95 |
2 files changed, 121 insertions, 0 deletions
diff --git a/pkgs/by-name/al/alpaca/fix_xdg_path_flatpak.patch b/pkgs/by-name/al/alpaca/fix_xdg_path_flatpak.patch new file mode 100644 index 000000000000..ebb0a44e6575 --- /dev/null +++ b/pkgs/by-name/al/alpaca/fix_xdg_path_flatpak.patch @@ -0,0 +1,26 @@ +diff --git a/src/alpaca.in b/src/alpaca.in +index cb883c8..a9822cc 100755 +--- a/src/alpaca.in ++++ b/src/alpaca.in +@@ -35,7 +35,21 @@ locale.bindtextdomain('alpaca', localedir) + locale.textdomain('alpaca') + gettext.install('alpaca', localedir) + ++# Use the right XDG paths outside flatpak ++def set_xdg_path(env, default): ++ app_id = "com.jeffser.Alpaca" ++ base = os.getenv(env) or os.path.expanduser(default) ++ path = os.path.join(base, app_id) ++ if not os.path.exists(path): ++ os.makedirs(path) ++ os.environ[env] = path ++ return ++ + if __name__ == '__main__': ++ set_xdg_path("XDG_CONFIG_HOME", "~/.config") ++ set_xdg_path("XDG_DATA_HOME", "~/.local/share") ++ set_xdg_path("XDG_CACHE_HOME", "~/.cache") ++ + import gi + + from gi.repository import Gio diff --git a/pkgs/by-name/al/alpaca/package.nix b/pkgs/by-name/al/alpaca/package.nix new file mode 100644 index 000000000000..5ce7ce0b0261 --- /dev/null +++ b/pkgs/by-name/al/alpaca/package.nix @@ -0,0 +1,95 @@ +{ + lib, + python3Packages, + fetchFromGitHub, + fetchpatch, + appstream, + meson, + ninja, + pkg-config, + gobject-introspection, + wrapGAppsHook4, + desktop-file-utils, + libadwaita, + gtksourceview5, + xdg-utils, + ollama, +}: + +python3Packages.buildPythonApplication rec { + pname = "alpaca"; + version = "0.9.6.1"; + pyproject = false; # Built with meson + + src = fetchFromGitHub { + owner = "Jeffser"; + repo = "Alpaca"; + rev = version; + hash = "sha256-EbaEjKqfotJBceaYEyz3LHilK3GnnwEpfMR7Teq96hI="; + }; + + patches = [ + # Change the way XDG paths are handled so it makes sense outside of flatpak + ./fix_xdg_path_flatpak.patch + + # Let ollama instance stop gracefully so we don't have model instance left behind + (fetchpatch { + url = "https://github.com/Jeffser/Alpaca/commit/e81d918675896c1670cf5aa5a55e1b706be5ed51.patch"; + hash = "sha256-gYYFvaoBI/Qn0g2qgS1cB0B4F08swznrSd5KCb51vh0="; + }) + ]; + + postPatch = '' + substituteInPlace src/local_instance.py \ + --replace-fail '/app/bin/ollama' 'ollama' + ''; + + nativeBuildInputs = [ + appstream + meson + ninja + pkg-config + gobject-introspection + wrapGAppsHook4 + desktop-file-utils + ]; + + buildInputs = [ + libadwaita + gtksourceview5 + ]; + + dependencies = with python3Packages; [ + pygobject3 + requests + pillow + pypdf + ]; + + dontWrapGApps = true; + + makeWrapperArgs = [ + "\${gappsWrapperArgs[@]}" + "--prefix PATH : ${lib.makeBinPath [ xdg-utils ollama ]}" + # Declared but not used in src/window.py, for later reference + # https://github.com/flatpak/flatpak/issues/3229 + "--set FLATPAK_DEST ${placeholder "out"}" + ]; + + meta = { + description = "Ollama client made with GTK4 and Adwaita"; + longDescription = '' + To run Alpaca with GPU acceleration enabled, simply override it: + ```nix + pkgs.alpaca.override { + ollama = pkgs.ollama-cuda; + } + ``` + ''; + homepage = "https://jeffser.com/alpaca"; + license = lib.licenses.gpl3Plus; + mainProgram = "alpaca"; + maintainers = with lib.maintainers; [ aleksana ]; + platforms = lib.platforms.linux; + }; +} |