colmena
colmena copied to clipboard
`nixd` evaluation
I am trying to make colmena work with nixd for a better IDE experience.
Nixd expects some config specific to each nix project so that it can resolve the attribute sets and support auto completion (see this example for a NixOS config).
I am trying to figure out the colmena equivalent! If I understood nixd correctly, the idea is to return the attribute set of the final config.
colmena eval
does not seem to be any good for this because it returns json, so I am going through the sources trying to instantiate a hive myself.
So far I have this (rough draft, not pinned to colmena version or anything yet):
# file: eval_nixd.nix
with builtins;
let
eval = import (fetchurl "https://github.com/zhaofengli/colmena/raw/main/src/nix/hive/eval.nix");
options_nix = (fetchurl "https://github.com/zhaofengli/colmena/raw/main/src/nix/hive/options.nix");
modules_nix = (fetchurl "https://github.com/zhaofengli/colmena/raw/main/src/nix/hive/modules.nix");
in
eval { rawHive = import ./hive.nix ; colmenaOptions = import options_nix; colmenaModules = import modules_nix; }
// file: nixd json config
"options": {
"enable": true,
"target": {
"args": [
"--expr",
"import ./eval_nixd.nix"
],
}
}
A hive, as returned by eval
, is not the final config with the same structure as the original raw hive.nix. For that I would expect it to have the following top-level attributes: meta
, defaults
, etc... I guess what I want is the final '.options' just like in a normal NixOS config.
Is there even a way to achieve what I am trying to do?