Compare commits

...

18 commits

Author SHA1 Message Date
Manuel Thalmann a7ba0a907b Only ask for logout when applicable 2024-09-19 23:48:29 +02:00
Manuel Thalmann f6094a9583 Allow configuring the hostname 2024-09-19 23:45:19 +02:00
Manuel Thalmann eabd55c811 Reboot system after installation 2024-09-19 22:29:50 +02:00
Manuel Thalmann ae39a13ad6 Keep all variables during installation 2024-09-19 22:29:34 +02:00
Manuel Thalmann 65be8ce05d Instruct user to log out 2024-09-19 22:27:44 +02:00
Manuel Thalmann c97cf3299c Exclude rclone directory from indexing 2024-09-19 22:26:06 +02:00
Manuel Thalmann 6c0b7ebbaf Add module import scripts globally 2024-09-19 22:25:48 +02:00
Manuel Thalmann 745f6d465a Allow configuring vscode for any user 2024-09-19 22:24:58 +02:00
Manuel Thalmann 15861af5d2 Make zoxide installation cross platform 2024-09-19 22:24:36 +02:00
Manuel Thalmann 91e7b21f34 Run rclone user config script in Plasma 2024-09-19 22:23:45 +02:00
Manuel Thalmann 8ba1f0f6f0 Add scripts for installing PS modules 2024-09-19 22:20:59 +02:00
Manuel Thalmann 991ed8f64d Configure git for Linux users properly 2024-09-19 22:00:08 +02:00
Manuel Thalmann ad7e22b274 Add aliae support in Linux pwsh 2024-09-19 21:59:37 +02:00
Manuel Thalmann c918b16bfd Make profile dialogue platform independent 2024-09-19 21:59:01 +02:00
Manuel Thalmann 5a3c74a496 Configure oh-my-posh on Linux 2024-09-19 21:58:30 +02:00
Manuel Thalmann d0aa70b96b Configure aliae for individual Linux users 2024-09-19 21:56:32 +02:00
Manuel Thalmann 0bb8cc8c99 Add support for PowerShell conf.d on Linux 2024-09-19 21:53:24 +02:00
Manuel Thalmann 64850b194e Refactor the sudo configuration script 2024-09-19 21:23:16 +02:00
29 changed files with 287 additions and 56 deletions

View file

@ -35,6 +35,12 @@
}; };
}; };
hostname = mkOption {
type = types.str;
description = "The hostname of the system.";
default = "valhalla";
};
setupUser = { setupUser = {
name = mkOption { name = mkOption {
type = types.str; type = types.str;

View file

@ -1,16 +1,20 @@
{ ... }: { { lib, ... }: {
imports = [ imports = [
../defaults.nix ../defaults.nix
]; ];
config = { config = {
valhalla = { valhalla = {
hostname = lib.mkDefault "der-geret";
windows = { windows = {
dualboot = { dualboot = {
enable = true; enable = true;
linuxPercentage = 70; # better safe than sorry linuxPercentage = 70; # better safe than sorry
}; };
hostname = "DerGeret";
users.manuel = { users.manuel = {
microsoftAccount = true; microsoftAccount = true;
groups = ["Administrators"]; groups = ["Administrators"];

View file

@ -4,6 +4,9 @@
]; ];
config = { config = {
valhalla.partition.os.deviceName = "nvme0n1"; valhalla = {
hostname = "manu-surface";
partition.os.deviceName = "nvme0n1";
};
}; };
} }

View file

@ -17,10 +17,12 @@ begin
and source "$dir/../Software/pacman/main.fish" and source "$dir/../Software/pacman/main.fish"
and source "$dir/../Software/yay/main.fish" and source "$dir/../Software/yay/main.fish"
and source "$dir/../Software/PowerShell/main.fish"
and yayinst \ and yayinst \
linux-headers \ linux-headers \
pacman-contrib \ pacman-contrib \
powershell-bin yq
end end
source "$dir/../../Common/OS/install.fish" source "$dir/../../Common/OS/install.fish"

View file

@ -11,7 +11,7 @@ begin
end end
function installValhallaDeps -V mountDir function installValhallaDeps -V mountDir
pacstrap -K "$mountDir" fish git jq nix tmux pacstrap -K "$mountDir" fish git jq nix sudo tmux
end end
function getInstallerScript -V dir -S function getInstallerScript -V dir -S
@ -86,11 +86,10 @@ begin
true true
end end
and echo "$ARCH_HOSTNAME" | arch-chroot "$mountDir" tee /etc/hostname > /dev/null and echo (getConfig valhalla.hostname) | arch-chroot "$mountDir" tee /etc/hostname > /dev/null
and arch-chroot "$mountDir" mkinitcpio -P and arch-chroot "$mountDir" mkinitcpio -P
and runHook installDrivers "Installing drivers..." || true and runHook installDrivers "Installing drivers..." || true
and arch-chroot "$mountDir" bash "$tempDir/../Software/sudo/install.sh"
and runInOS fish "$tempDir/../Software/GRUB/main.fish" and runInOS fish "$tempDir/../Software/GRUB/main.fish"
and if set -l keyLayout (getConfig valhalla.keyboardLayout) and if set -l keyLayout (getConfig valhalla.keyboardLayout)

View file

@ -21,7 +21,6 @@ function deploySoftware -d "Deploys a the specified software action" -a action
neofetch \ neofetch \
bash-completion \ bash-completion \
wget \ wget \
oh-my-posh-bin \
screen \ screen \
tmux \ tmux \
htop \ htop \
@ -36,6 +35,8 @@ function deploySoftware -d "Deploys a the specified software action" -a action
end end
and source "$dir/../../Common/Software/bash/main.fish" $argv and source "$dir/../../Common/Software/bash/main.fish" $argv
and source "$dir/../Software/sudo/main.fish" $argv
and source "$dir/../Software/Oh My Posh/main.fish" $argv
and source "$dir/../Software/openssh/main.fish" $argv and source "$dir/../Software/openssh/main.fish" $argv
and source "$dir/../Software/vim/main.fish" $argv and source "$dir/../Software/vim/main.fish" $argv
and source "$dir/../Software/git/main.fish" $argv and source "$dir/../Software/git/main.fish" $argv

View file

@ -0,0 +1,20 @@
#!/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"
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

View file

@ -0,0 +1,15 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../Scripts/software.fish"
function installSW
yayinst powershell-bin
end
function configureSW -V dir
fish "$dir/../../../Common/Software/PowerShell/main.fish" configure
end
runInstaller $argv
end

View file

@ -1,6 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
set -l base "$dir/../../../Common/Software/aliae/main.fish"
source "$dir/../../Scripts/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
@ -8,8 +9,12 @@ begin
aliae-bin aliae-bin
end end
function configureSW -V dir function configureSW -V base
fish "$dir/../../../Common/Software/aliae/main.fish" configure fish "$base" configure
end
function userConfig -V base
fish "$base" userConfig $argv
end end
runInstaller $argv runInstaller $argv

View file

@ -1,6 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
set -l base "$dir/../../../Common/Software/git/main.fish"
source "$dir/../../Scripts/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
@ -13,8 +14,12 @@ begin
gitflow-zshcompletion-avh gitflow-zshcompletion-avh
end end
function configureSW -V dir function configureSW -V base
fish "$dir/../../../Common/Software/git/main.fish" configure fish "$base" configure
end
function userConfig -V base
fish "$base" userConfig $argv
end end
runInstaller $argv runInstaller $argv

View file

@ -1,16 +1,20 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
set -l base "$dir/../../../Common/Software/rclone/main.fish"
source "$dir/../../Scripts/software.fish" source "$dir/../../Scripts/software.fish"
source "$dir/../../../Common/Software/rclone/main.fish"
function installSW function installSW
yayinst \ yayinst \
rclone rclone
end end
function configureSW -V dir function configureSW -V base
fish "$dir/../../../Common/Software/rclone/main.fish" configure fish "$base" configure
end
function userConfig -V base -a name
fish "$base" userConfig $argv
end end
runInstaller $argv runInstaller $argv

View file

@ -0,0 +1,15 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../Scripts/software.fish"
function installSW
pacinst sudo
end
function configureSW
echo "%wheel ALL=(ALL:ALL) ALL" | sudo tee /etc/sudoers.d/wheel > /dev/null
end
runInstaller $argv
end

View file

@ -24,7 +24,7 @@ if [ (id -u) -eq 0 ]
echo "$name ALL=(ALL:ALL) NOPASSWD: ALL" echo "$name ALL=(ALL:ALL) NOPASSWD: ALL"
end > "$sudoConfig" end > "$sudoConfig"
and sudo --preserve-env="CONFIG_NAME" --user "$name" "$INSTALLER_SCRIPT" and sudo --preserve-env --set-home --user "$name" "$INSTALLER_SCRIPT"
rm "$sudoConfig" rm "$sudoConfig"
userdel -rf "$name" userdel -rf "$name"
else else
@ -59,4 +59,9 @@ else
end end
and runHook postInstall || true and runHook postInstall || true
echo "The installation finished successfully!"
and echo "This machine will reboot in 5 seconds..."
and echo "Press CTRL-C to abort..."
and sleep 5
and systemctl reboot
end end

View file

@ -18,7 +18,7 @@ function runSetup
if not type -q installValhallaDeps if not type -q installValhallaDeps
function installValhallaDeps function installValhallaDeps
echo 'Please set up the hook `installValhallaDeps` for installing `fish`, `git`, `jq`, `nix` and `tmux`.' echo 'Please set up the hook `installValhallaDeps` for installing `fish`, `git`, `jq`, `nix`, `sudo` and `tmux`.'
exit 1 exit 1
end end
end end

View file

@ -51,7 +51,7 @@ $null = New-Module {
$profiles = & { $profiles = & {
. "$PSScriptRoot/SoftwareManagement.ps1"; . "$PSScriptRoot/SoftwareManagement.ps1";
if (Test-Command "wsl") { if (-not $IsWindows -or (Test-Command "wsl")) {
return Invoke-ConfigScript "getProfiles"; return Invoke-ConfigScript "getProfiles";
} else { } else {
return Get-ChildItem "$PSScriptRoot/../../../.config" | ForEach-Object { Split-Path -LeafBase $_ }; return Get-ChildItem "$PSScriptRoot/../../../.config" | ForEach-Object { Split-Path -LeafBase $_ };
@ -61,16 +61,20 @@ $null = New-Module {
$choice = $Host.UI.PromptForChoice( $choice = $Host.UI.PromptForChoice(
"Select Profile", "Select Profile",
(& { (& {
switch (Get-Stage) { if ($IsWindows) {
([WindowsInstallerAction]::Backup) { switch (Get-Stage) {
"Which profile do you wish to back up?"; ([WindowsInstallerAction]::Backup) {
} "Which profile do you wish to back up?";
([WindowsInstallerAction]::Install) { }
"Which profile do you wish to install?"; ([WindowsInstallerAction]::Install) {
} "Which profile do you wish to install?";
$null { }
"Which profile do you wish to set up?"; $null {
"Which profile do you wish to set up?";
}
} }
} else {
"Please select a profile:";
} }
}), }),
(& { (& {

View file

@ -0,0 +1,31 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../Scripts/software.fish"
function configureSW -V dir
source "$dir/../bash/profile.fish"
source "$dir/../fish/profile.fish"
begin
printf %s\n \
'set -x POSH_THEME $POSH_THEME' \
"oh-my-posh init fish | source" \
"oh-my-posh completion fish | source"
end | installFishProfile "oh-my-posh"
begin
printf %s\n \
'eval "$(oh-my-posh init bash)"' \
'eval "$(oh-my-posh completion bash)"'
end | installBashProfile "oh-my-posh"
sudo -HE pwsh "$dir/Manage.ps1" Configure
end
function userConfig -S -V dir -a name
pwsh -CommandWithArgs '& $args[0] ConfigureUser @{ user=$args[1]; }' "$dir/Manage.ps1" $name
end
runInstaller $argv
end

View file

@ -62,7 +62,7 @@ $null = New-Module {
$name = $Arguments.Name; $name = $Arguments.Name;
Add-PowerShellProfileStatement ` Add-PowerShellProfileStatement `
-DefaultUser ` -System `
-Category $name ` -Category $name `
-Script "Import-Module `"$name`";"; -Script "Import-Module `"$name`";";
}; };

View file

@ -0,0 +1,11 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../Scripts/software.fish"
function configureSW -V dir
sudo -HE pwsh "$dir/Manage.ps1" Configure
end
runInstaller $argv
end

View file

@ -0,0 +1,11 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../Scripts/software.fish"
function installSW -V dir
sudo -HE pwsh "$dir/Manage.ps1"
end
runInstaller $argv
end

View file

@ -38,6 +38,12 @@ begin
"aliae completion fish | source" "aliae completion fish | source"
end | installFishProfile "aliae" "aliae" end | installFishProfile "aliae" "aliae"
end end
sudo -HE pwsh "$dir/Main.ps1" Configure
end
function userConfig -V dir -a user
pwsh -CommandWithArgs '& $args[0] ConfigureUser @{ user=$args[1]; }' "$dir/Main.ps1" $user
end end
runInstaller $argv runInstaller $argv

View file

@ -7,7 +7,7 @@ param (
. "$PSScriptRoot/../../Scripts/System.ps1"; . "$PSScriptRoot/../../Scripts/System.ps1";
. "$PSScriptRoot/../../Types/InstallerAction.ps1"; . "$PSScriptRoot/../../Types/InstallerAction.ps1";
$null = New-Module { & {
param( param(
[hashtable] $Parameters [hashtable] $Parameters
) )

View file

@ -8,7 +8,7 @@ begin
end end
function userConfig -S -V dir -a name function userConfig -S -V dir -a name
configureGit "$name" pwsh -CommandWithArgs '& $args[0] ConfigureUser @{ user=$args[1]; }' "$dir/Manage.ps1" $name
end end
runInstaller $argv runInstaller $argv

View file

@ -0,0 +1,11 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../Scripts/software.fish"
function installSW -V dir
sudo -HE pwsh "$dir/Manage.ps1"
end
runInstaller $argv
end

View file

@ -14,9 +14,32 @@ begin
if [ (echo "$configs" | jq "length") -gt 0 ] if [ (echo "$configs" | jq "length") -gt 0 ]
if [ "$XDG_SESSION_TYPE" = "tty" ] if [ "$XDG_SESSION_TYPE" = "tty" ]
set -l sessionPid
set -l freeTty
set -l service
set -l sessionConfig
set -l welcomeConfig ~"$name"/.config/plasma-welcomerc
set -l entryPoint ~"$name"/.config/autostart/PortValhallaProfile.desktop set -l entryPoint ~"$name"/.config/autostart/PortValhallaProfile.desktop
sudo -u "$name" mkdir -p "$(dirname "$entryPoint")" sudo -u "$name" mkdir -p "$(dirname "$entryPoint")"
begin
set -l file (sudo mktemp)
sudo openvt -sw -- bash -c "tty > $(string escape $file)"
set freeTty (basename (sudo cat $file))
sudo rm $file
end
set service "getty@$freeTty"
set sessionConfig "/etc/systemd/system/$service.service.d/autologin.conf"
sudo mkdir -p (dirname $sessionConfig)
begin
printf %s\n \
"[General]" \
"LastSeenVersion=1.0.0" \
"ShowUpdatePage=false"
end | sudo -u "$name" tee "$welcomeConfig" > /dev/null
begin begin
printf %s\n \ printf %s\n \
"#!/user/bin/env xdg-open" \ "#!/user/bin/env xdg-open" \
@ -26,20 +49,41 @@ begin
"Terminal=false" ( "Terminal=false" (
printf "%s " \ printf "%s " \
"Exec=env" \ "Exec=env" \
"VALHALLA_REQUEST_LOGOUT=1" \
"CONFIG_NAME=$(echo "$CONFIG_NAME" | string escape)" \ "CONFIG_NAME=$(echo "$CONFIG_NAME" | string escape)" \
"konsole -e fish $(realpath (status filename) | string escape) userConfig" "konsole -e fish $(realpath (status filename) | string escape) userConfig"
) )
end | sudo -u "$name" tee "$entryPoint" > /dev/null end | sudo -u "$name" tee "$entryPoint" > /dev/null
sudo chmod +x "$entryPoint" sudo chmod +x "$entryPoint"
sudo -Eu "$name" dbus-launch --exit-with-session startplasma-wayland &> /dev/null
rm "$entryPoint" begin
rm ~"$name"/.config/plasma-welcomerc printf %s\n \
"[Service]" \
"ExecStart=" \
"ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin $name %I \$TERM"
end | sudo tee "$sessionConfig" > /dev/null
sudo systemctl daemon-reload
sudo systemctl restart $service
while [ -z "$sessionPid" ]
set sessionPid (sudo pgrep -t $freeTty -u "$name")
end
sudo openvt -sw -- sudo -u "$name" env (sudo cat /proc/$sessionPid/environ | string split0) /usr/lib/plasma-dbus-run-session-if-needed startplasma-wayland
sudo rm "$entryPoint"
sudo rm "$welcomeConfig"
sudo rm "$sessionConfig"
sudo rmdir (dirname "$sessionConfig")
sudo systemctl daemon-reload
else if [ -n "$name" ] && [ "$name" != "$USER" ] else if [ -n "$name" ] && [ "$name" != "$USER" ]
sudo -Eu "$name" CONFIG_NAME="$CONFIG_NAME" fish "$(status filename)" userConfig sudo -Eu "$name" CONFIG_NAME="$CONFIG_NAME" fish "$(status filename)" userConfig
else else
systemctl --user enable rclone.service systemctl --user enable rclone.service
echo "Please complete the setup of your rclone configurations!" echo "Please complete the setup of your rclone configurations!"
mkdir -p ~/.mnt
touch ~/.mnt/.trackerignore
for config in (echo "$configs" | jq '.[]' --raw-output0 | string split0) for config in (echo "$configs" | jq '.[]' --raw-output0 | string split0)
set -l configKey "$key.$config" set -l configKey "$key.$config"
@ -55,6 +99,12 @@ begin
rclone config || true rclone config || true
systemctl --user enable "$serviceName" --now || true systemctl --user enable "$serviceName" --now || true
end end
echo "rclone was configured successfully!"
if [ -n "$VALHALLA_REQUEST_LOGOUT" ]
read -P "Please log out"
end
end end
end end
end end

View file

@ -4,7 +4,7 @@ begin
source "$dir/../../Scripts/software.fish" source "$dir/../../Scripts/software.fish"
function userConfig -V dir -a name function userConfig -V dir -a name
pwsh "$dir/Main.ps1" ConfigureUser; pwsh -CommandWithArgs '& $args[0] ConfigureUser @{ user=$args[1]; }' "$dir/Main.ps1" $user
end end
runInstaller $argv runInstaller $argv

View file

@ -0,0 +1,19 @@
param(
$Action,
[hashtable] $Arguments
)
. "$PSScriptRoot/../../Scripts/Software.ps1";
. "$PSScriptRoot/../PowerShell/Profile.ps1";
Start-SoftwareInstaller @PSBoundParameters `
-Configurator {
Add-PowerShellProfileStatement `
-System `
-Category "zoxide" `
-Script (
@(
"# zoxide",
(Get-ScriptInitializer "zoxide init powershell | Out-String")
) -join [System.Environment]::NewLine);
};

View file

@ -8,7 +8,7 @@ begin
source "$dir/../fish/profile.fish" source "$dir/../fish/profile.fish"
echo 'eval "$(zoxide init bash)"' | installBashProfile "zoxide" echo 'eval "$(zoxide init bash)"' | installBashProfile "zoxide"
echo "zoxide init fish | source" | installFishProfile "zoxide" echo "zoxide init fish | source" | installFishProfile "zoxide"
sudo pwsh -NoProfile "$dir/install.ps1" sudo -HE pwsh -NoProfile "$dir/Main.ps1" Configure
end end
runInstaller $argv runInstaller $argv

View file

@ -8,7 +8,6 @@ function Start-Setup {
$Global:InformationPreference = "Continue"; $Global:InformationPreference = "Continue";
$Global:ErrorActionPreference = "Inquire"; $Global:ErrorActionPreference = "Inquire";
$env:CONFIG_NAME ??= $ConfigurationName; $env:CONFIG_NAME ??= $ConfigurationName;
$null = $env:WIN_COMPUTER_NAME;
$null = $env:SETUP_SCRIPT_NAME ??= "$PSScriptRoot/Install.ps1"; $null = $env:SETUP_SCRIPT_NAME ??= "$PSScriptRoot/Install.ps1";
$env:WSLENV = "CONFIG_NAME"; $env:WSLENV = "CONFIG_NAME";
@ -218,7 +217,7 @@ function Start-Setup {
# Adjust unattended settings # Adjust unattended settings
$computerName = (Get-Component (Get-PassSettings "specialize") "Microsoft-Windows-Shell-Setup").SelectSingleNode("./ua:ComputerName", $namespace); $computerName = (Get-Component (Get-PassSettings "specialize") "Microsoft-Windows-Shell-Setup").SelectSingleNode("./ua:ComputerName", $namespace);
$computerName.InnerText = "$env:WIN_COMPUTER_NAME"; $computerName.InnerText = $valhallaConfig.hostname;
# Execute corresponding installer script after startup # Execute corresponding installer script after startup
$oobeSettings = (Get-Component (Get-PassSettings "oobeSystem") "Microsoft-Windows-Shell-Setup"); $oobeSettings = (Get-Component (Get-PassSettings "oobeSystem") "Microsoft-Windows-Shell-Setup");

View file

@ -3,25 +3,30 @@ param(
[hashtable] $Arguments [hashtable] $Arguments
) )
. "$PSScriptRoot/../../../Common/Software/PowerShell/Profile.ps1"; & {
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; param(
[hashtable] $Parameters
)
Start-SoftwareInstaller @PSBoundParameters ` . "$PSScriptRoot/../../../Common/Software/PowerShell/Profile.ps1";
-Installer { . "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
param( . "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
[scriptblock] $Installer $base = "$PSScriptRoot/../../../Common/Software/zoxide/Main.ps1";
)
Install-ChocoPackage zoxide; Start-SoftwareInstaller @PSBoundParameters `
Install-WingetPackage junegunn.fzf; -Installer {
} ` param(
-Configurator { [scriptblock] $Installer
Add-PowerShellProfileStatement ` )
-System `
-Category "zoxide" ` Install-ChocoPackage zoxide;
-Script ( Install-WingetPackage junegunn.fzf;
@( } `
"# zoxide", -Configurator {
(Get-ScriptInitializer "zoxide init powershell | Out-String") param(
) -join [System.Environment]::NewLine); $Arguments
}; )
& $base ([InstallerAction]::ConfigureUser) @PSBoundParameters;
};
} $PSBoundParameters;