From be193a20572a72a15ffb569aba8eb56fe881c842 Mon Sep 17 00:00:00 2001 From: V Date: Sat, 29 Aug 2020 09:54:02 +0200 Subject: [PATCH 1/2] nixos-rebuild: make 'edit' work with directories $NIXOS_CONFIG can be set to a directory, in which case the file used is $NIXOS_CONFIG/default.nix. This updates 'nixos-rebuild edit' to handle that case correctly. --- nixos/modules/installer/tools/nixos-rebuild.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nixos/modules/installer/tools/nixos-rebuild.sh b/nixos/modules/installer/tools/nixos-rebuild.sh index 437199bae1d..e79cc5e24fb 100644 --- a/nixos/modules/installer/tools/nixos-rebuild.sh +++ b/nixos/modules/installer/tools/nixos-rebuild.sh @@ -288,6 +288,9 @@ fi if [ "$action" = edit ]; then if [[ -z $flake ]]; then NIXOS_CONFIG=${NIXOS_CONFIG:-$(nix-instantiate --find-file nixos-config)} + if [[ -d $NIXOS_CONFIG ]]; then + NIXOS_CONFIG=$NIXOS_CONFIG/default.nix + fi exec "${EDITOR:-nano}" "$NIXOS_CONFIG" else exec nix edit "${lockFlags[@]}" -- "$flake#$flakeAttr" From e08bcdbec3265f701c175ae5ac9d813e10cad292 Mon Sep 17 00:00:00 2001 From: V Date: Sat, 29 Aug 2020 09:54:14 +0200 Subject: [PATCH 2/2] nixos-rebuild: don't quote $EDITOR $EDITOR is allowed to contain flags, so it is important to allow the shell to split this normally. For example, Sublime Text needs to be passed --wait, since otherwise it will daemonise. --- nixos/modules/installer/tools/nixos-rebuild.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/installer/tools/nixos-rebuild.sh b/nixos/modules/installer/tools/nixos-rebuild.sh index e79cc5e24fb..ed9c2509b6b 100644 --- a/nixos/modules/installer/tools/nixos-rebuild.sh +++ b/nixos/modules/installer/tools/nixos-rebuild.sh @@ -291,7 +291,7 @@ if [ "$action" = edit ]; then if [[ -d $NIXOS_CONFIG ]]; then NIXOS_CONFIG=$NIXOS_CONFIG/default.nix fi - exec "${EDITOR:-nano}" "$NIXOS_CONFIG" + exec ${EDITOR:-nano} "$NIXOS_CONFIG" else exec nix edit "${lockFlags[@]}" -- "$flake#$flakeAttr" fi