nix build --rebuild doesn't work with CA derivations
Describe the bug
nix build --rebuild doesn't check for reproducibility for CA derivations.
Steps To Reproduce
$ nix build --expr '(builtins.getFlake "nixpkgs").legacyPackages.x86_64-linux.runCommand "test" { __contentAddressed = true; } "echo $RANDOM > $out"' --impure
$ nix build --expr '(builtins.getFlake "nixpkgs").legacyPackages.x86_64-linux.runCommand "test" { __contentAddressed = true; } "echo $RANDOM > $out"' --impure --rebuild
$ nix build --expr '(builtins.getFlake "nixpkgs").legacyPackages.x86_64-linux.runCommand "test" { __contentAddressed = false; } "echo $RANDOM > $out"' --impure
$ nix build --expr '(builtins.getFlake "nixpkgs").legacyPackages.x86_64-linux.runCommand "test" { __contentAddressed = false; } "echo $RANDOM > $out"' --impure --rebuild
error: derivation '/nix/store/mq5w634hcdy3mals8dcabr4n4iaazlxc-test.drv' may not be deterministic: output '/nix/store/qans2s4fc40pr269ax1adkb3p67ksil8-test' differs
Expected behavior
Nix should print an error complaining about different outputs like input-addressed derivations.
nix-env --version output
nix (Nix) 2.24.2
Additional context
Priorities
Add :+1: to issues you find important.
Overriding platform tags would also be useful. Currently, if any build.py script is used, poetry just assumes the most specific tags, in all other cases just py3-none-any.
We are having the same problem, as we want to distribute already-built binaries via poetry. Therefore we need to set these tags manually. This is what we came up with to workaround:
pyproject.toml
...
[build-system]
requires = ["poetry_core>=1.0.0", "setuptools"]
[tool.poetry.build]
script = "build.py"
generate-setup-file = true
...
build.py
import setuptools
def build(setup_kwargs):
# Run targeted build separately as poetry does not support target builds yet
try:
setuptools.setup(
**setup_kwargs,
script_args = ['bdist_wheel'],
options = {
'bdist_wheel': { 'plat_name': 'any' },
'egg_info': { 'egg_base': './build/' }
}
)
except:
print("Failed to create targeted wheel")
This will trigger an additional wheel build with a given target, leading to 2 different wheels in the dist folder, where one was created by poetry with host information and one created by this build script.
I've just run into this in the context of wanting to package in binaries which are generated outside of the poetry build. These binaries are platform specific and generated entirely outside of the python ecosphere (in our own CI build chains).
With all versions available at once, I want to be able to move one binary into place, run poetry build, rinse and repeat. To do that, I need to be able to pass in the platform and abi tags manually. Actually I need to be able to manually chose the platform different to the currently running platform and clamp abi to none.
poetry build --help mentions:
-c, --config-settings=CONFIG-SETTINGS Provide config settings that should be passed to backend in <key>=<value> format. (multiple values allowed)
This are a core feature for PEP 517.
So I think a very simple implementation might just allow you to specify these tags via config settings when you build. I think most of the use cases here are for people trying to build something for distribution. A secondary feature to set defaults for these in pyproject.toml might also be useful, but perhaps help fewer use cases.