!UKDpaKNNsBpOPfLWfX:zhaofeng.li

Colmena

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

Load older messages


SenderMessageTime
2 Sep 2022
@linus:schreibt.jetztLinux Hackermandefining modules that have the entire deployment as their scope instead of an individual host is 😘🤌18:49:15
@yuka:yuka.dev@yuka:yuka.devdefinitely, but I'd like to not mix up multiple issues/improvements too much18:49:49
@linus:schreibt.jetztLinux Hackermanyeah. I'm also not sure that should be colmena's responsibility.18:50:11
@yuka:yuka.dev@yuka:yuka.devhttps://github.com/yu-re-ka/colmena/commit/cd558fee7f4251719d1101f9677dce2581f6f58e19:19:20
@yuka:yuka.dev@yuka:yuka.devThis is enough changes to make it work for me19:19:34
@yuka:yuka.dev@yuka:yuka.dev

In my flake, I now do:

  outputs = { self, nixpkgs, colmena, ... }@inputs: {
    colmenaEval = colmena.evalHive {
      # whatever was in outputs.colmena before
    };
    nixosConfigurations = self.outputs.colmenaEval.nodes;
  };
20:11:45
@yuka:yuka.dev@yuka:yuka.devthough somehow it does not like to do pure eval20:12:14
@zhaofeng:zhaofeng.liZhaofeng Li Yeah, if the git repo is dirty, nix flake metadata will not return a locked flake URI that's usable in pure evaluation mode. That's one gotcha I encountered when looking into pure eval. 20:13:32
@yuka:yuka.dev@yuka:yuka.devDoes the assets wrapper flake solve this?20:14:10
@zhaofeng:zhaofeng.liZhaofeng LiYes, the locked URI of the assets flake encompasses the inputs as well.20:16:01
@zhaofeng:zhaofeng.liZhaofeng LiYour solution should work if the git repo is clean20:16:35
@yuka:yuka.dev@yuka:yuka.dev
In reply to @zhaofeng:zhaofeng.li
Yes, the locked URI of the assets flake encompasses the inputs as well.
also if it is a dirty git repo
20:16:50
@yuka:yuka.dev@yuka:yuka.dev
In reply to @zhaofeng:zhaofeng.li
Yes, the locked URI of the assets flake encompasses the inputs as well.
* also if one of the inputs is a dirty git repo?
20:16:56
@yuka:yuka.dev@yuka:yuka.devI mean it would be neat if I could also use --override-input etc. with colmena20:17:16
@zhaofeng:zhaofeng.liZhaofeng Li* Yeah, if the git repo is dirty, `nix flake metadata` will not return a locked flake URI (with the `narHash` query parameter) that's usable in pure evaluation mode. That's one gotcha I encountered when looking into pure eval.20:21:04
@yuka:yuka.dev@yuka:yuka.dev
In reply to @linus:schreibt.jetzt

I'm currently doing a hack like

    nixosConfigurations = lib.mapAttrs (name: config: let
      nodeNixpkgs = self.outputs.colmena.meta.nodeNixpkgs.${name} or self.outputs.colmena.meta.nixpkgs;
      nodeNixos = import (nodeNixpkgs.path + "/nixos/lib/eval-config.nix");
      in nodeNixos {
        modules = [
          self.outputs.colmena.defaults
          config
          inputs.colmena.nixosModules.deploymentOptions
          {
            _module.args.name = name;
            _module.args.nodes = self.outputs.nixosConfigurations;
            nixpkgs.overlays = [ nodeNixpkgs.lib.flakeOverlay (import ./overlay.nix) ];
          }
        ];
        inherit (nodeNixpkgs) system;
      }
    ) (builtins.removeAttrs self.outputs.colmena ["meta" "defaults"]);

to be able to get at least an approximation of the configs (enough to be able to build it in hydra, for example)

there is a way easier thing to do this
20:48:11
@yuka:yuka.dev@yuka:yuka.devthat doesn't need any changes to colmena20:48:20
@yuka:yuka.dev@yuka:yuka.dev

    nixosConfigurations = (import (inputs.colmena + "/src/nix/hive/eval.nix") {
      rawFlake = self;
      colmenaOptions = import (inputs.colmena + "/src/nix/hive/options.nix");
      colmenaModules = import (inputs.colmena + "/src/nix/hive/modules.nix");
    }).nodes;
20:48:36
@yuka:yuka.dev@yuka:yuka.dev *
    nixosConfigurations = (import (inputs.colmena + "/src/nix/hive/eval.nix") {
      rawFlake = self;
      colmenaOptions = import (inputs.colmena + "/src/nix/hive/options.nix");
      colmenaModules = import (inputs.colmena + "/src/nix/hive/modules.nix");
    }).nodes;
20:48:43
@yuka:yuka.dev@yuka:yuka.devAnd now I don't actually mind that colmena magically adds these expressions, because I will just keep using the colmena binary pinned in my flake inputs, so I know that colmena uses the exact same hive expression as my nixosConfigurations shim20:49:34
@linus:schreibt.jetztLinux Hackermanthat is nicer. Thanks20:50:36
@yuka:yuka.dev@yuka:yuka.devCan any of the evaluators take advantage of the eval cache?21:05:54
@linus:schreibt.jetztLinux Hackermanthe eval cache requires pure evaluation, so AFAIU no currently21:06:19
@linus:schreibt.jetztLinux Hackermanbut I might have missed something on the development of pure evaluation21:06:28
@linus:schreibt.jetztLinux Hackermanif pure evaluation is working, it should use the eval cache as well21:06:46
@yuka:yuka.dev@yuka:yuka.devcolmena does use pure evaluation mode21:07:25
@yuka:yuka.dev@yuka:yuka.devbut nix-instantiate as entry point, not nix build21:07:41
@yuka:yuka.dev@yuka:yuka.dev nix-instantiate -E ... builtins.getFlake .... 21:07:56
@yuka:yuka.dev@yuka:yuka.dev * nix-instantiate -E '... builtins.getFlake ....' 21:08:02
@linus:schreibt.jetztLinux Hackermanaah. I don't think so then. Not sure though.21:08:16

Show newer messages


Back to Room ListRoom Version: 6