I want to use buildPythonApplication
to build a python program using a nix flake. I’m using setup.py
for the packaging, and the python code is in its own directory, so the directory structure is:
├── fetch_links
│ ├── fetch_links.py
│ └── __init__.py
├── flake.lock
├── flake.nix
├── setup.py
Unfortunately due to nix’s caching, changes to the python code don’t cause nix to rebuild the program, presumably because the hash of the src
directory doesn’t change.
{
description = "A Python program.";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
outputs = { self, nixpkgs }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
in
{
packages.x86_64-linux.default = pkgs.python3Packages.buildPythonApplication {
pname = "fetch_links";
version = "1.0.0";
src = builtins.path {
path = ./.;
};
# Dependencies
propagatedBuildInputs = with pkgs.python3Packages; [
requests
beautifulsoup4
];
pythonImportsCheck = [ "fetch_links" ];
# Metadata
meta = with pkgs.lib; {
description = "A Python program.";
license = licenses.mit;
maintainers = [ maintainers.your-name ];
};
};
# App to run the program directly
apps.default = {
type = "app";
program = "${self.packages.default}/bin/fetch-links";
};
};
}
Is there a way to force nix build
to not cache src
? I have tried nix build . --rebuild
, but unsuccessfully.