about summary refs log tree commit diff
path: root/pkgs/applications/editors/jupyter-kernels/xeus-cling/default.nix
blob: 069e70b4253f2f997f6815424e91bd23f4e56d44 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{ callPackage
, clangStdenv
, cling
, fetchurl
, lib
, llvmPackages_9
, makeWrapper
, runCommand
, stdenv
}:

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

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

let
  xeus-cling = callPackage ./xeus-cling.nix {};

  mkDefinition = std:
    let
      versionSuffix =
        if std == "c++11" then " 11"
        else if std == "c++14" then " 14"
        else if std == "c++17" then " 17"
        else if std == "c++17" then " 17"
        else if std == "c++2a" then " 2a"
        else throw "Unexpected C++ std for cling: ${std}";
    in
      {
        displayName = "C++" + versionSuffix;
        argv = [
          "${xeus-cling}/bin/xcpp"
        ]
        ++ cling.flags
        ++ [
          "-resource-dir" "${cling.unwrapped}"
          "-L" "${cling.unwrapped}/lib"
          "-l" "${cling.unwrapped}/lib/cling.so"
          "-std=${std}"
          # "-v"
          "-f" "{connection_file}"
        ];
        language = "cpp";
        logo32 = fetchurl {
          url = "https://upload.wikimedia.org/wikipedia/commons/thumb/1/18/ISO_C%2B%2B_Logo.svg/32px-ISO_C%2B%2B_Logo.svg.png";
          hash = "sha256-cr0TB8/j2mkcFhfCkz9F7ZANOuTlWA2OcWtDcXyOjHw=";
        };
        logo64 = fetchurl {
          url = "https://upload.wikimedia.org/wikipedia/commons/thumb/1/18/ISO_C%2B%2B_Logo.svg/64px-ISO_C%2B%2B_Logo.svg.png";
          hash = "sha256-nZtJ4bR7GmQttvqEJC9KejOxphrjjxT36L9yOIITFLk=";
        };
      };

in

{
  cpp11-kernel = mkDefinition "c++11";
  cpp14-kernel = mkDefinition "c++14";
  cpp17-kernel = mkDefinition "c++17";
  cpp2a-kernel = mkDefinition "c++2a";
}