From 4504ca85d44063338b08331fb3d2db90ba1e7593 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 12 Oct 2024 01:54:31 +0200 Subject: [PATCH] Add function for inheriting `fish` installers --- scripts/Arch/Software/Firefox/main.fish | 5 +---- scripts/Arch/Software/GRUB/main.fish | 3 +-- scripts/Arch/Software/Oh My Posh/main.fish | 10 +-------- scripts/Arch/Software/PowerShell/main.fish | 5 +---- .../Virtual Machine Manager/main.fish | 10 +++------ scripts/Arch/Software/aliae/main.fish | 10 +-------- scripts/Arch/Software/brave/main.fish | 5 +---- scripts/Arch/Software/docker/main.fish | 10 +-------- scripts/Arch/Software/git/main.fish | 10 +-------- scripts/Arch/Software/logo-ls/main.fish | 5 +---- .../Arch/Software/minegrub-theme/main.fish | 5 +---- scripts/Arch/Software/nix/main.fish | 3 ++- scripts/Arch/Software/nvidia-dkms/main.fish | 3 ++- scripts/Arch/Software/pyenv/main.fish | 5 +---- scripts/Arch/Software/rclone/main.fish | 10 +-------- scripts/Arch/Software/vim/main.fish | 6 +---- scripts/Arch/Software/zoxide/main.fish | 5 +---- scripts/Common/Scripts/software.fish | 22 +++++++++++++++++++ scripts/Common/Software/Oh My Posh/main.fish | 9 ++++---- scripts/Common/Software/git/main.fish | 9 ++++---- 20 files changed, 53 insertions(+), 97 deletions(-) diff --git a/scripts/Arch/Software/Firefox/main.fish b/scripts/Arch/Software/Firefox/main.fish index 9719cbd8..70c4217b 100755 --- a/scripts/Arch/Software/Firefox/main.fish +++ b/scripts/Arch/Software/Firefox/main.fish @@ -2,14 +2,11 @@ begin set -l dir (status dirname) source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/Firefox/main.fish" function installSW -V dir yayinst firefox end - function configureSW -V dir - fish "$dir/../../../Common/Software/Firefox/main.fish" configure - end - runInstaller $argv end diff --git a/scripts/Arch/Software/GRUB/main.fish b/scripts/Arch/Software/GRUB/main.fish index fb9549aa..0db35958 100755 --- a/scripts/Arch/Software/GRUB/main.fish +++ b/scripts/Arch/Software/GRUB/main.fish @@ -2,14 +2,13 @@ begin set -l dir (status dirname) source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/GRUB/main.fish" function installSW -V dir pacinst \ grub \ efibootmgr \ os-prober - - fish "$dir/../../../Common/Software/GRUB/main.fish" configure end runInstaller $argv diff --git a/scripts/Arch/Software/Oh My Posh/main.fish b/scripts/Arch/Software/Oh My Posh/main.fish index f2a697ad..7641fffd 100755 --- a/scripts/Arch/Software/Oh My Posh/main.fish +++ b/scripts/Arch/Software/Oh My Posh/main.fish @@ -1,20 +1,12 @@ #!/bin/env fish begin set -l dir (status dirname) - set -l base "$dir/../../../Common/Software/Oh My Posh/main.fish" source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/Oh My Posh/main.fish" function installSW yayinst oh-my-posh-bin end - function configureSW -V base - fish "$base" configure - end - - function userConfig -S -V base -a name - fish "$base" userConfig $argv - end - runInstaller $argv end diff --git a/scripts/Arch/Software/PowerShell/main.fish b/scripts/Arch/Software/PowerShell/main.fish index 03c6f180..04b9379e 100755 --- a/scripts/Arch/Software/PowerShell/main.fish +++ b/scripts/Arch/Software/PowerShell/main.fish @@ -2,14 +2,11 @@ begin set -l dir (status dirname) source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/PowerShell/main.fish" function installSW yayinst powershell-bin end - function configureSW -V dir - fish "$dir/../../../Common/Software/PowerShell/main.fish" configure - end - runInstaller $argv end diff --git a/scripts/Arch/Software/Virtual Machine Manager/main.fish b/scripts/Arch/Software/Virtual Machine Manager/main.fish index 774a4246..10e37547 100755 --- a/scripts/Arch/Software/Virtual Machine Manager/main.fish +++ b/scripts/Arch/Software/Virtual Machine Manager/main.fish @@ -1,8 +1,8 @@ #!/bin/env fish begin set -l dir (status dirname) - set -l base "$dir/../../../Common/Software/Virtual Machine Manager/main.fish" source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/Virtual Machine Manager/main.fish" function installSW yayinst qemu-full @@ -17,14 +17,10 @@ begin virt-bootstrap-git end - function configureSW -V base + function configureSW sudo systemctl enable --now libvirtd sudo systemctl enable --now virtlogd - fish "$base" configure - end - - function userConfig -V base - fish "$base" userConfig $argv + configureSWBase $argv end runInstaller $argv diff --git a/scripts/Arch/Software/aliae/main.fish b/scripts/Arch/Software/aliae/main.fish index 9ccd4568..172049d3 100755 --- a/scripts/Arch/Software/aliae/main.fish +++ b/scripts/Arch/Software/aliae/main.fish @@ -1,21 +1,13 @@ #!/bin/env fish begin set -l dir (status dirname) - set -l base "$dir/../../../Common/Software/aliae/main.fish" source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/aliae/main.fish" function installSW yayinst \ aliae-bin end - function configureSW -V base - fish "$base" configure - end - - function userConfig -V base - fish "$base" userConfig $argv - end - runInstaller $argv end diff --git a/scripts/Arch/Software/brave/main.fish b/scripts/Arch/Software/brave/main.fish index fe7bc672..ddcb60d7 100755 --- a/scripts/Arch/Software/brave/main.fish +++ b/scripts/Arch/Software/brave/main.fish @@ -2,6 +2,7 @@ begin set -l dir (status dirname) source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/brave/main.fish" function installSW yayinst brave-bin ( @@ -10,9 +11,5 @@ begin ) end - function configureSW -V dir - fish "$dir/../../../Common/Software/brave/main.fish" configure - end - runInstaller $argv end diff --git a/scripts/Arch/Software/docker/main.fish b/scripts/Arch/Software/docker/main.fish index 8fbd845d..ca1197eb 100755 --- a/scripts/Arch/Software/docker/main.fish +++ b/scripts/Arch/Software/docker/main.fish @@ -1,8 +1,8 @@ #!/bin/env fish begin set -l dir (status dirname) - set -l base "$dir/../../../Common/Software/docker/main.fish" source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/docker/main.fish" function installSW yayinst \ @@ -12,13 +12,5 @@ begin docker-scan end - function configureSW -V base - fish "$base" configure - end - - function userConfig -V base - fish "$base" userConfig $argv - end - runInstaller $argv end diff --git a/scripts/Arch/Software/git/main.fish b/scripts/Arch/Software/git/main.fish index 929ce2c6..31f2feec 100755 --- a/scripts/Arch/Software/git/main.fish +++ b/scripts/Arch/Software/git/main.fish @@ -1,8 +1,8 @@ #!/bin/env fish begin set -l dir (status dirname) - set -l base "$dir/../../../Common/Software/git/main.fish" source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/git/main.fish" function installSW yayinst \ @@ -14,13 +14,5 @@ begin gitflow-zshcompletion-avh end - function configureSW -V base - fish "$base" configure - end - - function userConfig -V base - fish "$base" userConfig $argv - end - runInstaller $argv end diff --git a/scripts/Arch/Software/logo-ls/main.fish b/scripts/Arch/Software/logo-ls/main.fish index d2ac72ac..dfeefa5c 100755 --- a/scripts/Arch/Software/logo-ls/main.fish +++ b/scripts/Arch/Software/logo-ls/main.fish @@ -2,6 +2,7 @@ begin set -l dir (status dirname) source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/logo-ls/main.fish" function installSW -V dir set -l dirName (realpath "$dir") @@ -34,9 +35,5 @@ begin end end - function configureSW -V dir - fish "$dir/../../../Common/Software/logo-ls/main.fish" configure - end - runInstaller $argv end diff --git a/scripts/Arch/Software/minegrub-theme/main.fish b/scripts/Arch/Software/minegrub-theme/main.fish index dcf0ed35..9f924681 100755 --- a/scripts/Arch/Software/minegrub-theme/main.fish +++ b/scripts/Arch/Software/minegrub-theme/main.fish @@ -2,14 +2,11 @@ begin set -l dir (status dirname) source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/minegrub-theme/main.fish" function installSW yayinst grub-theme-minegrub-git end - function configureSW -V dir - fish "$dir/../../../Common/Software/minegrub-theme/main.fish" configure - end - runInstaller $argv end diff --git a/scripts/Arch/Software/nix/main.fish b/scripts/Arch/Software/nix/main.fish index 2b91ff25..f20c6783 100755 --- a/scripts/Arch/Software/nix/main.fish +++ b/scripts/Arch/Software/nix/main.fish @@ -2,6 +2,7 @@ begin set -l dir (status dirname) source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/nix/main.fish" function installSW yayinst \ @@ -13,7 +14,7 @@ begin function configureSW -V dir sudo systemctl enable --now nix-daemon - fish "$dir/../../../Common/Software/nix/main.fish" configure + configureSWBase configure $argv end runInstaller $argv diff --git a/scripts/Arch/Software/nvidia-dkms/main.fish b/scripts/Arch/Software/nvidia-dkms/main.fish index 0af2efc2..f1d101f6 100755 --- a/scripts/Arch/Software/nvidia-dkms/main.fish +++ b/scripts/Arch/Software/nvidia-dkms/main.fish @@ -2,6 +2,7 @@ begin set -l dir (status dirname) source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/nvidia-dkms/main.fish" function installSW yayinst \ @@ -21,7 +22,7 @@ begin done end | sudo tee /etc/mkinitcpio.conf.d/nvidia.conf >/dev/null - fish "$dir/../../../Common/Software/nvidia-dkms/main.fish" configure + configureSWBase $argv end runInstaller $argv diff --git a/scripts/Arch/Software/pyenv/main.fish b/scripts/Arch/Software/pyenv/main.fish index a1646e40..99bcaffe 100755 --- a/scripts/Arch/Software/pyenv/main.fish +++ b/scripts/Arch/Software/pyenv/main.fish @@ -2,14 +2,11 @@ begin set -l dir (status dirname) source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/pyenv/main.fish" function installSW yayinst pyenv end - function configureSW -V dir - fish "$dir/../../../Common/Software/pyenv/main.fish" configure - end - runInstaller $argv end diff --git a/scripts/Arch/Software/rclone/main.fish b/scripts/Arch/Software/rclone/main.fish index 9f138d65..4650961b 100755 --- a/scripts/Arch/Software/rclone/main.fish +++ b/scripts/Arch/Software/rclone/main.fish @@ -1,21 +1,13 @@ #!/bin/env fish begin set -l dir (status dirname) - set -l base "$dir/../../../Common/Software/rclone/main.fish" source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/rclone/main.fish" function installSW yayinst \ rclone end - function configureSW -V base - fish "$base" configure - end - - function userConfig -V base -a name - fish "$base" userConfig $argv - end - runInstaller $argv end diff --git a/scripts/Arch/Software/vim/main.fish b/scripts/Arch/Software/vim/main.fish index f2c5037c..53c4435e 100755 --- a/scripts/Arch/Software/vim/main.fish +++ b/scripts/Arch/Software/vim/main.fish @@ -2,6 +2,7 @@ begin set -l dir (status dirname) source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/vim/main.fish" function installSW yayinst ( @@ -13,10 +14,5 @@ begin wl-clipboard end - - function configureSW -V dir - fish "$dir/../../../Common/Software/vim/main.fish" configure - end - runInstaller $argv end diff --git a/scripts/Arch/Software/zoxide/main.fish b/scripts/Arch/Software/zoxide/main.fish index 84f3f60e..47ad6d9d 100755 --- a/scripts/Arch/Software/zoxide/main.fish +++ b/scripts/Arch/Software/zoxide/main.fish @@ -2,15 +2,12 @@ begin set -l dir (status dirname) source "$dir/../../Scripts/software.fish" + inherit "$dir/../../../Common/Software/zoxide/main.fish" function installSW yayinst \ zoxide end - function configureSW -V dir - fish "$dir/../../../Common/Software/zoxide/main.fish" configure - end - runInstaller $argv end diff --git a/scripts/Common/Scripts/software.fish b/scripts/Common/Scripts/software.fish index 4b2197d8..b8a6d453 100755 --- a/scripts/Common/Scripts/software.fish +++ b/scripts/Common/Scripts/software.fish @@ -14,6 +14,28 @@ begin runPSUserAction "$script" ConfigureUser "$name" end + function inherit -a script -d "Inherits the installer from the specified script." + set -l actions \ + installSW \ + install \ + configureSW \ + configure \ + userConfig \ + userConfig + + for i in (seq 1 2 (count $actions)) + set -l functionName "$actions[$i]Base" + + function $functionName -V script -V actions -V i + fish "$script" $actions[(math $i + 1)] $argv + end + + function $actions[$i] -V functionName + $functionName $argv + end + end + end + function runInstaller -V dir -a action set -l path (status stack-trace | head -n4 | tail -n1 | string replace --regex -- '^\s*called on line \d+ of file (.*)$' '$1') set -l name (basename (dirname $path)) diff --git a/scripts/Common/Software/Oh My Posh/main.fish b/scripts/Common/Software/Oh My Posh/main.fish index 7e2fd41b..26f59745 100644 --- a/scripts/Common/Software/Oh My Posh/main.fish +++ b/scripts/Common/Software/Oh My Posh/main.fish @@ -1,9 +1,10 @@ #!/bin/env fish begin set -l dir (status dirname) + set -l base "$dir/Manage.ps1" source "$dir/../../Scripts/software.fish" - function configureSW -V dir + function configureSW -V dir -V base source "$dir/../bash/profile.fish" source "$dir/../fish/profile.fish" @@ -20,11 +21,11 @@ begin 'eval "$(oh-my-posh completion bash)"' end | installBashProfile oh-my-posh - sudo -HE pwsh "$dir/Manage.ps1" Configure + sudo -HE pwsh "$base" Configure end - function userConfig -S -V dir -a name - runPSUserConfig "$dir/Manage.ps1" $name + function userConfig -S -V base -a name + runPSUserConfig "$base" $name end runInstaller $argv diff --git a/scripts/Common/Software/git/main.fish b/scripts/Common/Software/git/main.fish index 3cbc9219..4a79cb94 100755 --- a/scripts/Common/Software/git/main.fish +++ b/scripts/Common/Software/git/main.fish @@ -1,14 +1,15 @@ #!/bin/env fish begin set -l dir (status dirname) + set -l base "$dir/Manage.ps1" source "$(status dirname)/../../Scripts/software.fish" - function configureSW -S -V dir - pwsh "$dir/Manage.ps1" Configure + function configureSW -S -V base + pwsh "$base" Configure end - function userConfig -S -V dir -a name - runPSUserConfig "$dir/Manage.ps1" $name + function userConfig -S -V base -a name + runPSUserConfig "$base" $name end runInstaller $argv