aboutsummaryrefslogtreecommitdiff
path: root/tasks/default.nix
blob: 1ccda338563708a259b3637a59bd18000639628c (plain)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
{ pkgs, ... }:

let
  mkShellDerivation = n: ps: pkgs.stdenvNoCC.mkDerivation rec {
    name = n;
    buildInputs = ps;
    shellHook = ''
      export NIX_SHELL_NAME="${name}"
    '';
  };

  mkPythonShellDerivation = n: ps: init: pkgs.stdenvNoCC.mkDerivation rec {
    name = n;
    buildInputs = [(pkgs.python3.withPackages (python-packages: with python-packages; ps ++ [
      jupyterlab
      qtconsole
    ]))];
    shellHook = let
      startup = pkgs.writeTextFile {
        name = "startup.py";
        text = init;
      };

    in ''
      export NIX_SHELL_NAME="${name}"
      export PYTHONSTARTUP=${startup}
    '';
  };

  jupyter = import (builtins.fetchGit {
    url = https://github.com/tweag/jupyterWith;
    rev = "";
  }) {};

  mkJupyterEnv = kernel: (jupyter.jupyterlabWith {
    kernels = [ kernel ];
  }).env;

in {
  custom.tasks = {
    bsc_edit = {
      description = "Grid refinement BSc thesis editor";
      directory = "~/university/documents/bachelor/arbeit";
      type = "local-editor";
    };

    bsc_shell = {
      description = "Grid refinement BSc thesis shell";
      directory = "~/university/documents/bachelor/arbeit";
      type = "local-shell";
    };

    bsc_view = {
      description = "Grid refinement BSc thesis PDF";
      directory = "~/university/documents/bachelor/arbeit";
      command = "evince build/main.pdf";
    };

    olb_edit = {
      description = "OpenLB editor";
      directory = "~/projects/contrib/openlb";
      type = "local-editor";
    };

    olb_shell = {
      description = "OpenLB shell";
      directory = "~/projects/contrib/openlb";
      type = "local-shell";
    };

    study_edit = {
      description = "University notes editor";
      directory = "~/university/note";
      type = "local-editor";
    };

    study_shell = {
      description = "University notes shell";
      directory = "~/university/note";
      type = "local-shell";
    };

    cpp_shell = {
      description = "Generic C++ shell environment";
      directory = "~/";
      type = "environment";
      environment = mkShellDerivation "cpp-env" (with pkgs; [
        cmake
        gcc8
        gdb cgdb
        universal-ctags
      ]);
    };

    pymath_shell = {
      description = "Python console for mathematics";
      directory = "~/";
      type = "python-console";
      environment = mkPythonShellDerivation "pymath-env" (with pkgs.python3Packages; [
        sympy
        numpy
        matplotlib
      ])
      ''
        import numpy as np
        import sympy
        import matplotlib
        import matplotlib.pyplot as plt

        sympy.init_session()
      '';
    };

    pymath_jupyter = {
      description = "Python @ Jupyter Lab";
      directory = "~/";
      type = "jupyter-lab";
      environment = mkJupyterEnv (
        jupyter.kernels.iPythonWith {
          name = "python";
          packages = p: with p; [
            numpy
            sympy
            matplotlib
          ];
        }
      );
    };
  };
}