Add test and support for binder sub-directory

pull/448/head
Tim Head 2018-11-08 23:32:20 +01:00
rodzic 046b744785
commit d427fdfd52
7 zmienionych plików z 53 dodań i 14 usunięć

Wyświetl plik

@ -57,8 +57,8 @@ class NixBuildPack(BaseImage):
('${NB_USER}', """
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs && \
nix-channel --update && \
nix-shell default.nix
""")
nix-shell {}
""".format(self.binder_path('default.nix')))
]
def get_start_script(self):

Wyświetl plik

@ -8,20 +8,25 @@ _term() {
trap _term SIGTERM
echo 'command:' "$@"
# a script in the binder sub-directory take precedence
if [ -f ./binder/start ]; then
chmod u+x ./binder/start
nix-shell default.nix --command "./binder/start $@" &
elif [ -f ./start ]; then
chmod u+x ./start
nix-shell default.nix --command "./start $@" &
# if there is a binder/ sub-directory it takes precedence
# files outside it are ignored
if [ -e ./binder ]; then
nixpath="./binder/default.nix";
if [ -f ./binder/start ]; then
chmod u+x ./binder/start
nix-shell $nixpath --command "./binder/start $*" &
else
nix-shell $nixpath --command "$*" &
fi
else
nix-shell default.nix --command "$@" &
nixpath="./default.nix";
if [ -f ./start ]; then
chmod u+x ./start
nix-shell $nixpath --command "./start $*" &
else
nix-shell $nixpath --command "$*" &
fi
fi
PID=$!
echo 'waiting'
wait "$PID"

Wyświetl plik

@ -1,4 +1,13 @@
<<<<<<< HEAD
default.nix in a binder/ directory
----------------------------------
Check we find and use `default.nix` when it is in a `binder/` sub-directory.
=======
Nix environment - default.nix
-----------------------------
You can install a nix shell environment using the traditional default.nix.
Documentation on the syntax and typical setup of a ``nix-shell`` environment can be found `here <https://nixos.org/nix/manual/#sec-nix-shell>`_.
>>>>>>> 983b7f5... Add test and support for binder sub-directory

Wyświetl plik

@ -0,0 +1,20 @@
let
# Pinning nixpkgs to specific release
# To get sha256 use "nix-prefetch-git <url> --rev <commit>"
commitRev="5574b6a152b1b3ae5f93ba37c4ffd1981f62bf5a";
nixpkgs = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${commitRev}.tar.gz";
sha256 = "1pqdddp4aiz726c7qs1dwyfzixi14shp0mbzi1jhapl9hrajfsjg";
};
pkgs = import nixpkgs { config = { allowUnfree = true; }; };
in
pkgs.mkShell {
buildInputs = with pkgs; [
python36Packages.numpy
python36Packages.notebook
];
shellHook = ''
export NIX_PATH="nixpkgs=${nixpkgs}:."
'';
}

Wyświetl plik

@ -0,0 +1,3 @@
#!/usr/bin/env python
import numpy

Wyświetl plik

@ -11,6 +11,7 @@ in
pkgs.mkShell {
buildInputs = with pkgs; [
python36Packages.numpy
python36Packages.notebook
];
shellHook = ''

Wyświetl plik

@ -11,6 +11,7 @@ in
pkgs.mkShell {
buildInputs = with pkgs; [
python36Packages.numpy
python36Packages.notebook
];
shellHook = ''