hercules-ci / support

User feedback, questions and our public roadmap. help@hercules-ci.com
5 stars 1 forks source link

Eval fails in hercules only #51

Closed nrdxp closed 3 years ago

nrdxp commented 3 years ago

I was attempting to build a NixOS configuration as part of the ci. My repository is flake based so I am using flake-compat to pass derivations to hercules.

Here is the offending code. I can build this without error like so nix-build nix/ci.nix -A ci, but when hercules gets ahold of it, it produces the following error:

Exception: The option value `nix.registry.nixflk.to.path' in `/nix/store/vlrfmmyplwyj5wb6pn46jbqqpc3qm7sf-source/nixos/modules/services/misc/nix-daemon.nix' is not of type `string or signed integer or boolean or package'.; type: nix::ThrownError

My only guess is mismatched nix versions, as I am using nixFlakes from the 20.09 release.

roberth commented 3 years ago

I think I might have spotted a slight mistake.

  # ci = recurseIntoAttrs
  #   default.nixosConfigurations.ci.config.system.build.toplevel;

Here default.nixosConfigurations.ci.config.system.build.toplevel is a derivation rather than an attrset of derivations. This might throw off agent's evaluator.

Maybe you did intend to use an attrset at first?

let
#...
  ci = recurseIntoAttrs {
    nixos = default.nixosConfigurations.ci.config.system.build.toplevel;
  };
in
{
  inherit shell ci;
#...
}

I was able to instantiate it like that. Could you try something like this?

nrdxp commented 3 years ago

Thanks for the help. I did what you advised, but unfortunately got the exact same error. I also tried building a much simpler NixOS configuration just to ensure it wasn't specific to the ci config, but unfortunately, I still got the same error.

Here's a job with the two failed NixOS configurations.

Is there a way to override the nix version in use by the agent? If so I'd like to try that as well.

roberth commented 3 years ago

I've added trace calls and discovered the following value:

trace: DEBUG: firstInvalid
trace: { file = <CODE>; value = /var/lib/hercules-ci-agent/work/eval-45416e0281decdae/arg-src/nixflk; }
trace: DEBUG: defsFinal
trace: [ { file = <CODE>; value = /var/lib/hercules-ci-agent/work/eval-45416e0281decdae/arg-src/nixflk; } ]

So it seems that a path value is passed into the option, rather than a normal string, triggering the error message.

This has to do with the fact that the checkout is not a git repo currently.

To work around it, Nix Flakes' "fetchGit" behavior can be emulated in default in ci.nix as follows:

  default = (import "${../.}/compat").defaultNix;

In the future, I do plan to fetch via git, but for now it's best to use the workaround.