Any way to prevent local compilation?

Lately started to get haunted by hydra failures. (Relevant thread)

Today my laptop was levitating again due to fans. It was again thunderbird.

Is there a way to prevent local build? At least for certain packages? I realize that’s an odd question, but I’d rather see a nixos-rebuild to fail then compiling some of the apps I have.

2 Likes

Maybe try --max-jobs 0 with a remote builder.

Another possibility is using nixus or deploy-rs from another computer and deploy the result to your laptop. Here’s my config GitHub - bbigras/nix-config: My personal nix config . 3 days a week a github action updates my packages with niv, builds the config for multiple computers and pushes it to cachix so I don’t have to build anything on my computers.

2 Likes

Is it possible to specify max-jobs in conjunction with autoUpgrade though?

I’m not 100% sure but I think so. You can set nix.maxJobs = 0; in configuration.nix.

I used it before to avoid using too many resources on an important system.

:warning I tried this now and it turned out to be a very bad idea. Once you switched to that and nix-channel --updated, you cannot go back that easily, because it also prevents you from building a configuration without nixos.maxJobs = 0 (obviously).

1 Like

You can just run nixos-rebuild boot -j 1 or any similar nix-build command with the -j X option to allow local builds again.

2 Likes

Unfortunately -j X doesn’t seem to be combinable with --upgrade:

# nixos-rebuild boot -j 1 --upgrade
unpacking channels...
error: 1 derivations need to be built, but neither local builds ('--max-jobs') nor remote builds ('--builders') are enabled
error: program '/nix/store/agzmb1cin5dn8wlbfmkbbjzvz4422yys-nix-2.3.9/bin/nix-env' failed with exit code 1

Works for me:

# nixos-rebuild boot --upgrade -j1 --builders ''
unpacking channels...
created 1 symlinks in user environment
building Nix...
building the system configuration...
these derivations will be built:
  /nix/store/j3ccp5lyzbcw9aziqjs6kc589y218l3r-nixos-version.drv
  /nix/store/rd8fxmag28ybiqwbmk17l9ads057z8jx-system-path.drv
  /nix/store/ly9r5vhly6xiww36yy16gxrkkgvkq658-dbus-1.drv

Maybe the order of the arguments matter, I’m not sure about that.

I dont understand the result.

Is there a way to fail instead of compile if a package is not in the binary cache?

I am suffering from this too, especially as packages are NOT in the binary cache if they fail to build there, making compilation even less useful.

--option max-jobs 0 would work. Although that would prevent building other derivations that cannot be cached.

1 Like

Wouldn’t this fail on things like the activation script, or systemd-units, or a lot of other things that are marked as “preferLocalBuilds”?

2 Likes

Yes, that’s what I said “cannot be cached”.

1 Like

GitHub - dramforever/nix-log-check: Check binary cache for possibly failing build logs · GitHub might be what you are looking for

2 Likes

thanks for the replies!

yes, due to the nature of building nix systems, this would break a few workflows. The most recent I found was, breaking appimage-run which seems to require overrides for adding runtimes

For making this possible to implement in AutoUpgrades, it seems that module needs an ability to run custom commands. Currently, those are locked to nixos-rebuid with custom arguments.