How can I define a Nix environment that defaults to Python 3.5
<p>I have defined a the following environment in <code>default.nix</code>:</p>

<pre><code>with import &lt;nixpkgs&gt; {};
stdenv.mkDerivation rec {
  name = "env";
  env = buildEnv { name = name; paths = buildInputs; };
  buildInputs = [
    python35
    python35Packages.pyyaml
  ];
}
</code></pre>

<p>If I run <code>nix-shell</code>, <code>python</code> will still be the system python at <code>/usr/bin/python</code> (running on Ubuntu) while <code>python3</code> is a symlink to the Python 3.5 binary installed by Nix. Is there a way to define the environment so that <code>python</code> is pointing to the Nix Python 3.5?</p>

<p>One simple solution could be to add a shell hook to your environment, to define an alias from <code>python</code> to <code>python3</code>. This alias will be active only when you run <code>nix-shell</code>:</p>

<pre><code>with import &lt;nixpkgs&gt; {};
stdenv.mkDerivation rec {
  name = "env";
  env = buildEnv { name = name; paths = buildInputs; };
  buildInputs = [
    python35
    python35Packages.pyyaml
  ];
  # Customizable development shell setup
  shellHook = ''
    alias python='python3'
  '';
}
</code></pre>

python nix