Skip to content

Nix's master branch has broken nix-build exit codes #4813

@grahamc

Description

@grahamc

Describe the bug

nix-build should exit based on how the build failed. For example, from the docs:

Special exit codes:

    100
    Generic build failure, the builder process returned with a non-zero exit code.

    101
    Build timeout, the build was aborted because it did not complete within the specified timeout.

    102
    Hash mismatch, the build output was rejected because it does not match the outputHash attribute of the derivation.

    104
    Not deterministic, the build succeeded in check mode but the resulting output is not binary reproducable.

However, this is currently broken:

[grahamc@hyperchicken:~/projects/github.com/NixOS/nixpkgs]$ nix-build /nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv ; echo $?
this derivation will be built:
  /nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv
building '/nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv'...

trying https://github.com/mpv-player/mpv/commit/7c4465cefb27d4e0d07535d368febdf77b579566.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3553  100  3553    0     0  16919      0 --:--:-- --:--:-- --:--:-- 16919
error: hash mismatch in fixed-output derivation '/nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv':
         specified: sha256-PX8fPds1v2tAoUcohQFO2RKSlK50/uNmYbNMBYQwzPk=
            got:    sha256-PX8fPds1v3tAoUcohQFO2RKSlK50/uNmYbNMBYQwzPk=
1
[grahamc@hyperchicken:~/projects/github.com/NixOS/nixpkgs]$ nix-store --realize /nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv; echo $?
this derivation will be built:
  /nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv
building '/nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv'...

trying https://github.com/mpv-player/mpv/commit/7c4465cefb27d4e0d07535d368febdf77b579566.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3553  100  3553    0     0  36628      0 --:--:-- --:--:-- --:--:-- 36628
error: hash mismatch in fixed-output derivation '/nix/store/c70v6crmck8g7hrijma6b9r6x4a81x2v-7c4465cefb27d4e0d07535d368febdf77b579566.patch.drv':
         specified: sha256-PX8fPds1v2tAoUcohQFO2RKSlK50/uNmYbNMBYQwzPk=
            got:    sha256-PX8fPds1v3tAoUcohQFO2RKSlK50/uNmYbNMBYQwzPk=
1

Steps To Reproduce

  1. Create a fixed output derivation which has the wrong hash
  2. Try to build it
  3. Note that the exit code is wrong.

Expected behavior

Nix should exit with the documented exit codes.

nix-env --version output

nix-env (Nix) 2.4pre20210514_de9e43c

Additional context

NixOS unstable

Metadata

Metadata

Assignees

Labels

bugidea approvedThe given proposal has been discussed and approved by the Nix team. An implementation is welcome.
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions