Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixd evaluation #182

Open
Cottand opened this issue Nov 3, 2023 · 0 comments
Open

nixd evaluation #182

Cottand opened this issue Nov 3, 2023 · 0 comments

Comments

@Cottand
Copy link

Cottand commented Nov 3, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant