Skip to content

Instantly share code, notes, and snippets.

@infinisil
Forked from Nekroze/jupyter.nix
Last active September 14, 2017 00:36

Revisions

  1. infinisil revised this gist Sep 14, 2017. 1 changed file with 1 addition and 4 deletions.
    5 changes: 1 addition & 4 deletions jupyter.nix
    Original file line number Diff line number Diff line change
    @@ -47,13 +47,10 @@ in

    serviceConfig = with cfg; {
    User = cfg.localUser;
    ExecStart = "${pkgs.python34Packages.notebook}/bin/jupyter-notebook";
    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
    '';
    };
    };
    }
  2. @Nekroze Nekroze created this gist May 19, 2016.
    59 changes: 59 additions & 0 deletions jupyter.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    { 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
    '';
    };
    };
    }
    10 changes: 10 additions & 0 deletions services.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # This would be imported by /etc/nixos/configuration.nix
    { config, ... }:

    {
    import [ ./jupyter.nix ];
    services.jupyter = {
    enable = true;
    localUser = "nekroze";
    };
    }