!UKDpaKNNsBpOPfLWfX:zhaofeng.li

Colmena

289 Members
A simple, stateless NixOS deployment tool - https://github.com/zhaofengli/colmena98 Servers

Load older messages


SenderMessageTime
3 Mar 2024
@hexa:lossy.networkhexa e.g. in ~/.config.nixpkgs.config.nix 11:29:14
@dmoonfire:matrix.orgdmoonfireI have never heard of that file before. I'll do a `rg` to see.17:57:51
@dmoonfire:matrix.orgdmoonfire Apparently, I had it in one of my checked-in files for the flake. nixpkgs.config.allowAliases = false; 20:08:30
@dmoonfire:matrix.orgdmoonfire hexa: That was it, thank you! šŸ’™ 20:25:33
6 Mar 2024
@sammy:cherrykitten.dev@sammy:cherrykitten.dev joined the room.19:05:26
7 Mar 2024
@dretrange:matrix.orgDrEtrange joined the room.14:09:36
10 Mar 2024
@bonus:bonusplay.plBonus joined the room.12:48:17
13 Mar 2024
@ktemkin:katesiria.org@ktemkin:katesiria.org changed their display name from Kate Temkin to [K]ate Temkin.02:56:13
14 Mar 2024
@federicodschonborn:matrix.org@federicodschonborn:matrix.org left the room.02:04:46
@mjolnir:nixos.orgNixOS Moderation Botchanged room power levels.18:44:59
15 Mar 2024
@pgibson:matrix.orgpgibsonDoes Colmena (or NixOS) support automatic rollback for failed deployments? I had a deploy hang during testing (possible the SSH connection was interrupted) and I had to reboot the server04:02:47
@pgibson:matrix.orgpgibsonSSH was down and I hadn't configured a password to log in via the console04:03:23
@me:indeednotjames.comemilyno, see https://github.com/zhaofengli/colmena/issues/3804:08:18
@pgibson:matrix.orgpgibsonThanks04:09:39
@sammy:cherrykitten.dev@sammy:cherrykitten.devis there a way to build a VM from a colmena node config without duplicating the node config into an extra nixos configuration output (in a flake)?17:23:01
@sammy:cherrykitten.dev@sammy:cherrykitten.devso uh, an equivalent to nixos-rebuild build-vm17:23:54
@grahamc:nixos.org@grahamc:nixos.org joined the room.23:05:21
17 Mar 2024
@tcurdt:matrix.orgtcurdt

I have my hosts setup like this:

    nixosConfigurations = {
      utm = import ./machines/utm.nix {};

I really don't get the example config:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  };
  outputs = { nixpkgs, ... }: {
    colmena = {
      meta = {
        nixpkgs = import nixpkgs {
          system = "x86_64-linux";
          overlays = [];
        };
      };

      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";
      };
    };
  };
}

No nixosConfigurations?

00:35:19
@hexa:lossy.networkhexacolmena is a specific output that does not provide nixosConfigurations00:59:12
@hexa:lossy.networkhexabut you can create nixosConfigurations and transform them into colmena outputs00:59:25
@hexa:lossy.networkhexae.g. https://github.com/zhaofengli/colmena/issues/60#issuecomment-104719955100:59:53
@tcurdt:matrix.orgtcurdt

Urgh. That looks quite complicated.
Hoping this would work feels naiv now

      colema = {
        meta = {};
        utm = {
          deployment = {
            targetHost = "192.168.71.3";
            targetUser = "root";
          };
        };
        utm = self.nixosConfigurations.utm // {
          deployment = {
            targetHost = "192.168.71.3";
            targetUser = "root";
          };
        };
      };
01:13:12
@tcurdt:matrix.orgtcurdt *

Urgh. That looks quite complicated.
Hoping this would work feels naiv now

      colema = {
        meta = {};
        utm = self.nixosConfigurations.utm // {
          deployment = {
            targetHost = "192.168.71.3";
            targetUser = "root";
          };
        };
      };
01:16:51
18 Mar 2024
@dmoonfire:matrix.orgdmoonfireI struggle a lot translating those two concepts. Mostly I use a lot if Just file to handle what I couldn't figure out on my own. And trying to get home-manager into colmena took me months to puzzle out.02:23:17
@tcurdt:matrix.orgtcurdt
In reply to @dmoonfire:matrix.org
I struggle a lot translating those two concepts. Mostly I use a lot if Just file to handle what I couldn't figure out on my own.

And trying to get home-manager into colmena took me months to puzzle out.
Not good.
12:34:33
19 Mar 2024
@mjolnir:nixos.orgNixOS Moderation Botchanged room power levels.00:30:23
@dmoonfire:matrix.orgdmoonfireIts only been eighteen months if daily driving Nix. I'm sure in another couple years and I'll have it down.01:03:27
@me:indeednotjames.comemily
In reply to @hexa:lossy.network
but you can create nixosConfigurations and transform them into colmena outputs
you can also specify colmena as a flake input and pass your colmenaHiveĀ attrset to nixosConfiguration, one sec
01:21:22
@me:indeednotjames.comemily

take this slightly modified example from https://github.com/zhaofengli/colmena/blob/v0.4.0/src/nix/hive/tests/makehive-flake/flake.nix

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    colmena.url = "github:zhaofengli/colmena";
  };
  outputs = { nixpkgs, colmena, ... }: rec {
    colmenaHive = colmena.lib.makeHive {
      meta = {
        nixpkgs = import nixpkgs {
          system = "x86_64-linux";
        };
      };

      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";
      };
    };
    nixosConfigurations = colmenaHive.nodes;
  };
}

the diff to the upstream test is:

diff --git a/upstream-flake.nix b/flake.nix
index 11c7f62..a1f59d7 100644
--- a/upstream-flake.nix
+++ b/flake.nix
@@ -1,9 +1,9 @@
 {
   inputs = {
     nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
-    colmena.url = "git+file://@repoPath@";
+    colmena.url = "github:zhaofengli/colmena";
   };
-  outputs = { nixpkgs, colmena, ... }: {
+  outputs = { nixpkgs, colmena, ... }: rec {
     colmenaHive = colmena.lib.makeHive {
       meta = {
         nixpkgs = import nixpkgs {
@@ -25,5 +25,6 @@
         time.timeZone = "America/Los_Angeles";
       };
     };
+    nixosConfigurations = colmenaHive.nodes;
   };
 }

you can then use nix v3 (unstable) cli and nixos-rebuild as you wish:

āÆ nixos-rebuild --flake .#host-a build
building the system configuration...
trace: warning: system.stateVersion is not set, defaulting to 24.05. Read why this matters on https://nixos.org/manual/nixos/stable/options.html#opt-system.stateVersion.
01:39:01
@me:indeednotjames.comemilyi am honestly a bit surprised this isn't documented lol01:39:20

Show newer messages


Back to Room ListRoom Version: 6