From 3348feb61390d34db056857ad97226abd0384720 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 20 Nov 2025 00:34:25 -0500 Subject: [PATCH] Add a command to launch a repl of the current flake. --- nix/configuration/flake.nix | 24 ++++++++++++++++++++++++ nix/configuration/repl.nix | 5 +++++ 2 files changed, 29 insertions(+) create mode 100644 nix/configuration/repl.nix diff --git a/nix/configuration/flake.nix b/nix/configuration/flake.nix index af0ac6d9..3b857a9e 100644 --- a/nix/configuration/flake.nix +++ b/nix/configuration/flake.nix @@ -90,6 +90,30 @@ ]; }; } + ( + { + config, + lib, + pkgs, + ... + }: + let + repl_path = toString ./.; + nix-self-repl = pkgs.writeShellScriptBin "nix-self-repl" '' + source /etc/set-environment + nix repl "${repl_path}/repl.nix" "$@" + ''; + # If we wanted the current version of a flake then we'd just launch + # nix repl + # and then run: + # :lf /path/to/flake + in + { + config = { + environment.systemPackages = lib.mkIf config.nix.enable [ nix-self-repl ]; + }; + } + ) ]; } ) nodes; diff --git a/nix/configuration/repl.nix b/nix/configuration/repl.nix new file mode 100644 index 00000000..e21db83b --- /dev/null +++ b/nix/configuration/repl.nix @@ -0,0 +1,5 @@ +let + flake = builtins.getFlake (toString ./.); + nixpkgs = import { }; +in +{ inherit flake; } // flake // builtins // nixpkgs // nixpkgs.lib // flake.nixosConfigurations