Skip to content

Allow "building" with max-jobs=0 & no remote builders configured (or improve error message to specify what is missing) #15368

@Zocker1999NET

Description

@Zocker1999NET

Describe the bug

Despite everything being available for evaluation & realization (by utilizing substituter), Nix is unable to complete a build with --max-jobs 0 and no remote builders configured.

Steps To Reproduce

  1. Configure system.autoUpgrade similar to my setup
    • (just in case, the timings are configured there)
  2. provide a substitutor where the newest nixosConfiguration of the target is already built
  3. upgrade target manually to newest nixosConfiguration (optional, but even then this bug occurs)
  4. execute systemctl start nixos-upgrade.service and observe journal

Expected behavior

nixos-upgrade.service should be able to fully complete the "upgrade" process i.e. nix should be able to "build" everything because everything is provided by the local store and/or substituter.

Metadata

From the VM trying to perform the autoUpgrade: nix-env (Nix) 2.31.2

Additional context

The rationale for my setup is some VMs are not capable enough of building their own configuration (e.g. because they have at max 1 GiB RAM available). So I have a special builder & substituter VM, which has plenty of resources available (but is less prioritized in case of shortages). From former manual upgrades, I know that my substituter does build everything necessary for upgrading my VMs, and that the VMs are capable of accessing the substituter.

If the behavior I expect is the also the one which is currently implemented, then the error message that Nix gives is not really helpful. Because in that case I would expect that Nix at least states what derivation is missing & must therefore be built. As e.g. this is the log of one of my test VMs trying to perform a system.autoUpgrade:

Mar 01 00:26:27 immich systemd[1]: Starting NixOS Upgrade...
Mar 01 00:26:28 immich nixos-upgrade-start[14887]: building the system configuration...
Mar 01 00:26:37 immich nixos-upgrade-start[14896]: error:
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        … while calling the 'head' builtin
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:          at /nix/store/2fmdx1a2b9hkss7i43az0xfslhkd7hm4-source/lib/attrsets.nix:1696:13:
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:          1695|           if length values == 1 || pred here (elemAt values 1) (head values) then
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:          1696|             head values
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:              |             ^
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:          1697|           else
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        … while evaluating the attribute 'value'
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:          at /nix/store/2fmdx1a2b9hkss7i43az0xfslhkd7hm4-source/lib/modules.nix:1118:7:
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:          1117|     // {
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:          1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:              |       ^
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:          1119|       inherit (res.defsFinal') highestPrio;
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        … while evaluating the option `system.build.toplevel':
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        … while evaluating definitions from `/nix/store/2fmdx1a2b9hkss7i43az0xfslhkd7hm4-source/nixos/modules/system/activation/top-level.nix':
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        … while evaluating the option `system.systemBuilderArgs':
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        … while evaluating definitions from `/nix/store/2fmdx1a2b9hkss7i43az0xfslhkd7hm4-source/nixos/modules/system/activation/activatable-system.nix':
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        … while evaluating the option `system.activationScripts.etc.text':
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        … while evaluating definitions from `/nix/store/2fmdx1a2b9hkss7i43az0xfslhkd7hm4-source/nixos/modules/system/etc/etc-activation.nix':
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        … while evaluating definitions from `/nix/store/2fmdx1a2b9hkss7i43az0xfslhkd7hm4-source/nixos/modules/system/etc/etc.nix':
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        … while evaluating the option `environment.etc."ssh/ssh_config".source':
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        … while evaluating definitions from `/nix/store/2fmdx1a2b9hkss7i43az0xfslhkd7hm4-source/nixos/modules/system/etc/etc.nix':
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        … while evaluating the option `environment.etc."ssh/ssh_config".text':
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        … while evaluating definitions from `/nix/store/2fmdx1a2b9hkss7i43az0xfslhkd7hm4-source/nixos/modules/programs/ssh.nix':
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        (stack trace truncated; use '--show-trace' to show the full, detailed trace)
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        error: Unable to start any build; either increase '--max-jobs' or enable remote builds.
Mar 01 00:26:37 immich nixos-upgrade-start[14896]:        For more information run 'man nix.conf' and search for '/machines'.
Mar 01 00:26:37 immich nixos-upgrade-start[14887]: Command 'nix --extra-experimental-features 'nix-command flakes' build --print-out-paths 'github:Zocker1999NET/server#nixosConfigurations."immich.boreth.pve.6nw.de".config.system.build.toplevel' --no-link --max-jobs 0 --print-build-logs --refresh' returned non-zero exit status 1.
Mar 01 00:26:37 immich systemd[1]: nixos-upgrade.service: Main process exited, code=exited, status=1/FAILURE
Mar 01 00:26:37 immich systemd[1]: nixos-upgrade.service: Failed with result 'exit-code'.
Mar 01 00:26:37 immich systemd[1]: Failed to start NixOS Upgrade.
Mar 01 00:26:37 immich systemd[1]: nixos-upgrade.service: Consumed 10.534s CPU time, 1.8G memory peak, 160.2M read from disk, 624K written to disk, 10.5K incoming IP traffic, 5.7K outgoing IP traffic.

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions