From df2edcba7f8f94c32f7ade8cc00f3431bd40b88a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 5 Nov 2024 17:39:06 +0100 Subject: [PATCH] Ask for config profile in `tmux` --- scripts/lib/action.fish | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/scripts/lib/action.fish b/scripts/lib/action.fish index 98e641a0..d59254c2 100644 --- a/scripts/lib/action.fish +++ b/scripts/lib/action.fish @@ -9,31 +9,34 @@ function runActionSetup -V dir and echo "Preparing nix..." and runHook prepareNix || installNixPkgs - and if [ -z "$CONFIG_NAME" ] - selectProfile config - set -gx CONFIG_NAME "$config" - end - and echo "Flagging repository as safe..." and sudo git config --system --add safe.directory (realpath "$(status dirname)/../..") and runHook actionPreRun || true end +function runActionConfigure + and if [ -z "$CONFIG_NAME" ] + selectProfile config + set -x CONFIG_NAME "$config" + end +end + function disposeAction -V dir source "$dir/hooks.fish" - and sudo git config remove-section --system safe || true + source "$dir/nix.fish" runHook actionPostRun || true + and uninstallNixPkgs + and sudo git config remove-section --system safe || true end function runAction -V dir runActionSetup + and runActionConfigure and $argv and disposeAction end function runSetupUserAction -V dir - source "$dir/nix.fish" - if [ (id -u) -eq 0 ] set -l cmdline (cat /proc/$fish_pid/cmdline | string split0) @@ -42,10 +45,11 @@ function runSetupUserAction -V dir tmux new-session -e "CONFIG_NAME=$CONFIG_NAME" $cmdline else source "$dir/settings.fish" + runActionConfigure set -l sudoConfig "/etc/sudoers.d/PortValhalla" set -l name (getOSConfig setupUser.name) - begin + and begin echo "Creating setup user" and useradd \ @@ -64,7 +68,6 @@ function runSetupUserAction -V dir and sudo --preserve-env --set-home --user "$name" $cmdline disposeAction - uninstallNixPkgs rm "$sudoConfig" userdel -rf "$name" end