tsuki/jupyter: set up tmpdirs for notebooks
This commit is contained in:
parent
1ea23dc42e
commit
ce5c3666b9
|
@ -16,7 +16,7 @@ in {
|
||||||
readFile = f: "open('${f}', 'r', encoding='utf8').read().strip()";
|
readFile = f: "open('${f}', 'r', encoding='utf8').read().strip()";
|
||||||
in
|
in
|
||||||
readFile config.sops.secrets."jupyter/password".path;
|
readFile config.sops.secrets."jupyter/password".path;
|
||||||
|
|
||||||
kernels = {
|
kernels = {
|
||||||
pythonDS = let
|
pythonDS = let
|
||||||
env = (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [
|
env = (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [
|
||||||
|
@ -40,6 +40,19 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.tmpfiles.settings."10-jupyter" = {
|
||||||
|
"/var/lib/jupyter/notebooks".d = {
|
||||||
|
mode = "0700";
|
||||||
|
user = "jupyter";
|
||||||
|
group = "jupyter";
|
||||||
|
};
|
||||||
|
"/var/lib/jupyter/data".d = {
|
||||||
|
mode = "0700";
|
||||||
|
user = "jupyter";
|
||||||
|
group = "jupyter";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
systemd.services.jupyter = let
|
systemd.services.jupyter = let
|
||||||
notebookConfig = pkgs.writeText "jupyter_config.py" ''
|
notebookConfig = pkgs.writeText "jupyter_config.py" ''
|
||||||
c.NotebookApp.notebook_dir = 'notebooks'
|
c.NotebookApp.notebook_dir = 'notebooks'
|
||||||
|
@ -57,8 +70,8 @@ in {
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
environment = {
|
environment = {
|
||||||
JUPYTER_DATA_DIR = "$STATE_DIRECTORY/data";
|
JUPYTER_DATA_DIR = "%S/${config.systemd.services.jupyter.serviceConfig.StateDirectory}/data";
|
||||||
JUPYTER_RUNTIME_DIR = "$RUNTIME_DIRECTORY";
|
JUPYTER_RUNTIME_DIR = "%t/${config.systemd.services.jupyter.serviceConfig.RuntimeDirectory}";
|
||||||
};
|
};
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
RuntimeDirectory = "jupyter";
|
RuntimeDirectory = "jupyter";
|
||||||
|
@ -86,9 +99,6 @@ in {
|
||||||
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];
|
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];
|
||||||
SystemCallArchitectures = "native";
|
SystemCallArchitectures = "native";
|
||||||
|
|
||||||
ExecStartPre = ''
|
|
||||||
${pkgs.coreutils}/bin/mkdir -p /var/lib/jupyter/{notebooks,data}
|
|
||||||
'';
|
|
||||||
ExecStart = lib.mkForce ''
|
ExecStart = lib.mkForce ''
|
||||||
${cfg.package}/bin/${cfg.command} --NotebookApp.config_file=${notebookConfig}
|
${cfg.package}/bin/${cfg.command} --NotebookApp.config_file=${notebookConfig}
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in New Issue