Merge pull request #300335 from amarshall/nixos-rebuild-repl-path
nixos-rebuild: Fix `repl` with a relative flake path
This commit is contained in:
commit
9ffe63c6fa
@ -559,11 +559,16 @@ if [ "$action" = repl ]; then
|
||||
blue="$(echo -e '\033[34;1m')"
|
||||
attention="$(echo -e '\033[35;1m')"
|
||||
reset="$(echo -e '\033[0m')"
|
||||
if [[ -e $flake ]]; then
|
||||
flakePath=$(realpath "$flake")
|
||||
else
|
||||
flakePath=$flake
|
||||
fi
|
||||
# This nix repl invocation is impure, because usually the flakeref is.
|
||||
# For a solution that preserves the motd and custom scope, we need
|
||||
# something like https://github.com/NixOS/nix/issues/8679.
|
||||
exec nix repl --impure --expr "
|
||||
let flake = builtins.getFlake ''$flake'';
|
||||
let flake = builtins.getFlake ''$flakePath'';
|
||||
configuration = flake.$flakeAttr;
|
||||
motd = ''
|
||||
$d{$q\n$q}
|
||||
|
@ -113,7 +113,7 @@ runCommand "test-nixos-rebuild-repl" {
|
||||
|
||||
# cat -n ~/flake.nix
|
||||
|
||||
expect ${writeText "test-nixos-rebuild-repl-expect" ''
|
||||
expect ${writeText "test-nixos-rebuild-repl-absolute-path-expect" ''
|
||||
${expectSetup}
|
||||
spawn sh -c "nixos-rebuild repl --fast --flake path:\$HOME#testconf"
|
||||
|
||||
@ -138,6 +138,19 @@ runCommand "test-nixos-rebuild-repl" {
|
||||
send "lib?nixos\n"
|
||||
expect_simple "true"
|
||||
''}
|
||||
|
||||
pushd "$HOME"
|
||||
expect ${writeText "test-nixos-rebuild-repl-relative-path-expect" ''
|
||||
${expectSetup}
|
||||
spawn sh -c "nixos-rebuild repl --fast --flake .#testconf"
|
||||
|
||||
expect_simple "nix-repl>"
|
||||
|
||||
send "config.networking.hostName\n"
|
||||
expect_simple "itsme"
|
||||
''}
|
||||
popd
|
||||
|
||||
echo
|
||||
|
||||
#########
|
||||
|
Loading…
Reference in New Issue
Block a user