9 months ago
this is my nixpacks.toml context. but nixpacks refuse to change the requirement location and try to reade requirement.txt from root
[variables]
BPREQUIREMENTSTXT_PATH = "requirements/production.txt"
[phases.setup]
nixPkgs = ["python312"]
[phases.install]
cmd = ["pip install -r requirements/production.txt"]
[start]
cmd = "./entrypoint.sh"
but it wont recognize my requirement/production.txt and when i see the plan it is always going for default requiements.txt in root. how to tell it to change the requirement.txt location on build
Pinned Solution
9 months ago
To solve your issue cleanly, where nixpacks insists on using requirements.txt in the root but you want to use a custom location (requirements/production.txt), here's the recommended solution:
# nixpacks.toml
[variables]
# This variable is not used by nixpacks automatically; safe to remove or ignore
# BPREQUIREMENTSTXT_PATH = "requirements/production.txt"
[phases.setup]
nixPkgs = ["python312"]
[phases.install]
# ⛔ Skip default install behavior that looks for requirements.txt in root
skip = true
cmd = ["pip install -r requirements/production.txt"]
[start]
cmd = "./entrypoint.sh"
Setting
skip = truein[phases.install]prevents the default logic, which always looks forrequirements.txtin the root.Your custom
cmdstill runs inside the virtual environment created by the setup phase — so you still get the automatic Python setup, virtual environment, and all default system dependencies.
Don’t rely on BPREQUIREMENTSTXT_PATH
That variable is used by the internal build plan generator, but is not currently configurable via nixpacks.toml. It’s ignored unless you patch the internals or fork Nixpacks.
8 Replies
i try to build nixpacks locally , to understand the problem but nixpacks still going for requirements.txt in root
9 months ago
Hey man. Nixpack always looks for requirements.txt in the root. To use a different file, either symlink your file to root as requirements.txt or disable the default install phase by adding skip = true under [phases.setup] and keep your custom install command.
hello and tnx for answering.
linking the requirements is out of question ( this is my solution right now) but if i use skip=true do i get the benefits of automatically venv creation and other stuff that automatic build give me ? or i have to wright entire build process
9 months ago
Yes, even if you set skip = true under [phases.install], Nixpacks will still handle the setup phase, which includes creating the virtual environment and setting up Python based on your nixPkgs.
So no, you don’t need to rewrite the whole build process. Just skip the default install phase and provide your custom pip install command. Everything else (like venv creation) still works as expected from the setup phase.
9 months ago
To solve your issue cleanly, where nixpacks insists on using requirements.txt in the root but you want to use a custom location (requirements/production.txt), here's the recommended solution:
# nixpacks.toml
[variables]
# This variable is not used by nixpacks automatically; safe to remove or ignore
# BPREQUIREMENTSTXT_PATH = "requirements/production.txt"
[phases.setup]
nixPkgs = ["python312"]
[phases.install]
# ⛔ Skip default install behavior that looks for requirements.txt in root
skip = true
cmd = ["pip install -r requirements/production.txt"]
[start]
cmd = "./entrypoint.sh"
Setting
skip = truein[phases.install]prevents the default logic, which always looks forrequirements.txtin the root.Your custom
cmdstill runs inside the virtual environment created by the setup phase — so you still get the automatic Python setup, virtual environment, and all default system dependencies.
Don’t rely on BPREQUIREMENTSTXT_PATH
That variable is used by the internal build plan generator, but is not currently configurable via nixpacks.toml. It’s ignored unless you patch the internals or fork Nixpacks.
Status changed to Open chandrika • 9 months ago
Status changed to Solved chandrika • 9 months ago
sorry for the delay i was in Iran, and in middle of war so i can test your suggestion until now
i change the nixpacks.toml to this according to ur suggestion
[phases.setup]
nixPkgs = ["python312"]
[phases.install]
skip=true
cmd = ["pip install -r requirements/production.txt"]
[start]
cmd = "./entrypoint.sh"
and after build i get this it seems skip won't work and nixpack wanted to use requirements.txt again
══════════════════════════════ Nixpacks v1.39.0 ══════════════════════════════╗
║ setup │ python312 ║
║──────────────────────────────────────────────────────────────────────────────║
║ install │ python -m venv --copies /opt/venv && . /opt/venv/bin/activate ║
║ │ && pip install -r requirements.txt ║
║──────────────────────────────────────────────────────────────────────────────║
║ start │ ./entrypoint.sh ║
╚════════════════════════════════