aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorrebecca “wiggles” turner <rbt@sent.as>2024-04-09 05:29:48 +0000
committerGerrit Code Review <gerrit@lix>2024-04-09 05:29:48 +0000
commita95c62673b06813632b5cf487519fb535e47a2b3 (patch)
treeb1442451fd5d845809c29e325e5fa4c6d301ee1c /src/libexpr
parentb0293f2de18f4b91d64cb18e969ddf886dc7def1 (diff)
parent727b43478cce8ebbd0f58530878d3af80a3ba233 (diff)
Merge "Add `repl-overlays`" into main
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval-settings.hh36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/libexpr/eval-settings.hh b/src/libexpr/eval-settings.hh
index c264b521f..98fe6881e 100644
--- a/src/libexpr/eval-settings.hh
+++ b/src/libexpr/eval-settings.hh
@@ -125,6 +125,42 @@ struct EvalSettings : Config
This is useful for debugging warnings in third-party Nix code.
)"};
+
+ PathsSetting replOverlays{this, Paths(), "repl-overlays",
+ R"(
+ A list of files containing Nix expressions that can be used to add
+ default bindings to [`nix
+ repl`](@docroot@/command-ref/new-cli/nix3-repl.md) sessions.
+
+ Each file is called with three arguments:
+ 1. An [attribute set](@docroot@/language/values.html#attribute-set)
+ containing at least a
+ [`currentSystem`](@docroot@/language/builtin-constants.md#builtins-currentSystem)
+ attribute (this is identical to
+ [`builtins.currentSystem`](@docroot@/language/builtin-constants.md#builtins-currentSystem),
+ except that it's available in
+ [`pure-eval`](@docroot@/command-ref/conf-file.html#conf-pure-eval)
+ mode).
+ 2. The top-level bindings produced by the previous `repl-overlays`
+ value (or the default top-level bindings).
+ 3. The final top-level bindings produced by calling all
+ `repl-overlays`.
+
+ For example, the following file would alias `pkgs` to
+ `legacyPackages.${info.currentSystem}` (if that attribute is defined):
+
+ ```nix
+ info: final: prev:
+ if prev ? legacyPackages
+ && prev.legacyPackages ? ${info.currentSystem}
+ then
+ {
+ pkgs = prev.legacyPackages.${info.currentSystem};
+ }
+ else
+ { }
+ ```
+ )"};
};
extern EvalSettings evalSettings;