colmena icon indicating copy to clipboard operation
colmena copied to clipboard

Move meta.nodeNixpkgs to deployment.nixpkgs inside the node config

Open cole-h opened this issue 2 years ago • 4 comments

IMHO, it makes more sense to configure the used nixpkgs inside of the node's config, instead of in the meta attrset.

cole-h avatar Feb 04 '22 23:02 cole-h

It's a chicken-and-egg problem, because in order to get deployment.nixpkgs from a node's config the first place, you need a nixpkgs for its evalModules implementation.

zhaofengli avatar Feb 05 '22 00:02 zhaofengli

Understood; however, meta.nixpkgs is required even when meta.nodeNixpkgs is specified.

I've got a very ugly, WIP patch that does exactly what I want. I'll submit a PR soon to show you what I mean and how it's possible.

cole-h avatar Feb 05 '22 01:02 cole-h

I've opened https://github.com/zhaofengli/colmena/pull/56 with the smallest diff necessary for this functionality (minus removing meta.nodeNixpkgs).

cole-h avatar Feb 05 '22 01:02 cole-h

IMHO this is an opportunity to rethink how a colmena deployment is specified in general. I think the current setup has a couple of paper cuts:

  • awkwardness of using meta to specify what nixpkgs a node uses (what this issue is primarily about), but also:
  • defaults and meta on the same level as named nodes --- having special attribute names that are treated differently within a set that is otherwise interpreted to be "just the nodes" feels very awkward; it would be much nicer to have a set with a fixed set of attributes, that one could feasibly write a NixOS-style config module to validate.

I envision a hive being structured something more like this...

{
  colmena = {
    meta.nixpkgs = nixpkgs.legacyPackages.x86_64-linux;
    defaults = { name, pkgs, lib, ... }: {
      imports = [ ./defaults.nix ];
      networking.hostName = lib.mkDefault name;
    };
    nodes = {
      phone = {
        nixpkgs = nixpkgs-mobile.legacyPackages.aarch64-linux;
        config = {
          deployment.targetHost = "phone.vpn.linuxhackerman.de";
          imports = [ ./nodes/beaker/configuration.nix ];
        };
      };
      server = {
        config.deployment.targetHost = "server.linuxhackerman.de";
        config.imports = [ ./nodes/server/configuration.nix ];
      };
    };
  };
}

For extra niceness, I think it would be awesome to have the hive itself be a NixOS-style module, where modules can be written that produce config across multiple nodes, much like nixus does. I've done some experiments trying to force nixus's output into a colmena hive, and it's worked fairly well, but is definitely a little more awkward than native support would be.

Thoughts?

(cc @ma27 and @willibutz who I've worked with/talked to about this)

lheckemann avatar Feb 19 '22 01:02 lheckemann