Ask for config profile in tmux

This commit is contained in:
Manuel Thalmann 2024-11-05 17:39:06 +01:00
parent 4042481c51
commit 15f58e4daa

View file

@ -9,31 +9,34 @@ function runActionSetup -V dir
and echo "Preparing nix..." and echo "Preparing nix..."
and runHook prepareNix || installNixPkgs and runHook prepareNix || installNixPkgs
and if [ -z "$CONFIG_NAME" ]
selectProfile config
set -gx CONFIG_NAME "$config"
end
and echo "Flagging repository as safe..." and echo "Flagging repository as safe..."
and sudo git config --system --add safe.directory (realpath "$(status dirname)/../..") and sudo git config --system --add safe.directory (realpath "$(status dirname)/../..")
and runHook actionPreRun || true and runHook actionPreRun || true
end end
function runActionConfigure
and if [ -z "$CONFIG_NAME" ]
selectProfile config
set -x CONFIG_NAME "$config"
end
end
function disposeAction -V dir function disposeAction -V dir
source "$dir/hooks.fish" source "$dir/hooks.fish"
and sudo git config remove-section --system safe || true source "$dir/nix.fish"
runHook actionPostRun || true runHook actionPostRun || true
and uninstallNixPkgs
and sudo git config remove-section --system safe || true
end end
function runAction -V dir function runAction -V dir
runActionSetup runActionSetup
and runActionConfigure
and $argv and $argv
and disposeAction and disposeAction
end end
function runSetupUserAction -V dir function runSetupUserAction -V dir
source "$dir/nix.fish"
if [ (id -u) -eq 0 ] if [ (id -u) -eq 0 ]
set -l cmdline (cat /proc/$fish_pid/cmdline | string split0) 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 tmux new-session -e "CONFIG_NAME=$CONFIG_NAME" $cmdline
else else
source "$dir/settings.fish" source "$dir/settings.fish"
runActionConfigure
set -l sudoConfig "/etc/sudoers.d/PortValhalla" set -l sudoConfig "/etc/sudoers.d/PortValhalla"
set -l name (getOSConfig setupUser.name) set -l name (getOSConfig setupUser.name)
begin and begin
echo "Creating setup user" echo "Creating setup user"
and useradd \ and useradd \
@ -64,7 +68,6 @@ function runSetupUserAction -V dir
and sudo --preserve-env --set-home --user "$name" $cmdline and sudo --preserve-env --set-home --user "$name" $cmdline
disposeAction disposeAction
uninstallNixPkgs
rm "$sudoConfig" rm "$sudoConfig"
userdel -rf "$name" userdel -rf "$name"
end end