zhaofengli / colmena

A simple, stateless NixOS deployment tool
https://colmena.cli.rs
MIT License
1.06k stars 59 forks source link

Support for nix-infect for non-nix hosts #148

Open ChetanBhasin opened 1 year ago

ChetanBhasin commented 1 year ago

I think this is one of the features supported by nixops. Nix Infect is a script that takes a non Nix host and "infects" it with Nix such that the system can now be managed using Nix.

This is very nice for cloud providers that do not offer a Nix image out of the box. At the moment, I infect the node manually and then use colmena to apply custom configuration. It would be nice though if colmena, just like nixops could also first apply infect scripts and THEN apply the nix configuration.

aciceri commented 1 year ago

Check also nixos-anywhere for something a bit more structured than nixos-infect, under the hood they should use the same principle.

Janik-Haag commented 3 months ago

Yeah nixos-anywhere support would be awesome. I currently use

nixos-anywhere --store-paths $(nix-build -E '(import ./colmena-anywhere.nix).host-a.disko-script') $(nix-build -E '(import ./colmena-anywhere.nix).host-a.nixos-system') root@example.com 

where the content of colmena-anywhere.nix is

let
  sources = import ./npins;
  pkgs = import sources.nixpkgs { };
  lib = pkgs.lib;
  makeHive =
    rawHive:
    (import "${sources.colmena}/src/nix/hive/eval.nix" {
      inherit rawHive;
      colmenaOptions = import "${sources.colmena}/src/nix/hive/options.nix";
      colmenaModules = import "${sources.colmena}/src/nix/hive/modules.nix";
    });
in
lib.mapAttrs (name: value: {
  nixos-system = value.config.system.build.toplevel;
  disko-script = value.config.system.build.diskoScriptNoDeps;
}) (makeHive (import ./hive.nix)).nodes