我想了解nix是如何工作的。爲了這個目的,我嘗試創建一個運行jupyter筆記本的簡單環境。如何使用default.nix文件運行`nix-shell`?
當我運行命令:
nix-shell -p "\
with import <nixpkgs> {};\
python35.withPackages (ps: [\
ps.numpy\
ps.toolz\
ps.jupyter\
])\
"
我得到了我的預期 - 在與Python的環境中路徑訪問的外殼和安裝列出的所有包,以及所有預期的命令:
[nix-shell:~/dev/hurricanes]$ which python
/nix/store/5scsbf8z3jnz8ardch86mhr8xcyc8jr2-python3-3.5.3-env/bin/python
[nix-shell:~/dev/hurricanes]$ which jupyter
/nix/store/5scsbf8z3jnz8ardch86mhr8xcyc8jr2-python3-3.5.3-env/bin/jupyter
[nix-shell:~/dev/hurricanes]$ jupyter notebook
[I 22:12:26.191 NotebookApp] Serving notebooks from local directory: /home/calsaverini/dev/hurricanes
[I 22:12:26.191 NotebookApp] 0 active kernels
[I 22:12:26.191 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=7424791f6788af34f4c2616490b84f0d18353a4d4e60b2b5
所以,我創建了一個新的文件夾與單個文件default.nix
具有以下內容:
with import <nixpkgs> {};
python35.withPackages (ps: [
ps.numpy
ps.toolz
ps.jupyter
])
當我在此文件夾中運行nix-shell
雖然,好像是安裝一切,但PATH
s的未設置:
[nix-shell:~/dev/hurricanes]$ which python
/usr/bin/python
[nix-shell:~/dev/hurricanes]$ which jupyter
[nix-shell:~/dev/hurricanes]$ jupyter
The program 'jupyter' is currently not installed. You can install it by typing:
sudo apt install jupyter-core
通過什麼我read here我期待這兩種情況是等價的。我做錯了什麼?
感謝您的澄清。事實上,這是導致我錯誤地認爲我擁有正確配置的部分。謝謝。 –