From 70f3ae6894e6136b52c152fb82077f499d228fb3 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 1 Jan 2026 10:52:00 -0500 Subject: [PATCH] Add a nix-flake-repl script. --- nix/configuration/configuration.nix | 1 + nix/configuration/flake.nix | 49 -------------------- nix/configuration/hosts/odo/default.nix | 1 + nix/configuration/hosts/odowork/default.nix | 1 + nix/configuration/hosts/quark/default.nix | 1 + nix/configuration/roles/nix_repl/default.nix | 38 +++++++++++++++ 6 files changed, 42 insertions(+), 49 deletions(-) create mode 100644 nix/configuration/roles/nix_repl/default.nix diff --git a/nix/configuration/configuration.nix b/nix/configuration/configuration.nix index b2657bf9..11eb2d93 100644 --- a/nix/configuration/configuration.nix +++ b/nix/configuration/configuration.nix @@ -54,6 +54,7 @@ ./roles/minimal_base ./roles/network ./roles/nix_index + ./roles/nix_repl ./roles/nix_worker ./roles/nixdev ./roles/nvme diff --git a/nix/configuration/flake.nix b/nix/configuration/flake.nix index 85b6552e..b75d8819 100644 --- a/nix/configuration/flake.nix +++ b/nix/configuration/flake.nix @@ -1,6 +1,3 @@ -# Get a repl for this flake -# nix repl --expr "builtins.getFlake \"$PWD\"" - # TODO maybe use `nix eval --raw .#odo.iso.outPath` # @@ -93,29 +90,6 @@ ]; }; } - ( - { - config, - lib, - pkgs, - ... - }: - let - nix-self-repl = pkgs.writeShellScriptBin "nix-self-repl" '' - source /etc/set-environment - nix repl --expr 'builtins.getFlake "${self}"' - ''; - # 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; @@ -127,29 +101,6 @@ }; modules = [ ./formats/installer.nix - ( - { - config, - lib, - pkgs, - ... - }: - let - nix-self-repl = pkgs.writeShellScriptBin "nix-self-repl" '' - source /etc/set-environment - nix repl --expr 'builtins.getFlake "${self}"' - ''; - # 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 ]; - }; - } - ) ({ nixpkgs.hostPlatform.system = nodeConfig.system; }) ]; }; diff --git a/nix/configuration/hosts/odo/default.nix b/nix/configuration/hosts/odo/default.nix index 3b760bec..62622617 100644 --- a/nix/configuration/hosts/odo/default.nix +++ b/nix/configuration/hosts/odo/default.nix @@ -114,6 +114,7 @@ me.memtest.enable = true; me.network.enable = true; me.nix_index.enable = true; + me.nix_repl.enable = true; me.nixdev.enable = true; me.nvme.enable = true; me.openpgp_card_tools.enable = true; diff --git a/nix/configuration/hosts/odowork/default.nix b/nix/configuration/hosts/odowork/default.nix index 0ca2c62b..9b2922b5 100644 --- a/nix/configuration/hosts/odowork/default.nix +++ b/nix/configuration/hosts/odowork/default.nix @@ -115,6 +115,7 @@ me.memtest.enable = true; me.network.enable = true; me.nix_index.enable = true; + me.nix_repl.enable = true; me.nixdev.enable = true; me.nvme.enable = true; me.openpgp_card_tools.enable = true; diff --git a/nix/configuration/hosts/quark/default.nix b/nix/configuration/hosts/quark/default.nix index 238607e8..2665fa6a 100644 --- a/nix/configuration/hosts/quark/default.nix +++ b/nix/configuration/hosts/quark/default.nix @@ -108,6 +108,7 @@ me.memtest.enable = true; me.network.enable = true; me.nix_index.enable = true; + me.nix_repl.enable = true; me.nix_worker.enable = true; me.nixdev.enable = true; me.nvme.enable = true; diff --git a/nix/configuration/roles/nix_repl/default.nix b/nix/configuration/roles/nix_repl/default.nix new file mode 100644 index 00000000..1fea995c --- /dev/null +++ b/nix/configuration/roles/nix_repl/default.nix @@ -0,0 +1,38 @@ +{ + config, + lib, + pkgs, + self, + ... +}: + +let + nix-flake-repl = pkgs.writeShellScriptBin "nix-flake-repl" '' + source /etc/set-environment + target="''${1:-$(pwd)}" + nix repl --expr "builtins.getFlake \"''$target\"" + ''; + nix-self-repl = pkgs.writeShellScriptBin "nix-self-repl" '' + source /etc/set-environment + nix repl --expr 'builtins.getFlake "${self}"' + ''; +in +{ + imports = [ ]; + + options.me = { + nix_repl.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install nix_repl."; + }; + }; + + config = lib.mkIf config.me.nix_repl.enable { + environment.systemPackages = [ + nix-flake-repl + nix-self-repl + ]; + }; +}