Skip to content

Instantly share code, notes, and snippets.

@Nekroze
Created May 19, 2016 10:33
Show Gist options
  • Save Nekroze/775eccdc1a17d8d6cd4a4ab0e8da6581 to your computer and use it in GitHub Desktop.
Save Nekroze/775eccdc1a17d8d6cd4a4ab0e8da6581 to your computer and use it in GitHub Desktop.
Jupyer Nixos Module
{ 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 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