!UKDpaKNNsBpOPfLWfX:zhaofeng.li

Colmena

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

Load older messages


SenderMessageTime
3 Feb 2022
@zhaofeng:zhaofeng.liZhaofeng LiIt also provides a clear upgrade path for users using legacy hive.nix to flakes02:17:13
@schnecfk:ruhr-uni-bochum.deCRTified Oh, that explains a lot. In that case, it might be great to document the shim-method that Buckley posted, as it should give "the best of both worlds" 02:17:50
@buckley310:matrix.orgBuckleythere has actually been an update since then as well, i have a custom module to store my deployment options, but you dont actually need that anymore, as the colmena flake exposes its modules as an output now02:18:27
@zhaofeng:zhaofeng.liZhaofeng Li
In reply to @zhaofeng:zhaofeng.li
It also provides a clear upgrade path for users using legacy hive.nix to flakes

Also regarding upgrading to flakes, note that Colmena can auto-call if hive.nix evaluates to a function, allowing you to do things like this:

{ pkgs ? import <nixpkgs> { system = "x86_64-linux"; } }: # or how you pin your nixpkgs
{
  meta = { ... };
}

and importing it like outputs.colmena = import ./hive.nix { pkgs = ...; }; in your flake. You can then deploy with either flake.nix and hive.nix during your transition period.

02:27:38
@zhaofeng:zhaofeng.liZhaofeng Li If the current directory contains both flake.nix and hive.nix, then flake.nix is always preferred 02:28:12
@zhaofeng:zhaofeng.liZhaofeng Li * If the current directory contains both flake.nix and hive.nix, then flake.nix is always preferred if you don't specify a config file explicitly 02:29:39
@schnecfk:ruhr-uni-bochum.deCRTifiedThat iirc fails as I previously imported channels directly all over the place 😅 So my goal is indeed to have a flake config without such a transition configuration 02:33:48
@winterqt:nixos.devWinter (she/her) joined the room.03:46:59
@janejasperous:one.ems.hostJane Jasperous
In reply to @phaer:matrix.org

Jane Jasperous:
Does this work for you?

colmena.my-host = { name, nodes, ... }:
{
   imports = [ self.nixosConfigurations.my-host ];
}; 

(if you get an error that deployment options are undefined, import colmena.nixosModules.deploymentOptions in your nixosConfiguration)

no exactly,
14:27:34
@janejasperous:one.ems.hostJane Jasperous
        deployment.allowLocalDeployment = true;
        nixpkgs.system = self.nixosConfigurations.x2100.config.nixpkgs.system;
        imports = self.nixosConfigurations.x2100.extraArgs.modules ;
      };
14:28:23
@janejasperous:one.ems.hostJane Jasperous *
colmena.node-a = {
        deployment.allowLocalDeployment = true;
        nixpkgs.system = self.nixosConfigurations.x2100.config.nixpkgs.system;
        imports = self.nixosConfigurations.x2100.extraArgs.modules ;
      };

nixosConfigurations.x2100 = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      specialArgs = { inherit inputs; };
      modules = [
          module-a
     ];
};
14:30:17
@janejasperous:one.ems.hostJane Jasperous *
colmena.node-a = {
        deployment.allowLocalDeployment = true;
        nixpkgs.system = self.nixosConfigurations.node-a.config.nixpkgs.system;
        imports = self.nixosConfigurations.node-a.extraArgs.modules ;
      };

nixosConfigurations.node-a = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      specialArgs = { inherit inputs; };
      modules = [
          module-a
     ];
};
14:30:53
@janejasperous:one.ems.hostJane Jasperous *
colmena.node-a = {
        deployment.allowLocalDeployment = true;
        nixpkgs.system = self.nixosConfigurations.node-a.config.nixpkgs.system;
        imports = self.nixosConfigurations.node-a.extraArgs.modules ;
      };

nixosConfigurations.node-a = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      specialArgs = { inherit inputs; };
      modules = [
          module-a
          #inputs.colmena.nixosModules.deploymentOptions
     ];
};
14:31:31
@janejasperous:one.ems.hostJane Jasperousonly this works to me. If I import nixosModules.deploymentOptions and move deployment directive to nixosConfiguration I get this error:14:33:32
@janejasperous:one.ems.hostJane Jasperous error: The option deployment.allowLocalDeployment' in <unknown-file>' is already declared in /nix/store/rz7wzrgh4fpdgab95dgrx46ig2gc2nym-source/flake.nix'.` 14:38:23
@janejasperous:one.ems.hostJane Jasperous * error: The option 'deployment.allowLocalDeployment' in '<unknown-file>' is already declared in '/nix/store/rz7wzrgh4fpdgab95dgrx46ig2gc2nym-source/flake.nix'. 14:38:45
@janejasperous:one.ems.hostJane Jasperous * only this works to me. If I import nixosModules.deploymentOptions and move deployment directive to nixosConfiguration I get this error running colmena apply-local 14:39:27
@janejasperous:one.ems.hostJane Jasperous * only this works to me. If I import nixosModules.deploymentOptions and move deployment directive to nixosConfiguration I get this error running colmena apply-local 14:39:46
@pacien:pacien.netNotkea joined the room.15:15:09
@janejasperous:one.ems.hostJane JasperousIm also realize while playing with colmena/nixosConfigurations outputs that colmena are impure builds. Is there some option to force pure builds??15:35:17
@winterqt:nixos.devWinter (she/her)
In reply to @janejasperous:one.ems.host
Im also realize while playing with colmena/nixosConfigurations outputs that colmena are impure builds. Is there some option to force pure builds??
there isn't, but you can just remove this line: https://github.com/zhaofengli/colmena/blob/f674ddf1739aa79ac9dcad38771cc89c662eaa6a/src/nix/evaluator/nix_eval_jobs.rs#L84
16:42:07
@winterqt:nixos.devWinter (she/her)but i'm curious why impure is passed by default, i only see it mentioned there and in a test, cc Zhaofeng Li16:42:30
@pacien:pacien.netNotkea hello, is it possible to define specialArgs per node? I'd like to "inject" some attributes which depend on different values of system 16:58:07
@zhaofeng:zhaofeng.liZhaofeng Li
In reply to @pacien:pacien.net
hello, is it possible to define specialArgs per node? I'd like to "inject" some attributes which depend on different values of system
Apart from specialArgs, there are also normal arguments. For example, you can set the _module.args.someArg option in node configs.
18:35:56
@zhaofeng:zhaofeng.liZhaofeng Li
In reply to @winterqt:nixos.dev
but i'm curious why impure is passed by default, i only see it mentioned there and in a test, cc Zhaofeng Li
Currently, there is an eval.nix that takes a normal hive.nix or a flake URI, evaluated in a normal impure context. If a flake URI is passed, then it's fetched using builtins.getFlake.
18:40:37
@pacien:pacien.netNotkea
In reply to @zhaofeng:zhaofeng.li
Apart from specialArgs, there are also normal arguments. For example, you can set the _module.args.someArg option in node configs.

thank you, that works!

By the way, what is meta.nixpkgs used for? Which system should be set for importing nixpkgs there? Should it match the platform of the machine running colmena?

18:42:23
@zhaofeng:zhaofeng.liZhaofeng Li
In reply to @pacien:pacien.net

thank you, that works!

By the way, what is meta.nixpkgs used for? Which system should be set for importing nixpkgs there? Should it match the platform of the machine running colmena?

It should be the platform that you are deploying to, not the one running Colmena itself.
18:44:26
@pacien:pacien.netNotkea ok! I'm setting this with nodeNixpkgs explicitly for each node. Would it be possible to make nixpkgs not mandatory in this case? 18:47:11
@zhaofeng:zhaofeng.liZhaofeng Li
In reply to @pacien:pacien.net
ok! I'm setting this with nodeNixpkgs explicitly for each node. Would it be possible to make nixpkgs not mandatory in this case?
Sadly not, because we still rely on some helper functions from lib of the top-level pinned nixpkgs. We could use the ones from an arbitrary nodeNixpkgs but it doesn't seem ideal.
18:51:19
@zhaofeng:zhaofeng.liZhaofeng Li
In reply to @winterqt:nixos.dev
but i'm curious why impure is passed by default, i only see it mentioned there and in a test, cc Zhaofeng Li
*

Currently, there is an eval.nix that takes a normal hive.nix or a flake URI, evaluated in a normal impure context. If a flake URI is passed, then it's fetched using builtins.getFlake.

And this setup (importing a file outside of a flake context) sadly doesn't work in pure evaluation.

18:53:26

Show newer messages


Back to Room ListRoom Version: 6