dream2nix icon indicating copy to clipboard operation
dream2nix copied to clipboard

Separate the pyEnv and devShell parts of pip module into their own module(s)

Open zackattackz opened this issue 1 year ago • 0 comments

For my requirements, I need to be able to build a python interpreter with access to the specified pip requirements AND access to specific system packages. I've found that I can accomplish this by using dream2nix's pip module, with something like this:

packages.${system}.default = pkgs.writeShellApplication {
  name = "python";
  runtimeInputs = [ odoo16_0.pyEnv pkgs.wkhtmltopdf-bin <more packages here> ];
  text = ''
    python "$@"
  '';
}; 

Where odoo16_0 is just an eval'ed dream2nix pip module.

I am just using the pyEnv attribute of the pip module, and I don't care to actually expose the rest of the parts of the eval'ed pip module. I only care about the resulting pyEnv/devShell.

My mkDerivation inside the module is also pretty much empty, like so:

mkDerivation = {
  src = ./.
};

but src doesn't actually contain any of the source code for the project, because I don't care for building the source of the project as a nix derivation. Again, I only care about creating the pyEnv.

So, I believe that, similarly to how nodejs-node-xxx dream2nix modules are cleanly separated between the concerns of building only nodeModules, or a whole package from source - the pip module should have pyEnv (and with it, devShell too) separated into it's own module (pip-pyEnv, or something of the sort). Then, pip module can import that module and effectively wouldn't change. But those who only need access to the pyEnv can do so by importing only the pip-pyEnv module.

zackattackz avatar Feb 14 '24 13:02 zackattackz