|
|
Line 19: |
Line 19: |
|
| |
|
| Then run <code>nix-shell</code> to use the shell. | | Then run <code>nix-shell</code> to use the shell. |
|
| |
| == Development shell ==
| |
|
| |
| When you want to install Python only for a specific project you can use a [[Development environment with nix-shell|Development shell]].
| |
|
| |
| If you only need Python you can put the following in your <code>shell.nix</code>:
| |
|
| |
| <syntaxHighlight lang="nix">
| |
| # shell.nix
| |
| { pkgs ? import <nixpkgs> {} }:
| |
| let
| |
| my-python-packages = ps: with ps; [
| |
| pandas
| |
| requests
| |
| # other python packages
| |
| ];
| |
| my-python = pkgs.python3.withPackages my-python-packages;
| |
| in my-python.env
| |
| </syntaxHighlight>
| |
|
| |
| However, if you already have a <code>shell.nix</code> with other packages, you can add python like this:
| |
|
| |
| <syntaxHighlight lang="nix">
| |
| # ...
| |
| pkgs.mkShell {
| |
| packages = [
| |
| # ...
| |
| (python3.withPackages my-python-packages) # we have defined this in the installation section
| |
| ];
| |
| }
| |
| </syntaxHighlight>
| |
|
| |
|
| == Using alternative packages == | | == Using alternative packages == |