Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coq_kernel: init at 1.6.0 #171202

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions pkgs/applications/editors/jupyter-kernels/coq/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{ lib
, stdenv
, callPackage
, runCommand
, makeWrapper
, coq
, imagemagick
, python3
}:
teto marked this conversation as resolved.
Show resolved Hide resolved

# Jupyter console:
# nix run --impure --expr 'with import <nixpkgs> {}; jupyter-console.withSingleKernel coq-kernel.definition'

teto marked this conversation as resolved.
Show resolved Hide resolved
# Jupyter console with packages:
# nix run --impure --expr 'with import <nixpkgs> {}; jupyter-console.withSingleKernel (coq-kernel.definitionWithPackages [coqPackages.bignums])'

# Jupyter notebook:
# nix run --impure --expr 'with import <nixpkgs> {}; jupyter.override { definitions.coq = coq-kernel.definition; }'

let
python = python3.withPackages (ps: [ ps.traitlets ps.jupyter_core ps.ipykernel (callPackage ./kernel.nix {}) ]);

logos = runCommand "coq-logos" { buildInputs = [ imagemagick ]; } ''
mkdir -p $out
convert ${coq.src}/ide/coqide/coq.png -resize 32x32 $out/logo-32x32.png
convert ${coq.src}/ide/coqide/coq.png -resize 64x64 $out/logo-64x64.png
'';

in

rec {
launcher = runCommand "coq-kernel-launcher" {
nativeBuildInputs = [ makeWrapper ];
} ''
mkdir -p $out/bin

makeWrapper ${python.interpreter} $out/bin/coq-kernel \
--add-flags "-m coq_jupyter" \
--suffix PATH : ${coq}/bin
'';

definition = definitionWithPackages [];

definitionWithPackages = packages: {
displayName = "Coq " + coq.version;
argv = [
"${launcher}/bin/coq-kernel"
"-f"
"{connection_file}"
];
language = "coq";
logo32 = "${logos}/logo-32x32.png";
logo64 = "${logos}/logo-64x64.png";
env = {
COQPATH = lib.concatStringsSep ":" (map (x: "${x}/lib/coq/${coq.coq-version}/user-contrib/") packages);
};
};
}
30 changes: 30 additions & 0 deletions pkgs/applications/editors/jupyter-kernels/coq/kernel.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{ lib
, fetchFromGitHub
, python3
, coq
}:

python3.pkgs.buildPythonPackage rec {
pname = "coq-jupyter";
version = "1.6.0";

src = fetchFromGitHub {
owner = "EugeneLoy";
repo = "coq_jupyter";
rev = "v${version}";
sha256 = "sha256-+Pp51cxeqjg5MW4CEccNWVjNcY9iyFNATIEage9RWJ0=";
};

propagatedBuildInputs = (with python3.pkgs; [ ipykernel future ]) ++ [ coq ];

nativeBuildInputs = [ coq ];

doCheck = false;

meta = with lib; {
homepage = "https://github.com/EugeneLoy/coq_jupyter";
description = "Jupyter kernel for Coq";
license = licenses.asl20;
maintainers = with maintainers; [ thomasjm ];
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39494,6 +39494,8 @@ with pkgs;

coq2html = callPackage ../tools/typesetting/coq2html { };

coq-kernel = callPackage ../applications/editors/jupyter-kernels/coq { };

cryptoverif = callPackage ../applications/science/logic/cryptoverif { };

crypto-org-wallet = callPackage ../applications/blockchains/crypto-org-wallet { };
Expand Down