Skip to content

Commit

Permalink
nixos-rebuild: add edit command
Browse files Browse the repository at this point in the history
  • Loading branch information
LnL7 committed Feb 24, 2019
1 parent a1c295e commit 49c4d61
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion nixos/modules/installer/tools/nixos-rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ while [ "$#" -gt 0 ]; do
--help)
showSyntax
;;
switch|boot|test|build|dry-build|dry-run|dry-activate|build-vm|build-vm-with-bootloader)
switch|boot|test|build|edit|dry-build|dry-run|dry-activate|build-vm|build-vm-with-bootloader)
if [ "$i" = dry-run ]; then i=dry-build; fi
action="$i"
;;
Expand Down Expand Up @@ -227,6 +227,13 @@ if [ -z "$_NIXOS_REBUILD_REEXEC" -a -n "$canRun" -a -z "$fast" ]; then
fi
fi

# Find configuration.nix and open editor instead of building.
if [ "$action" = edit ]; then
NIXOS_CONFIG=${NIXOS_CONFIG:-$(nix-instantiate --find-file nixos-config)}
exec "${EDITOR:-nano}" "$NIXOS_CONFIG"
exit 1
fi


tmpDir=$(mktemp -t -d nixos-rebuild.XXXXXX)
SSHOPTS="$NIX_SSHOPTS -o ControlMaster=auto -o ControlPath=$tmpDir/ssh-%n -o ControlPersist=60"
Expand Down

0 comments on commit 49c4d61

Please sign in to comment.