aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-07-06 21:06:27 +0200
committerAdrian Kummerlaender2019-07-06 21:06:27 +0200
commit6bae7fc0d898a62607344ae9b25242d4a1ef1413 (patch)
treeab9dd4483d41340c3db907ae7cf405a4c2b621c8
parente8689b8ca91d2d27378b85d11db64c6acfae6916 (diff)
downloadnixos_home-6bae7fc0d898a62607344ae9b25242d4a1ef1413.tar
nixos_home-6bae7fc0d898a62607344ae9b25242d4a1ef1413.tar.gz
nixos_home-6bae7fc0d898a62607344ae9b25242d4a1ef1413.tar.bz2
nixos_home-6bae7fc0d898a62607344ae9b25242d4a1ef1413.tar.lz
nixos_home-6bae7fc0d898a62607344ae9b25242d4a1ef1413.tar.xz
nixos_home-6bae7fc0d898a62607344ae9b25242d4a1ef1413.tar.zst
nixos_home-6bae7fc0d898a62607344ae9b25242d4a1ef1413.zip
Add Python console task type
-rw-r--r--custom.nix2
-rw-r--r--module/tasker.nix4
-rw-r--r--tasks/default.nix40
3 files changed, 39 insertions, 7 deletions
diff --git a/custom.nix b/custom.nix
index 61de1aa..ca0d53c 100644
--- a/custom.nix
+++ b/custom.nix
@@ -21,7 +21,7 @@ in {
default = "~/";
};
type = mkOption {
- type = types.enum [ "launcher" "terminal" "local-shell" "local-editor" "environment" ];
+ type = types.enum [ "launcher" "terminal" "local-shell" "local-editor" "environment" "python-console" ];
default = "launcher";
};
command = mkOption {
diff --git a/module/tasker.nix b/module/tasker.nix
index 4f2e0fe..032027b 100644
--- a/module/tasker.nix
+++ b/module/tasker.nix
@@ -27,6 +27,10 @@ let
environment = launchTerminalInDirectory conf.directory ''
nix-shell ${builtins.unsafeDiscardStringContext conf.environment.drvPath} --command fish
'';
+
+ python-console = launchCommandInDirectory "~/" ''
+ nix-shell ${builtins.unsafeDiscardStringContext conf.environment.drvPath} --command jupyter-qtconsole
+ '';
};
};
diff --git a/tasks/default.nix b/tasks/default.nix
index dc77baf..3521443 100644
--- a/tasks/default.nix
+++ b/tasks/default.nix
@@ -9,6 +9,24 @@ let
'';
};
+ 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}
+ '';
+ };
+
in {
custom.tasks = {
bsc_edit = {
@@ -65,13 +83,23 @@ in {
]);
};
- sympy_shell = {
- description = "Python shell with SymPy";
+ pymath_shell = {
+ description = "Python console for mathematics";
directory = "~/";
- type = "environment";
- environment = with pkgs; mkShellDerivation "python-env" [
- (pkgs.python3.withPackages (python-packages: with python-packages; [ sympy ]))
- ];
+ 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()
+ '';
};
};
}