Skip to content

Commit

Permalink
nix(nix/package): split into multiple files, allow overriding of JXL …
Browse files Browse the repository at this point in the history
…and vtf2img
  • Loading branch information
xarvex committed Mar 7, 2025
1 parent 8c9275e commit 031e85f
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 74 deletions.
19 changes: 14 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,20 @@
perSystem =
{ pkgs, ... }:
{
packages = rec {
default = tagstudio;
tagstudio = pkgs.python312Packages.callPackage ./nix/package.nix { };
tagstudio-jxl = tagstudio.override { withJXLSupport = true; };
};
packages =
let
python = pkgs.python312Packages;

pillow-jxl-plugin = python.callPackage ./nix/package/pillow-jxl-plugin.nix { };
vtf2img = python.callPackage ./nix/package/vtf2img.nix { };
in
rec {
default = tagstudio;
tagstudio = pkgs.python312Packages.callPackage ./nix/package {
inherit pillow-jxl-plugin vtf2img;
};
tagstudio-jxl = tagstudio.override { withJXLSupport = true; };
};

devShells = rec {
default = tagstudio;
Expand Down
73 changes: 4 additions & 69 deletions nix/package.nix → nix/package/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
buildPythonApplication,
buildPythonPackage,
chardet,
cmake,
fetchPypi,
ffmpeg-headless,
ffmpeg-python,
hatchling,
Expand All @@ -12,9 +9,9 @@
mutagen,
numpy,
opencv-python,
packaging,
pillow,
pillow-heif,
pillow-jxl-plugin,
pydub,
pyside6,
pytest-qt,
Expand All @@ -23,87 +20,25 @@
pythonRelaxDepsHook,
qt6,
rawpy,
rustPlatform,
send2trash,
sqlalchemy,
structlog,
syrupy,
ujson,
vtf2img,

withJXLSupport ? false,
}:

let
pyproject = (lib.importTOML ../pyproject.toml).project;

pillow-jxl-plugin = buildPythonPackage rec {
pname = "pillow_jxl_plugin";
version = "1.3.2";
pyproject = true;

src = fetchPypi {
inherit pname version;
hash = "sha256-efBoek8yUFR+ArhS55lm9F2XhkZ7/I3GsScQEe8U/2I=";
};

cargoDeps = rustPlatform.fetchCargoVendor {
inherit src;
hash = "sha256-vZHrwGfgo3fIIOY7p0vy4XIKiHoddPDdJggkBen+w/A=";
};

nativeBuildInputs = [
cmake
rustPlatform.cargoSetupHook
rustPlatform.maturinBuildHook
];

dontUseCmakeConfigure = true;

pythonImportsCheck = [ "pillow_jxl" ];

dependencies = [
packaging
pillow
];

meta = {
description = "Pillow plugin for JPEG-XL, using Rust for bindings.";
homepage = "https://github.com/Isotr0py/pillow-jpegxl-plugin";
license = lib.licenses.gpl3;
maintainers = with lib.maintainers; [ xarvex ];
platforms = lib.platforms.unix;
};
};

vtf2img = buildPythonPackage rec {
pname = "vtf2img";
version = "0.1.0";

src = fetchPypi {
inherit pname version;
hash = "sha256-YmWs8673d72wH4nTOXP4AFGs2grIETln4s1MD5PfE0A=";
};

pythonImportsCheck = [ "vtf2img" ];

dependencies = [ pillow ];

meta = {
description = "A Python library to convert Valve Texture Format (VTF) files to images.";
homepage = "https://github.com/julienc91/vtf2img";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ xarvex ];
mainProgram = "vtf2img";
platforms = lib.platforms.unix;
};
};
pyproject = (lib.importTOML ../../pyproject.toml).project;
in
buildPythonApplication {
pname = pyproject.name;
inherit (pyproject) version;
pyproject = true;

src = ../.;
src = ../../.;

nativeBuildInputs = [
pythonRelaxDepsHook
Expand Down
48 changes: 48 additions & 0 deletions nix/package/pillow-jxl-plugin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
buildPythonPackage,
cmake,
fetchPypi,
lib,
packaging,
pillow,
rustPlatform,
}:

buildPythonPackage rec {
pname = "pillow_jxl_plugin";
version = "1.3.2";
pyproject = true;

src = fetchPypi {
inherit pname version;
hash = "sha256-efBoek8yUFR+ArhS55lm9F2XhkZ7/I3GsScQEe8U/2I=";
};

cargoDeps = rustPlatform.fetchCargoVendor {
inherit src;
hash = "sha256-vZHrwGfgo3fIIOY7p0vy4XIKiHoddPDdJggkBen+w/A=";
};

nativeBuildInputs = [
cmake
rustPlatform.cargoSetupHook
rustPlatform.maturinBuildHook
];

dontUseCmakeConfigure = true;

pythonImportsCheck = [ "pillow_jxl" ];

dependencies = [
packaging
pillow
];

meta = {
description = "Pillow plugin for JPEG-XL, using Rust for bindings.";
homepage = "https://github.com/Isotr0py/pillow-jpegxl-plugin";
license = lib.licenses.gpl3;
maintainers = with lib.maintainers; [ xarvex ];
platforms = lib.platforms.unix;
};
}
29 changes: 29 additions & 0 deletions nix/package/vtf2img.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
buildPythonPackage,
fetchPypi,
lib,
pillow,
}:

buildPythonPackage rec {
pname = "vtf2img";
version = "0.1.0";

src = fetchPypi {
inherit pname version;
hash = "sha256-YmWs8673d72wH4nTOXP4AFGs2grIETln4s1MD5PfE0A=";
};

pythonImportsCheck = [ "vtf2img" ];

dependencies = [ pillow ];

meta = {
description = "A Python library to convert Valve Texture Format (VTF) files to images.";
homepage = "https://github.com/julienc91/vtf2img";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ xarvex ];
mainProgram = "vtf2img";
platforms = lib.platforms.unix;
};
}

0 comments on commit 031e85f

Please sign in to comment.