Here’s an example default.nix
that you can put in your project and use nix-shell
.
{ nixpkgs ? (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/ba02fd0434ed92b7335f17c97af689b9db1413e0.tar.gz";
sha256 = "1pjx78qb3k4cjkbwiw9v0wd545h48fj4criazijwds53l0q4dzn1";
})
, src ? builtins.fetchGit ./.
}:
let
pkgs = import nixpkgs { };
python38Optimized = pkgs.python38.override {
enableOptimizations = true;
reproducibleBuild = false;
self = python38Optimized;
};
pyPkgs = python38Optimized.pkgs;
in
python38Optimized.pkgs.buildPythonPackage rec {
name = "python-example";
inherit src;
propagatedBuildInputs = with pyPkgs; [
numpy
];
nativeBuildInputs = with pyPkgs; pkgs.lib.optionals (pkgs.lib.inNixShell) [
ipython
];
}
Notes:
- The expression requires the directory to be versioned with
git
- Fetch a hot beverage while it compiles Python 3.8 for you on the first launch