Skip to content

Commit

Permalink
add: nix-kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
GTrunSec committed May 27, 2020
1 parent dc8bb19 commit 534f07d
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions kernels/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
iRWith = callPackage ./irkernel;
iPythonWith = callPackage ./ipython;
iRubyWith = callPackage ./iruby;
iNixKernel = callPackage ./inix;
cKernelWith = callPackage ./ckernel;
ansibleKernel = callPackage ./ansible-kernel;
xeusCling = callPackage ./xeus-cling;
Expand Down
12 changes: 12 additions & 0 deletions kernels/inix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# JupyterWith Nix

The Nix kernel can be used as follows:

```nix
{
iNix = jupyter.kernels.iNixKernel {
# Identifier that will appear on the Jupyter interface.
name = "Nix-kernel";
};
}
```
48 changes: 48 additions & 0 deletions kernels/inix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{ python3
, stdenv
, name ? "nixpkgs"
, callPackage
, nix
, writeScriptBin
}:

let
nix-kernel = callPackage ./nix-kernel {};
kernelEnv = (python3.withPackages (p: (with p; [
nix-kernel
])
));

kernelFile = {
display_name = "Nix - ${name}";
language = "Nix";
argv = [
"${nix-bin}/bin/nix-kernel"
"-f"
"{connection_file}"
];
logo64 = "logo-64x64.png";
};

nix-bin = writeScriptBin "nix-kernel" ''
#! ${stdenv.shell}
PATH=${nix}/bin/:${kernelEnv}/bin:$PATH
exec python -m nix-kernel $@
'';

iNixKernel = stdenv.mkDerivation {
name = "inix-${name}";
src = ./nix.png;
phases = "installPhase";
installPhase = ''
mkdir -p $out/kernels/inix_${name}
cp $src $out/kernels/inix_${name}/logo-64x64.png
echo '${builtins.toJSON kernelFile}' > $out/kernels/inix_${name}/kernel.json
'';
};
in
{
spec = iNixKernel;
runtimePackages = [
];
}
22 changes: 22 additions & 0 deletions kernels/inix/nix-kernel/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ stdenv
, python3Packages
, python3
, pkgs
, fetchFromGitHub
}:
with python3.pkgs;
python3Packages.buildPythonPackage rec {
pname = "nix-kernel";
version = "0.1";
src = fetchFromGitHub {
owner = "GTrunSec";
repo = "nix-kernel";
rev = "dfa42d0812d508ded99f690ee1a83281d900a3ec";
sha256 = "1lf4rbbxjmq9h6g3wrdzx3v3dn1bndfmiybxiy0sjavgb6lzc8kq";
};
doCheck = false;
preBuild = ''
export HOME=$(pwd)
'';
propagatedBuildInputs = with python3Packages; [ pexpect notebook ] ;
}
Binary file added kernels/inix/nix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 534f07d

Please sign in to comment.