Home Explore Blog Models CI



nixpkgs

4th chunk of `pkgs/development/misc/resholve/README.md`
6cd0d28fc8de3f5352d53b107a0453bcd946e614cd6f72580000000100000873
more copies of their specification/behavior than I like, and continuing to
add more at this early date will only ensure that I spend more time updating
docs and less time filling in feature gaps.

Full documentation may be greatly accelerated if someone can help me sort out
single-sourcing. See: https://github.com/abathur/resholve/issues/19
-->

This will hopefully make more sense when you see it. Here are CLI examples
from the manpage, and the Nix equivalents:

```nix
{
  # --fake 'f:setUp;tearDown builtin:setopt source:/etc/bashrc'
  fake = {
    # fake accepts the initial of valid identifier types as a CLI convenience.
    # Use full names in the Nix API.
    function = [
      "setUp"
      "tearDown"
    ];
    builtin = [ "setopt" ];
    source = [ "/etc/bashrc" ];
  };

  # --fix 'aliases $GIT:gix /bin/bash'
  fix = {
    # all single-word directives use `true` as value
    aliases = true;
    "$GIT" = [ "gix" ];
    "/bin/bash" = true;
  };

  # --keep 'source:$HOME /etc/bashrc ~/.bashrc'
  keep = {
    source = [ "$HOME" ];
    "/etc/bashrc" = true;
    "~/.bashrc" = true;
  };
}
```


> **Note:** For now, at least, you'll need to reference the manpage to completely understand these examples.

## Controlling nested resolution with lore

Initially, resolution of commands in the arguments to command-executing
commands was limited to one level for a hard-coded list of builtins and
external commands. resholve can now resolve these recursively.

This feature combines information (_lore_) that the resholve Nix API
obtains via binlore ([nixpkgs](../../tools/analysis/binlore), [repo](https://github.com/abathur/resholve)),
with some rules (internal to resholve) for locating sub-executions in
some of the more common commands.

- "execer" lore identifies whether an executable can, cannot,
  or might execute its arguments. Every "can" or "might" verdict requires:
  - an update to the matching rules in [binlore](https://github.com/abathur/binlore)
    if there's absolutely no exec in the executable and binlore just lacks
    rules for understanding this
  - an override in [binlore](https://github.com/abathur/binlore) if there is

Title: Nix API Examples for `resholve` Directives and Introduction to Nested Resolution with Lore
Summary
This chunk concludes the examples for `resholve` directives in the Nix API, specifically demonstrating the `keep` directive's structure which uses `true` for single-word options and lists for others, mirroring `fake` and `fix` directives. It then introduces `lore`, a new feature that enables recursive resolution of commands within arguments of other commands, a significant expansion from the previous one-level limitation. `lore` integrates 'execer' information from `binlore` (a separate tool) with `resholve`'s internal rules to determine whether an executable can, cannot, or might execute its arguments, requiring corresponding updates or overrides in `binlore` for positive verdicts.