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

documentation leaves me confused #226

Open
tcurdt opened this issue Sep 12, 2024 · 5 comments
Open

documentation leaves me confused #226

tcurdt opened this issue Sep 12, 2024 · 5 comments

Comments

@tcurdt
Copy link

tcurdt commented Sep 12, 2024

The goal is deploy from aarch64-darwin to x86_64-linux and aarch64-linux.

But I am absolute lost about when it comes to the meta section.
Error messages and documentation seem to suggest something along the lines of

      colmena = {
        meta = {
          nixpkgs = import nixpkgs-stable {
            system = "x86_64-linux";
            overlays = [];
          };
        };

But I don't understand why I would need to specify the nixpkgs in the meta section - and even more so the system.
Both are already declared in the nixosConfigurations. And why would all deployments share the same meta?

But now it gets even more interesting: How do select the nixosConfiguration?
The docs have an example like this:

      host-a = { name, nodes, pkgs, ... }: {
        boot.isContainer = true;
        time.timeZone = nodes.host-b.config.time.timeZone;
      };
      host-b = {
        deployment = {
          targetHost = "somehost.tld";
          targetPort = 1234;
          targetUser = "luser";
        };
        boot.isContainer = true;
        time.timeZone = "America/Los_Angeles";
      };

But that is missing a reference to what should get deployed 🤷‍♂️

I tried this:

        utm-arm = import self.nixosConfigurations.utm-arm {
          deployment = {
            tags = [ "vm" ];
            keys = {
              foo = {
                text = "text";
              };
            };
            targetHost = "192.168.78.7";
            targetUser = "root";
          };
        };

but it seems like that's not the way either.

It would be great to have some real-world example to look at.

@tcurdt
Copy link
Author

tcurdt commented Sep 12, 2024

The full flake is here FWIW

https://github.com/tcurdt/nixcfg/blob/main/flake.nix

@tcurdt
Copy link
Author

tcurdt commented Sep 12, 2024

Digging some more I assume it should be something along the lines of this?
Still not correct but probably closer.

      colmena = {
        meta = {
          nixpkgs = import nixpkgs-stable {
            system = "aarch64-darwin";
          };
        };

        utm-arm = {
          deployment = {
            targetHost = "192.168.78.7";
            targetUser = "root";
          };
          imports = [ self.nixosConfigurations.utm-arm ];
          # imports = [ ./machines/utm-arm.nix ];
        };

@tcurdt
Copy link
Author

tcurdt commented Sep 13, 2024

I got it working now like this

      colmena = {
        meta = {
          nixpkgs = import nixpkgs-stable {
            system = "aarch64-darwin";
          };
          specialArgs = { inherit inputs; };
        };

        utm-arm = {
          deployment = {
            targetHost = "192.168.78.7";
            targetUser = "root";
          };
          imports = [ ./machines/utm-arm.nix ];
        };

but the meta section is still a mystery to me.

@justinas
Copy link
Contributor

justinas commented Sep 13, 2024

Colmena is not flakes-first or flakes-mandatory, hence it takes only NixOS configurations modules (as seen in your last example imports = [ ./machines/utm-arm.nix ];), not an instantiated nixpkgs.lib.nixosSystem which you might have in flakes. So meta.nixpkgs needs to be specified, since otherwise Colmena has no idea what nixpkgs to evaluate with.

See also #60 for ways to integrate flake nixosConfigurations outputs with Colmena.

@justinas
Copy link
Contributor

To expand on your core issue (how to deploy from x86_64 to aarch64), it should be fine setting meta.nixpkgs to a nixpkgs import with the system of your machine, and then specifying nixpkgs.system or nixpkgs.hostPlatform (this one is set automatically nowadays by nixos-generate-config in hardware-configuration.nix) inside the aarch64 machine's configuration. I've used this pattern in the past, although on a flakeless setup.

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