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

Demo fails to deploy via colmena #34

Closed
djohnson1865 opened this issue Apr 25, 2024 · 6 comments
Closed

Demo fails to deploy via colmena #34

djohnson1865 opened this issue Apr 25, 2024 · 6 comments

Comments

@djohnson1865
Copy link

djohnson1865 commented Apr 25, 2024

Little bit of a newbie when it comes to both flakes and NixOS on anything other than x86_64, so apologies if this is something to do with my environment rather than an issue with the flake itself.

Currently the demo flake won't seem to build on my workstation. Both when using the local flake and the remote flake (which I'd expect as I have made no changes to either flake)

Regardless of configuration, on attempting to use the example colmena command nix run nixpkgs#colmena apply

error:
       … while evaluating the attribute 'metaConfig'

         at /nix/store/nac0qag97bq6605slx1ilyd1kdc4cw08-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 'listToAttrs' builtin

         at /nix/store/h5g4m28iz22w31c0asl73mcir6z7x5ra-source/lib/attrsets.nix:382:5:

          381|     set:
          382|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |     ^
          383|

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `rk3588' does not exist. Definition values:
       - In `<unknown-file>'
[ERROR] -----
[ERROR] Operation failed with error: Child process exited with error code: 1
Hint: Backtrace available - Use `RUST_BACKTRACE=1` environment variable to display a backtrace

The Rust backtrace didn't provide me with much without digging into the Colmena source code. Not sure if this is due to a change on the colmena side, or something else, but without more offhand knowledge I'm at a loss

@noar-t
Copy link

noar-t commented Sep 10, 2024

I think you need to change it to specialArgs.rk3588. At least that worked for me, but is now leading me to be stuck at a different error around nixpkgs

@noar-t
Copy link

noar-t commented Sep 10, 2024

For reference changing to:

demo/flake.nix

     colmena = {
       meta = {
         nixpkgs = import nixpkgs {inherit system;};
         specialArgs.rk3588 = {
           inherit nixpkgs pkgsKernel;
         };
       };

results in:

[ERROR] Failed to evaluate opi5 - Last 20 lines of logs:
[ERROR]   stderr)        … while calling the 'head' builtin
[ERROR]   stderr)
[ERROR]   stderr)          at /nix/store/g8zzlf6drg73c987ii390yicq4c0j778-source/lib/attrsets.nix:922:11:
[ERROR]   stderr)
[ERROR]   stderr)           921|         || pred here (elemAt values 1) (head values) then
[ERROR]   stderr)           922|           head values
[ERROR]   stderr)              |           ^
[ERROR]   stderr)           923|         else
[ERROR]   stderr)
[ERROR]   stderr)        (stack trace truncated; use '--show-trace' to show the full trace)
[ERROR]   stderr)
[ERROR]   stderr)        error: attribute 'nixpkgs' missing
[ERROR]   stderr)
[ERROR]   stderr)        at /nix/store/g8zzlf6drg73c987ii390yicq4c0j778-source/lib/modules.nix:506:28:
[ERROR]   stderr)
[ERROR]   stderr)           505|         builtins.addErrorContext (context name)
[ERROR]   stderr)           506|           (args.${name} or config._module.args.${name})
[ERROR]   stderr)              |                            ^
[ERROR]   stderr)           507|       ) (lib.functionArgs f);
[ERROR]  failure) Child process exited with error code: 1
[ERROR] Failed to complete requested operation - Last 1 lines of logs:
[ERROR]  failure) Child process exited with error code: 1
[ERROR] -----
[ERROR] Operation failed with error: Child process exited with error code: 1
Hint: Backtrace available - Use `RUST_BACKTRACE=1` environment variable to display a backtrace

@cessationoftime
Copy link
Contributor

cessationoftime commented Sep 24, 2024

colmena.meta.specialArgs is the source of both problems. The parameter nixpkgs is not being specified for configuration.nix to find.

the solution is:

    colmena = {
      meta = {
        nixpkgs = import nixpkgs {inherit system;};
        specialArgs = {
          rk3588 = {
            inherit nixpkgs pkgsKernel;
          };
          # Pass nixpkgs to all modules
          inherit nixpkgs;
        };
      };

and I now get this error:

 nix run nixpkgs#colmena apply
[INFO ] Using flake: git+file:///home/cvanvranken/gits/nix-colmena
[INFO ] Enumerating nodes...
[INFO ] Selected all 1 nodes.
      🕓 15m 1 running, 1 succeeded
      ❌ 21m Failed: Child process exited with error code: 1
 opi5 ✅ 7s Evaluated opi5
 opi5 ❌ 21m Build failed: Child process exited with error code: 1
[ERROR] Failed to build opi5 - Last 20 lines of logs:
[ERROR]   stderr) root module: dm_crypt
[ERROR]   stderr)   copying dependency: /nix/store/7wq5blzbja576j6fj5dq70cb1vg1y56i-k-aarch64-unknown-linux-gnu-modules/lib/modules/6.1.43/kernel/lib/asn1_encoder.ko
[ERROR]   stderr)   copying dependency: /nix/store/7wq5blzbja576j6fj5dq70cb1vg1y56i-k-aarch64-unknown-linux-gnu-modules/lib/modules/6.1.43/kernel/security/keys/trusted-keys/trusted.ko
[ERROR]   stderr)   copying dependency: /nix/store/7wq5blzbja576j6fj5dq70cb1vg1y56i-k-aarch64-unknown-linux-gnu-modules/lib/modules/6.1.43/kernel/security/keys/encrypted-keys/encrypted-keys.ko
[ERROR]   stderr)   dependency already copied: /nix/store/7wq5blzbja576j6fj5dq70cb1vg1y56i-k-aarch64-unknown-linux-gnu-modules/lib/modules/6.1.43/kernel/drivers/md/dm-mod.ko
[ERROR]   stderr)   copying dependency: /nix/store/7wq5blzbja576j6fj5dq70cb1vg1y56i-k-aarch64-unknown-linux-gnu-modules/lib/modules/6.1.43/kernel/drivers/md/dm-crypt.ko
[ERROR]   stderr) root module: input_leds
[ERROR]   stderr)   copying dependency: /nix/store/7wq5blzbja576j6fj5dq70cb1vg1y56i-k-aarch64-unknown-linux-gnu-modules/lib/modules/6.1.43/kernel/drivers/input/input-leds.ko
[ERROR]   stderr) depmod: WARNING: could not open modules.builtin.modinfo at /nix/store/yi6sc7cvx4rv19cyccjhcswa7zm5fqmp-k-aarch64-unknown-linux-gnu-modules-shrunk/lib/modules/6.1.43: No such file or directory
[ERROR]   stderr) building '/nix/store/dal8qjsxjv7xbw57v2xng2id09r4x28j-initrd-k-aarch64-unknown-linux-gnu.drv'...
[ERROR]   stderr) building '/nix/store/s7dg198miv9cb2x8qir2zp36vpg23r68-boot.json.drv'...
[ERROR]   stderr) building '/nix/store/29k8cwz7xji8j7ais1x2yx29p9iw6nc2-nixos-system-orangepi5plus-23.11pre-git.drv'...
[ERROR]   stderr) The bootloader cannot find the proper kernel image.
[ERROR]   stderr) (Expecting /nix/store/w6fsb1g61746xh030bxmxkqp4gc4cci9-k-aarch64-unknown-linux-gnu/bzImage)
[ERROR]   stderr) error: builder for '/nix/store/29k8cwz7xji8j7ais1x2yx29p9iw6nc2-nixos-system-orangepi5plus-23.11pre-git.drv' failed with exit code 1;
[ERROR]   stderr)        last 2 log lines:
[ERROR]   stderr)        > The bootloader cannot find the proper kernel image.
[ERROR]   stderr)        > (Expecting /nix/store/w6fsb1g61746xh030bxmxkqp4gc4cci9-k-aarch64-unknown-linux-gnu/bzImage)
[ERROR]   stderr)        For full logs, run 'nix log /nix/store/29k8cwz7xji8j7ais1x2yx29p9iw6nc2-nixos-system-orangepi5plus-23.11pre-git.drv'.
[ERROR]  failure) Child process exited with error code: 1
[ERROR] Failed to complete requested operation - Last 1 lines of logs:
[ERROR]  failure) Child process exited with error code: 1
[ERROR] -----
[ERROR] Operation failed with error: Child process exited with error code: 1
Hint: Backtrace available - Use `RUST_BACKTRACE=1` environment variable to display a backtrace

@cessationoftime
Copy link
Contributor

If I try to look for the Image file:

ls /nix/store/w6fsb1g61746xh030bxmxkqp4gc4cci9-k-aarch64-unknown-linux-gnu/
dtbs  Image  lib  System.map

Then we see it has an Image and not a bzImage. This must be the source of the problem.

@cessationoftime
Copy link
Contributor

cessationoftime commented Sep 25, 2024

My problem seems to be from the fact I am using UEFI and the demo is configured for U-BOOT. The solution is to remove the sd-image and use grub with UEFI since that is what nixos-generators configured for boot loading in the UEFI image.

This almost works, but it looks like I still need to specify my fileSystem root. I can probably take that from hardware-configuration.nix generated from nixos-generate-config

{
  description = "NixOS configuration for rk3588 remote deployment";

  inputs = {
    # For production, use the remote flake
    nixos-rk3588.url = "github:ryan4yin/nixos-rk3588";
  };

  outputs = {nixos-rk3588, ...}: let
    # using the same nixpkgs as nixos-rk3588 to utilize the cross-compilation cache.
    inherit (nixos-rk3588.inputs) nixpkgs;
    boardModule = nixos-rk3588.nixosModules.orangepi5plus;

    # 1. for cross-compilation on x86_64-linux
    system = "x86_64-linux";
    # Compile the kernel using a cross-compilation tool chain
    # Which is faster than emulating the target system.
    pkgsKernel = import nixpkgs {
      localSystem = "x86_64-linux";
      crossSystem = "aarch64-linux";
    };
    # 2. for native compilation on aarch64-linux SBCs.
    # system = "aarch64-linux";
    # native compilation tool chain for the linux kernel
    # pkgsKernel = import nixpkgs {
    #    system = "aarch64-linux";
    # };
  in {
    colmena = {
      meta = {
         nixpkgs = import nixpkgs {inherit system;};
         specialArgs = {
           rk3588 = {
             inherit nixpkgs pkgsKernel;
           };
           # Pass nixpkgs to all modules
           inherit nixpkgs;
         };
      };

      opi5plus = {
        deployment.targetHost = "orange";
        deployment.targetUser = "root";
        # Allow local deployment with `colmena apply-local`
        # deployment.allowLocalDeployment = true;

        imports = [
          # import the rk3588 module, which contains the configuration for bootloader/kernel/firmware 
          # Import the core module, but exclude sd-image (U-Boot-specific)
          boardModule.core
          # boardModule.sd-image

          # your custom configuration
          ./configuration.nix
          ./user-group.nix

          # UEFI configuration with bootloader settings
          {
             # grub bootloader configured for UEFI
             boot = {
               # growPartition = true;  # If partition resizing is necessary
               kernelParams = ["console=ttyS0"];  # If you need serial console access
               # loader.timeout = lib.mkDefault 0;  # Optional, to skip GRUB menu
               initrd.availableKernelModules = ["uas"];  # If specific kernel modules are required
               loader.grub = {
                 enable = true;
                 device = "nodev";
                 efiSupport = true;
                 efiInstallAsRemovable = true;
               };
             };
          }
        ];
      };
    };
  };
}

@cessationoftime
Copy link
Contributor

You should be able to close this now after merging my PRs.

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

3 participants