Forcing a package to rebuild

Hello all,

Is anyone aware of a way to force a package to rebuild? I’m trying to optimize a build job by fiddling around with the --cores and --max-jobs settings in Nix, and the corresponding -j setting for gcc. In order to do so, I need to be able to re-run the same build multiple times and compare results. I notice that nix build has a --rebuild option, but that doesn’t seem to force an actual re-build.

Thanks!

There’s a --check option that’ll force one for reproducibility testing

I think that’s just on nix-build, and I’m using flakes/nix build, so I’m not sure if it’s still an option here?

It isn’t. AFAIK rebuild and check do the same thing in the different CLIs, though I don’t think I’ve used the flake version. I know I’ve successfully used check in nix-build.

Yes, you’re right. The --rebuild flag does exactly this. I thought it didn’t, but I must have been using it wrongly before. Thanks.

1 Like

currently trying this on nix 2.17.0 and here nix build --rebuild ... seems to ignore the --builders ... flag and also the preconfigured builders via /etc/nixos/machines. trying to delegate a rebuild from a linux to a darwin machine yields the following error:

env NEXTEST_EXTRA_ARGS="request_timeout" nix build --builders "ssh-ng://builder@167.235.13.208 x86_64-darwin - 4 1 nix-command,flakes,ca-derivations,impure-derivations,recursive-nix - -" --rebuild -vL --impure --show-trace --override-input versions ./versions/weekly --override-input holochain . .#packages.x86_64-darwin.build-holochain-tests-unit
(...)
error: a 'x86_64-darwin' with features {} is required to build '/nix/store/4agkixxfhj29rly6j09jg4p00hr84rx1-holochain-tests-nextest-nextest-workspace.drv', but I am a 'x86_64-linux' with features {ca-derivations, recursive-nix}

@steveej Did you ever figure this out? I am struggling to understand why my similar setup is failing.

no, i ended up SSHing into the mac builder directly. manual testing like this is rare for me so i couldn’t’ justify digging deep into this issue.