From 30013a61746405015bd84327b1a2407d73eae2d2 Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Sun, 20 Jun 2021 13:56:50 -0700 Subject: [PATCH] init: octave-kernel at 0.32.0 --- .../jupyter-kernels/octave/default.nix | 60 +++++++++++++++++++ .../editors/jupyter-kernels/octave/kernel.nix | 30 ++++++++++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 92 insertions(+) create mode 100644 pkgs/applications/editors/jupyter-kernels/octave/default.nix create mode 100644 pkgs/applications/editors/jupyter-kernels/octave/kernel.nix diff --git a/pkgs/applications/editors/jupyter-kernels/octave/default.nix b/pkgs/applications/editors/jupyter-kernels/octave/default.nix new file mode 100644 index 000000000000..9db38d144489 --- /dev/null +++ b/pkgs/applications/editors/jupyter-kernels/octave/default.nix @@ -0,0 +1,60 @@ +{ lib +, stdenv +, callPackage +, runCommand +, makeWrapper +, octave +, imagemagick +, python3 +}: + +# To test: +# $(nix-build -E 'with import {}; jupyter.override { definitions = { octave = octave-kernel.definition; }; }')/bin/jupyter-notebook + +let + kernel = callPackage ./kernel.nix { + python3Packages = python3.pkgs; + }; + +in + +rec { + launcher = runCommand "octave-kernel-launcher" { + inherit octave; + python = python3.withPackages (ps: [ ps.traitlets ps.jupyter_core ps.ipykernel ps.metakernel kernel ]); + buildInputs = [ makeWrapper ]; + } '' + mkdir -p $out/bin + + makeWrapper $python/bin/python $out/bin/octave-kernel \ + --add-flags "-m octave_kernel" \ + --suffix PATH : $octave/bin + ''; + + sizedLogo = size: stdenv.mkDerivation { + name = ''octave-logo-${octave.version}-${size}x${size}.png''; + + src = octave.src; + + buildInputs = [ imagemagick ]; + + dontConfigure = true; + dontInstall = true; + + buildPhase = '' + convert ./libgui/src/icons/logo.png -resize ${size}x${size} $out + ''; + }; + + definition = { + displayName = "Octave"; + argv = [ + "${launcher}/bin/octave-kernel" + "-f" + "{connection_file}" + ]; + language = "octave"; + logo32 = sizedLogo "32"; + logo64 = sizedLogo "64"; + }; +} diff --git a/pkgs/applications/editors/jupyter-kernels/octave/kernel.nix b/pkgs/applications/editors/jupyter-kernels/octave/kernel.nix new file mode 100644 index 000000000000..9ebb4257784b --- /dev/null +++ b/pkgs/applications/editors/jupyter-kernels/octave/kernel.nix @@ -0,0 +1,30 @@ +{ lib, octave, python3Packages }: + +with python3Packages; + +buildPythonPackage rec { + pname = "octave-kernel"; + version = "0.32.0"; + + src = fetchPypi { + pname = "octave_kernel"; + inherit version; + sha256 = "0dfbxfcf3bz4jswnpkibnjwlkgy0y4j563nrhaqxv3nfa65bksif"; + }; + + propagatedBuildInputs = [ metakernel ipykernel ]; + + # Tests require jupyter_kernel_test to run, but it hasn't seen a + # release since 2017 and seems slightly abandoned. + # Doing fetchPypi on it doesn't work, even though it exists here: + # https://pypi.org/project/jupyter_kernel_test/. + doCheck = false; + + meta = with lib; { + description = "A Jupyter kernel for Octave."; + homepage = "https://github.com/Calysto/octave_kernel"; + license = licenses.bsd3; + maintainers = with maintainers; [ thomasjm ]; + platforms = platforms.all; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d5b4c1104e97..f6e75bc37fd0 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12095,6 +12095,8 @@ in overridePlatforms = ["x86_64-linux" "x86_64-darwin"]; }; + octave-kernel = callPackage ../applications/editors/jupyter-kernels/octave { }; + octavePackages = recurseIntoAttrs octave.pkgs; ocropus = callPackage ../applications/misc/ocropus { };