Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flake-utils usage #221

Open
abueide opened this issue Aug 7, 2024 · 5 comments
Open

flake-utils usage #221

abueide opened this issue Aug 7, 2024 · 5 comments

Comments

@abueide
Copy link

abueide commented Aug 7, 2024

Hi,

I'm trying to use colmena with flake-utils so that way I can deploy from my aarch64-linux runner as well as my x86_64-linux runner, but I get meta.nixpkgs must be evaluated in hermetic mode. Works fine without flake-utils and specifying system = "aarch64-linux" directly. I'm probably doing something stupid.

https://gist.github.com/abueide/5c8c0fd7bb5c1f70c4ff468748c03751

@justinas
Copy link
Contributor

I think the play here is to:

  1. Take the definition of the colmena output outside of the flake-utils.lib.eachDefaultSystem - I don't think having multiple, per-system colmena hives is supported or makes sense.
  2. Pass an uninstantiated nixpkgs, e.g. meta.nixpkgs = nixpkgs.
  3. Define nixpkgs.hostPlatform in your host configurations.

Then, deploying from either of aarch64 or x86_64 should work as long as there is a way to build for the destination system (e.g. emulatedSystems or a remote builder).

NB: I don't use flakes, so this is basically a guess.

@abueide
Copy link
Author

abueide commented Aug 18, 2024

@justinas thanks for the suggestion unfortunately produces this error

warning: Git tree '/home/andrea/code/natea/infra' is dirty
[INFO ] Using flake: git+file:///home/andrea/code/natea/infra?dir=amd64
error:
       … while evaluating the attribute 'metaConfig'

         at /nix/store/0wvzhzwrqhhc2v9ymjablcjfbjb1d853-source/eval.nix:192:3:

          191|   evalSelectedDrvPaths =     names: lib.mapAttrs    (_: v: v.drvPath)          (evalSelected names);
          192|   metaConfig = lib.filterAttrs (n: v: elem n metaConfigKeys) hive.meta;
             |   ^
          193|   introspect = f: f { inherit lib; pkgs = nixpkgs; nodes = uncheckedNodes; };

       … while calling the 'throw' builtin

         at /nix/store/0wvzhzwrqhhc2v9ymjablcjfbjb1d853-source/eval.nix:89:24:

           88|     if typeOf pkgConf == "path" || (typeOf pkgConf == "set" && pkgConf ? outPath) then
           89|       if hermetic then throw (uninitializedError "a path to Nixpkgs")
             |                        ^
           90|       # The referenced file might return an initialized Nixpkgs attribute set directly

       error: Passing a path to Nixpkgs as meta.nixpkgs is no longer accepted with Flakes.
       Please initialize Nixpkgs like the following:

       {
         # ...
         outputs = { nixpkgs, ... }: {
           colmena = {
             meta.nixpkgs = import nixpkgs {
               system = "x86_64-linux"; # Set your desired system here
               overlays = [];
             };
           };
         };
       }

@justinas
Copy link
Contributor

Right. Still, try making colmena a single output at the top level of your flake (not per-system), i.e. not use eachDefaultSystem for it.

If you have any target hosts that are aarch64, nixpkgs.hostPlatform in the host config should do the trick nevertheless (or else, you might want to try colmena's nodeNixpkgs attribute).

@abueide
Copy link
Author

abueide commented Aug 18, 2024

https://gist.github.com/abueide/8d10d550aff42a1c227e686e3f4037e4

like this? (i commented out any other nodes just to eliminate variables, nhqiv-jump definitely has nixpkgs.hostPlatform = "aarch64-linux"; in its hardware-configuration.nix)

it still produces the same error as above

@justinas
Copy link
Contributor

Yeah, the colmena output looks to be in the right place now. This does not change the fact that colmena requires meta.nixpkgs = import <nixpkgs> { system = ... }, as in the error message, you should revert that - sorry for my initial wrong suggestion.

The "system" used there should hopefully not matter as long as the hosts themselves override hostPlatform or system as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants