From 727b43478cce8ebbd0f58530878d3af80a3ba233 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Thu, 4 Apr 2024 16:26:25 -0700 Subject: Add `repl-overlays` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a `repl-overlays` option, which specifies files that can overlay and modify the top-level bindings in `nix repl`. For example, with the following contents in `~/.config/nix/repl.nix`: info: final: prev: let optionalAttrs = predicate: attrs: if predicate then attrs else {}; in optionalAttrs (prev ? legacyPackages && prev.legacyPackages ? ${info.currentSystem}) { pkgs = prev.legacyPackages.${info.currentSystem}; } We can run `nix repl` and use `pkgs` to refer to `legacyPackages.${currentSystem}`: $ nix repl --repl-overlays ~/.config/nix/repl.nix nixpkgs Lix 2.90.0 Type :? for help. Loading installable 'flake:nixpkgs#'... Added 5 variables. Loading 'repl-overlays'... Added 6 variables. nix-repl> pkgs.bash «derivation /nix/store/g08b5vkwwh0j8ic9rkmd8mpj878rk62z-bash-5.2p26.drv» Change-Id: Ic12e0f2f210b2f46e920c33088dfe1083f42391a --- src/libcmd/meson.build | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/libcmd/meson.build') diff --git a/src/libcmd/meson.build b/src/libcmd/meson.build index 867508926..b057daa37 100644 --- a/src/libcmd/meson.build +++ b/src/libcmd/meson.build @@ -32,8 +32,13 @@ libcmd_headers = files( 'repl.hh', ) +libcmd_generated_headers = [ + gen_header.process('repl-overlays.nix', preserve_path_from: meson.current_source_dir()), +] + libcmd = library( 'nixcmd', + libcmd_generated_headers, libcmd_sources, dependencies : [ liblixutil, -- cgit v1.2.3