How to `requireFile` when it is a directory?

I’d like to add a Python package to a flake.nix where the src of it is non free software, and it’s a directory containing a I know there’s the requireFile Nix function from Nixpkgs:

I think I understood correctly that I can use the hashMode = "recursive"; argument for a directory. But my question is, how do I instruct users of my flake to add that directory to their nix store by themselves?

I tried:

nix-store --query --hash $(nix-store --add-fixed sha256 --recursive <path-to-manually-downloaded-dir>)

But the requireFile doesn’t seem to find the find the directory I added - the hash doesn’t fit perhaps?

I also tried a modern nix command:

nix-store --query --hash $(nix store add-path <path-to-manually-downloaded-dir> --name 'unfree-py-package-src')

And this time I even matched the name that requireFile needs to be "unfree-py-package-src" but it didn’t work :confused: .

Am I doing something substantially wrong?

EDIT: Perhaps the best way would be to instruct users of my flake to zip that folder and then add that zip to their store?

1 Like

I probably had a typo or something, but this worked eventually.

Apparently, even for files added with this method, the hashMode = "recursive" argument is needed as well.

There’s some more discussion going on at: Too many ways / commands to add files to the store manually · Issue #6210 · NixOS/nix · GitHub