Add a nix-flake-repl script.
This commit is contained in:
38
nix/configuration/roles/nix_repl/default.nix
Normal file
38
nix/configuration/roles/nix_repl/default.nix
Normal file
@@ -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
|
||||
];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user