| 15 Mar 2024 |
@sammy:cherrykitten.dev | is 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 | so uh, an equivalent to nixos-rebuild build-vm | 17:23:54 |
| @grahamc:nixos.org joined the room. | 23:05:21 |
| 17 Mar 2024 |
tcurdt | 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 | colmena is a specific output that does not provide nixosConfigurations | 00:59:12 |
hexa | but you can create nixosConfigurations and transform them into colmena outputs | 00:59:25 |
hexa | e.g. https://github.com/zhaofengli/colmena/issues/60#issuecomment-1047199551 | 00:59:53 |
tcurdt | 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 | * 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 | 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. | 02:23:17 |
tcurdt | 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 |
| NixOS Moderation Botchanged room power levels. | 00:30:23 |
dmoonfire | Its only been eighteen months if daily driving Nix. I'm sure in another couple years and I'll have it down. | 01:03:27 |
emily | 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 |
emily | 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 |
emily | i am honestly a bit surprised this isn't documented lol | 01:39:20 |
emily | you can also mix colmena nodes and your "vanilla" lib.nixosSystem in nixosConfigurations that way (for use with nixos-rebuild):
https://git.geklaute.cloud/emilylange/nixos-config/src/commit/22570786b24b606484447bef7a29fe565d475db7/flake.nix#L48-L76
| 01:41:46 |
ari ❄ | here's how I do this: https://code.hackerspace.pl/ar/nibylandia/src/branch/main/flake.nix#L115-L123 | 10:35:29 |
ari ❄ | tl;dr: automatically generate nixosConfiguration entries based on contents of a directory, and then generating colmena nodes based off of that | 10:37:39 |
| 21 Mar 2024 |
| craige joined the room. | 05:41:34 |
| NixOS Moderation Botchanged room power levels. | 18:03:17 |
| @grahamc:nixos.org left the room. | 20:07:53 |
| 22 Mar 2024 |
| @mrene:matrix.org left the room. | 00:51:08 |
| 25 Mar 2024 |
| @badele:matrix.org joined the room. | 20:26:10 |
| @belak:matrix.org joined the room. | 22:16:11 |
@belak:matrix.org | I'm looking at the multi-architecture-deployments page and I feel like I must be missing something. In this instance, when you set up meta.nixpkgs, do you specify your "default" architecture, and use the nixos configuration's nixpkgs.system to override when you're not on the default? | 22:40:58 |
@belak:matrix.org | * I'm looking at the multi-architecture-deployments page and I feel like I must be missing something. In this instance, when you set up colmena.meta.nixpkgs, do you specify your "default" architecture, and use the nixos configuration's nixpkgs.system to override when you're not on the default? | 22:41:20 |
@belak:matrix.org | Redacted or Malformed Event | 22:41:32 |
@belak:matrix.org | Also, is there anything like deploy-rs's method of automatically rolling back if it determines something is broken? | 22:42:01 |
| 26 Mar 2024 |
| cblacktech joined the room. | 02:03:57 |