Flake vs nixpkgs

I’m trying to use Nix to install a number of interrelated bits of software for my own use. Some of these I might want to contribute to nixpkgs, others probably not, in some cases it’s not yet clear.

If this were for exclusively for my personal use, I’d probably write a flake; if I were planning to contribute something to nixpkgs, I’d probably do it directly in my clone of nixpkgs.

Is there a clean way of organizing a flake that gives me access to a bunch of interrelated software, from which it would be easy to spin off nixpkgs contributions?

In general each package in Nixpkgs takes up a directory in which default.nix is to be callPackaged. You can also adopt this format in a flake. This way you can add the directory to Nixpkgs and add a line in all-packages.nix and make a pull request.

I have a template here that does this along with some readDir magic to generate an overlay based on the directories in the flake sources:


Thanks, this works nicely.

Is there any reason why it wouldn’t work with buildPythonPackage-based derivations?

If I copy-paste a simple python package derivation from nixpkgs, I always get errors such as

Function called without required argument "buildPythonPackage" at /nix/store/xlh1ig1gvwwf6k3gdand4syba18v6pjg-source/pkgs/dataframe-image/default.nix:2

Leaving just the derivation’s parameters in place

{ lib
, buildPythonPackage
, fetchPypi

and playing around with the expected arguments, gives similar errors, as long as Python-related things like buildPythonPackage or fetchPypi are expected. [edit: looks like I was mistaken: fetchPypi works, buildPythonPackage seems to be the only problematic argument.]

So it seems that the callPackage in the flake (based on your magic-overlay) is not providing buildPythonPackage and other Python-related things, even though such arguments clearly work in nixpkgs.

Any idea how to get past this problem?

Yeah python stuff depend on the python version so you need to use something like python3Packages.callPackage for it. This way you can just build the same thing for multiple python versions without changing the code itself. My ‘magic overlay’ doens’t really handle it but I think you get the idea.