Skip to content

hive.introspect feels like weird control inversion #266

@Radvendii

Description

@Radvendii

in src/hive/eval.nix, we have defined in the output

{
  ...
  introspect = f: f { inherit lib; pkgs = nixpkgs; nodes = uncheckedNodes; };
}

Which feels like a weird control-passing-style inversion of

{
  ...
  introspect_args = { inherit lib; pkgs = nixpkgs; nodes = uncheckedNodes; };
}

or even adding at the top level (nodes is already taken)

{
  ...
  inherit lib uncheckedNodes;
  pkgs = nixpkgs;
}

It's much easier to take the data passed back in that way and feed it into a function

(colmena.makeHive hive).introspect f

becomes

f (colmena.makeHive hive).introspect_args

or

let hive = (colmena.makeHive hive); in
f { inherit (hive) pkgs lib; nodes = hive.uncheckedNodes; }

versus trying to get those arguments out when all we have is the introspect function:

let
  hive = (colmena.makeHive hive);
  inherit (hive) pkgs lib uncheckedNodes;
in
<body>

becomes either

(colmena.makeHive hive).introspect ({lib, pkgs, nodes}:
<body>
) # gotta remember to close our function

or

let
  hive = colmena.makeHive hive;
  lib = hive.introspect ( { lib, ... }: lib);
  pkgs = hive.introspect ( { pkgs, ... }: pkgs);
  nodes = hive.introspect ( {nodes, ... }: nodes);
in
<body>

We could also keep providing introspect, and additionally provide pkgs, lib, uncheckedNodes as additional outputs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions