cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
3.61k stars 262 forks source link

`devenv container build processes` fails with unexpected buildGoModule error #1083

Closed jab closed 2 months ago

jab commented 2 months ago

Describe the bug

I just followed the https://devenv.sh/containers/ docs to try to build a container for (essentially a "hello world") Python webapp using devenv for the first time. Though devenv up works as expected (it starts my server process and I can verify it's successfully serving requests), devenv container build processes fails with a "buildGoModule" error deep in github:NixOS/nixpkgs/.../lib/strings.nix:

❯ devenv processes up -d
• Building processes ...
• Failed to get cachix caches due to evaluation error
✔ Building processes in 5.7s.
• Starting processes ...• Building shell ...
• Failed to get cachix caches due to evaluation error
✔ Building shell in 5.6s.
• PID is 119314
• See logs:  $ tail -f /home/jab/src/hello-nix-image-py-webapp/.devenv/processes.log
• Stop:      $ devenv processes stop
✔ Starting processes in 5.6s.

❯ curl localhost:8000  # prove the server process is up and running
2024-03-29 23:55:24⏎

❯ devenv container build processes  # wat:
• Building processes container ...
• Failed to get cachix caches due to evaluation error
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'image-processes.json'
         whose name attribute is located at «github:NixOS/nixpkgs/807c549feabce7eddbf259dbdcec9e0600a0660d»/pkgs/stdenv/generic/make-derivation.nix:331:7

       … while evaluating attribute 'buildCommand' of derivation 'image-processes.json'
         at «github:NixOS/nixpkgs/807c549feabce7eddbf259dbdcec9e0600a0660d»/pkgs/build-support/trivial-builders/default.nix:68:16:
           67|         enableParallelBuilding = true;
           68|         inherit buildCommand name;
             |                ^
           69|         passAsFile = [ "buildCommand" ]

       … while evaluating derivation 'nix2container-1.0.0'
         whose name attribute is located at «github:NixOS/nixpkgs/807c549feabce7eddbf259dbdcec9e0600a0660d»/pkgs/stdenv/generic/make-derivation.nix:331:7

       … while evaluating attribute 'configurePhase' of derivation 'nix2container-1.0.0'
         at «github:NixOS/nixpkgs/807c549feabce7eddbf259dbdcec9e0600a0660d»/pkgs/build-support/go/module.nix:172:5:
          171|
          172|     configurePhase = args.configurePhase or (''
             |     ^
          173|       runHook preConfigure

       … from call site
         at «github:NixOS/nixpkgs/807c549feabce7eddbf259dbdcec9e0600a0660d»/pkgs/build-support/go/module.nix:180:10:
          179|       cd "$modRoot"
          180|     '' + lib.optionalString (vendorHash != null) ''
             |          ^
          181|       ${if proxyVendor then ''

       … while calling 'optionalString'
         at «github:NixOS/nixpkgs/807c549feabce7eddbf259dbdcec9e0600a0660d»/lib/strings.nix:256:5:
          255|     # String to return if condition is true
          256|     string: if cond then string else "";
             |     ^
          257|

       error:
       error: buildGoModule: Expect vendorHash instead of vendorSha256

✖ Command produced the following output:

✔ Building processes container in 1.5s.
Error:   × Command `/nix/store/l24rmcpdnachwhz4rjwb9d89m3gxfy5n-nix-2.21-devenv/bin/nix --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes
  │ --option warn-dirty false --option eval-cache false --keep-going --max-jobs 1 build --print-out-paths --no-link .#devenv.containers.processes.derivation` failed with
  │ with exit code 1



Reproducing

Please see https://github.com/jab/hello-nix-image-py-webapp for the code I used to reproduce this.

Version

devenv 1.0.1 (x86_64-linux)

jab commented 2 months ago

In case it's relevant, I changed my devenv.yaml to use a nixpkgs url of github:NixOS/nixpkgs/nixpkgs-unstable (as suggested in https://github.com/cachix/devenv/issues/1071#issuecomment-2027097581) just so I could get as far as devenv up working. Not sure if this has anything to do with this nix2container stuff not working though.

nlewo commented 2 months ago

The nix2container issue has been fixed by https://github.com/nlewo/nix2container/pull/126.

MaxDaten commented 2 months ago

@nlewo awesome, thank you very much!

jab commented 2 months ago

Thanks @nlewo, after running devenv update, I can now run devenv container build processes successfully.

Closing this, but unfortunately I immediately hit a new issue when trying devenv container run processes, so I've opened a new issue to track that.