Created
May 19, 2016 10:33
-
-
Save Nekroze/775eccdc1a17d8d6cd4a4ab0e8da6581 to your computer and use it in GitHub Desktop.
Jupyer Nixos Module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, lib, pkgs, ... }: | |
with lib; | |
let | |
cfg = config.services.jupyter; | |
in | |
{ | |
###### interface | |
options = { | |
services.jupyter = { | |
enable = mkOption { | |
type = types.bool; | |
default = false; | |
description = '' | |
Whether to enable the jupyter notebook server. | |
''; | |
}; | |
localUser = mkOption { | |
description = '' | |
Local user to execute as. | |
''; | |
}; | |
}; | |
}; | |
###### implementation | |
config = mkIf cfg.enable { | |
environment.systemPackages = with pkgs.python34Packages; [ | |
jupyter_core | |
jupyter_client | |
notebook | |
ipywidgets | |
]; | |
systemd.services.jupyter = { | |
description = '' | |
Jupyter notebook web server service | |
''; | |
wantedBy = [ "multi-user.target" ]; | |
serviceConfig = with cfg; { | |
User = cfg.localUser; | |
RestartSec = 10; | |
Restart = "on-failure"; | |
}; | |
script = with pkgs.python34Packages; '' | |
export PYTHONPATH=$PYTHONPATH:${ipywidgets}/lib/python3.4/site-packages | |
/run/current-system/sw/bin/jupyter-notebook | |
''; | |
}; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This would be imported by /etc/nixos/configuration.nix | |
{ config, ... }: | |
{ | |
import [ ./jupyter.nix ]; | |
services.jupyter = { | |
enable = true; | |
localUser = "nekroze"; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment