From efb6657ea264efce513d95d59b1678c579158ec1 Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Mon, 15 Jan 2024 15:55:17 +0000 Subject: [PATCH] packages,shells: add axidraw --- flake.lock | 6 ++-- flake.nix | 40 ++++++++++++++++++--- packages/axidraw/inkscape.nix | 32 +++++++++++++++++ packages/axidraw/modules.nix | 65 +++++++++++++++++++++++++++++++++++ shells/axidraw/default.nix | 10 ++++++ 5 files changed, 146 insertions(+), 7 deletions(-) create mode 100644 packages/axidraw/inkscape.nix create mode 100644 packages/axidraw/modules.nix create mode 100644 shells/axidraw/default.nix diff --git a/flake.lock b/flake.lock index a70d186..310db92 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1702900294, - "narHash": "sha256-pt7sSoJYNw3n8YtXw0Z/Nnr6/PfY2YrjDvqboErXnRM=", + "lastModified": 1705204527, + "narHash": "sha256-WVz9WdaFBhAwO/7A+HlW8HPJ4VQ8QnpCD1WZAcAPneo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "886c9aee6ca9324e127f9c2c4e6f68c2641c8256", + "rev": "dd5621df6dcb90122b50da5ec31c411a0de3e538", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index b978953..f6af43e 100644 --- a/flake.nix +++ b/flake.nix @@ -13,18 +13,50 @@ inherit system; overlays = [ self.overlays.default ]; }; + inherit (pkgs) lib; + names = builtins.attrNames (self.overlays.default pkgs pkgs); in { - devShells = { zephyr = pkgs.callPackage ./shells/zephyr { }; }; + devShells = { + axidraw = pkgs.callPackage ./shells/axidraw { }; + zephyr = pkgs.callPackage ./shells/zephyr { }; + }; formatter = pkgs.nixfmt; - packages = self.overlays.default pkgs pkgs; + packages = builtins.listToAttrs (lib.concatMap (name: + let pkg = pkgs.${name}; + in lib.optional (builtins.typeOf pkg == "set") { + inherit name; + value = if lib.isDerivation pkg then + pkg + else + pkg // { + type = "derivation"; + name = "dummy-attrset"; + }; + }) names); }) // { overlays.default = final: prev: { - jlink = final.callPackage ./packages/jlink { }; ipsw = final.callPackage ./packages/ipsw { }; + jlink = final.callPackage ./packages/jlink { }; + zephyrPackages = final.callPackage ./packages/zephyr { }; + + inherit (final.python3.pkgs) axicli; + + inkscape-extensions = prev.inkscape-extensions // { + axidraw = final.callPackage ./packages/axidraw/inkscape.nix { }; + }; + kernelPatches = prev.kernelPatches // final.callPackage ./packages/kernelPatches { }; - zephyrPackages = final.callPackage ./packages/zephyr { }; + + pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ + (pythonFinal: pythonPrev: { + inherit (final.callPackage ./packages/axidraw/modules.nix { + inherit pythonFinal pythonPrev; + }) + ink-extensions plotink axidrawinternal axicli; + }) + ]; }; }; } diff --git a/packages/axidraw/inkscape.nix b/packages/axidraw/inkscape.nix new file mode 100644 index 0000000..6252bd7 --- /dev/null +++ b/packages/axidraw/inkscape.nix @@ -0,0 +1,32 @@ +{ stdenv, lib, fetchzip, autoPatchelfHook }: + +stdenv.mkDerivation rec { + pname = "axidraw-inkscape"; + version = "394"; + + src = fetchzip { + url = + "https://cdn.evilmadscientist.com/dl/ad/public/${version}/AxiDraw_${version}_LinX86.zip"; + hash = "sha256-LoNi7mR30spELnEYikRuYFvlgUWP3w8KRbQ6Ug108vU="; + }; + + nativeBuildInputs = [ autoPatchelfHook ]; + + dontBuild = true; + + installPhase = '' + runHook preInstall + mkdir -p "$out/share/inkscape/extensions" + cp -rt "$out/share/inkscape/extensions" *.py *.inx axidraw_deps build_deps svg_fonts + runHook postInstall + ''; + + meta = with lib; { + description = "Inkscape extension for managing axidraw"; + homepage = + "https://wiki.evilmadscientist.com/Axidraw_Software_Installation"; + license = licenses.gpl2Plus; + maintainers = with maintainers; [ artemist ]; + platforms = [ "x86_64-linux" ]; + }; +} diff --git a/packages/axidraw/modules.nix b/packages/axidraw/modules.nix new file mode 100644 index 0000000..48dc401 --- /dev/null +++ b/packages/axidraw/modules.nix @@ -0,0 +1,65 @@ +{ pythonFinal, pythonPrev, fetchPypi, fetchzip }: +let + inherit (pythonFinal) buildPythonPackage; + + axicliVersion = "3.9.0"; + axicliVer = builtins.replaceStrings [ "." ] [ "" ] axicliVersion; + axicliSrc = fetchzip { + url = + "https://github.com/evil-mad/axidraw/releases/download/v${axicliVersion}/AxiDraw_API_${axicliVer}.zip"; + hash = "sha256-RPh00jiiH1RqqKZ10ylFP1J+iBYl5VOmZ8g0vFH8Ibg="; + }; +in { + ink-extensions = buildPythonPackage rec { + pname = "ink_extensions"; + version = "1.3.2"; + src = fetchPypi { + inherit pname version; + hash = "sha256-9dPmoLBhIoJGBaQwOtGMZnOS9mGGel13dQXkaJdexyc="; + }; + propagatedBuildInputs = with pythonFinal; [ lxml ]; + }; + + plotink = buildPythonPackage rec { + pname = "plotink"; + version = "1.8.0"; + src = fetchPypi { + inherit pname version; + hash = "sha256-YxSASXBNXqRyGp7x6jlTU0UYJHJkiKdlEzfDMzUtKXk="; + }; + doCheck = false; + propagatedBuildInputs = with pythonFinal; [ ink-extensions pyserial ]; + }; + + axidrawinternal = buildPythonPackage { + pname = "axidrawinternal"; + version = axicliVersion; + format = "wheel"; + src = + "${axicliSrc}/prebuilt_dependencies/axidrawinternal-${axicliVersion}-py2.py3-none-any.whl"; + propagatedBuildInputs = with pythonFinal; [ + ink-extensions + requests + packaging + plotink + pyclipper + tqdm + ]; + }; + + axicli = buildPythonPackage { + pname = "axicli"; + version = axicliVersion; + format = "setuptools"; + src = axicliSrc; + doCheck = false; + propagatedBuildInputs = with pythonFinal; [ + ink-extensions + lxml + plotink + pyserial + requests + axidrawinternal + ]; + }; +} diff --git a/shells/axidraw/default.nix b/shells/axidraw/default.nix new file mode 100644 index 0000000..087bbaa --- /dev/null +++ b/shells/axidraw/default.nix @@ -0,0 +1,10 @@ +{ lib, mkShell, python3, inkscape-with-extensions, inkscape-extensions }: +mkShell { + packages = [ + (inkscape-with-extensions.override { + inkscapeExtensions = [ inkscape-extensions.axidraw ]; + }) + python3 + ] ++ (with python3.pkgs; [ ipython requests axicli ]); + +}