Compare commits

...

445 commits

Author SHA1 Message Date
Manuel Thalmann 7bb0f9b6a3 Add a script for creating backups 2024-09-09 00:05:21 +02:00
Manuel Thalmann 242a6f1e94 Force profile selection for Windows installation actions 2024-09-09 00:04:06 +02:00
Manuel Thalmann 79aafce443 Force line endings of Unix scripts 2024-09-09 00:00:49 +02:00
Manuel Thalmann 9536ec9f8d Start setup automatically 2024-09-08 17:48:10 +02:00
Manuel Thalmann ec3f2ab8ff Show profile selection during setup 2024-09-08 17:48:02 +02:00
Manuel Thalmann 7903478799 Add a function for selecting the profile 2024-09-08 17:47:49 +02:00
Manuel Thalmann c06e7b8a61 Use same installer script for all profiles 2024-09-08 17:47:28 +02:00
Manuel Thalmann 3f1f4a31a3 Fix non-functioning WSL installation 2024-09-08 17:42:31 +02:00
Manuel Thalmann 7437452939 Make Oh-My-Posh theme location dynamic 2024-09-08 17:42:11 +02:00
Manuel Thalmann 7d5fa1a752 Improve performance 2024-09-08 17:41:30 +02:00
Manuel Thalmann 0d5a9ef078 Update Selenium to the newest version 2024-09-08 17:12:01 +02:00
Manuel Thalmann 921db1c229 Switch to named flakes 2024-09-08 17:09:01 +02:00
Manuel Thalmann efc6adb6a2 Store user related options properly 2024-09-03 23:11:28 +02:00
Manuel Thalmann ba0e7fdf4f Refactor the directory structure 2024-09-03 23:10:35 +02:00
Manuel Thalmann bf4cee6691 Add code for cleaning up after installations 2024-09-03 22:15:15 +02:00
Manuel Thalmann d2779bbef0 Add functions for uninstalling packages 2024-09-03 22:14:21 +02:00
Manuel Thalmann c483d13e73 Improve assignments of groups 2024-09-03 20:32:01 +02:00
Manuel Thalmann cc657ca0d8 Remove unnecessary policy change 2024-09-03 16:31:12 +02:00
Manuel Thalmann 36332b92c5 Migrate winiso script to fish 2024-09-03 12:08:47 +02:00
Manuel Thalmann 11cc9b1c65 Ask for live scripts only once 2024-09-03 12:08:35 +02:00
Manuel Thalmann 07ce2f2de5 Install Ubuntu automatically 2024-09-03 12:08:14 +02:00
Manuel Thalmann e08e9559e1 Add a backup script for reWASD 2024-09-03 12:02:48 +02:00
Manuel Thalmann dde27d8fde Add a backup script for Visual Studio 2024-09-03 12:02:32 +02:00
Manuel Thalmann 74d6e80560 Allow backing up TrackMania Forever 2024-09-03 12:02:09 +02:00
Manuel Thalmann 14cdf638f5 Allow testing winget packages with specific scope 2024-09-03 01:16:42 +02:00
Manuel Thalmann abb07af518 Allow backing up RetroArch 2024-08-28 13:07:58 +02:00
Manuel Thalmann 4342645275 Add scripts for backing up PuTTY 2024-08-28 13:00:37 +02:00
Manuel Thalmann 54cbbaf548 Add scripts for backing up osu! 2024-08-28 12:47:07 +02:00
Manuel Thalmann fde93b0b9a Install osu!lazer per user 2024-08-28 12:37:20 +02:00
Manuel Thalmann 2d8e1e9572 Add backup support for ManiaPlanet 2024-08-28 05:18:52 +02:00
Manuel Thalmann 15d38ca5ed Add scripts for backing up and restoring LGHub 2024-08-28 05:05:55 +02:00
Manuel Thalmann f47d858806 Allow users to restore a backup 2024-08-28 04:40:32 +02:00
Manuel Thalmann f4cc0514dd Add scripts for backing up and restoring personal files 2024-08-28 04:40:00 +02:00
Manuel Thalmann eb0ca51bb5 Fix non-functioning profile script 2024-08-28 04:39:15 +02:00
Manuel Thalmann 000fb9237e Ensure 7z is installed for backups 2024-08-28 04:38:56 +02:00
Manuel Thalmann 0fecb0546c Streamline restoration of directories 2024-08-28 04:38:30 +02:00
Manuel Thalmann ab4d874aae Set a default path for backup artifacts 2024-08-28 00:38:20 +02:00
Manuel Thalmann 7b2eb20220 Add capabilities to back up apps 2024-08-28 00:37:04 +02:00
Manuel Thalmann 185b19f6fd Allow specifying a backup action 2024-08-28 00:29:33 +02:00
Manuel Thalmann 3c01f7802d Ignore unspecified backup archives 2024-08-28 00:22:38 +02:00
Manuel Thalmann 6096a088f3 Ignore inexistent backup artifacts 2024-08-28 00:21:06 +02:00
Manuel Thalmann 0b60d65696 Make the install script action agnostic 2024-08-28 00:03:28 +02:00
Manuel Thalmann d1de499daf Rename the Windows installer script 2024-08-27 23:35:56 +02:00
Manuel Thalmann 8fa4396b2a Rename outdated script 2024-08-27 23:08:41 +02:00
Manuel Thalmann ace3d59d39 Silence errors concerning empty aliae configurations 2024-08-27 22:35:31 +02:00
Manuel Thalmann 28b32263c0 Make Operations script cross platform 2024-08-27 22:27:44 +02:00
Manuel Thalmann 7c84dfdedd Handle OneShot tasks only on Windows 2024-08-27 21:32:49 +02:00
Manuel Thalmann 0e2a70903f Add a script for managing backups 2024-08-27 21:05:51 +02:00
Manuel Thalmann 044c20461c Add tools for managing aliae 2024-08-27 18:58:33 +02:00
Manuel Thalmann 4eb25a2d71 Fix non-functioning aliae installation 2024-08-27 18:55:12 +02:00
Manuel Thalmann 9ccf2806ec Create dedicated script for creating users 2024-08-27 17:04:17 +02:00
Manuel Thalmann e09d5b1613 Create dedicated script for installing software 2024-08-27 16:41:08 +02:00
Manuel Thalmann 909fd1a2e5 Prevent reading nix config multiple times 2024-08-27 14:35:04 +02:00
Manuel Thalmann 5741d30539 Ensure only one user is enabled at once 2024-08-27 14:11:31 +02:00
Manuel Thalmann 03d158a5ff Prevent unnecessary file creation 2024-08-27 14:06:56 +02:00
Manuel Thalmann 8ef5920789 Execute OneShot tasks in any operation 2024-08-27 14:05:16 +02:00
Manuel Thalmann 4f9957dad4 Use /mnt as mount directory 2024-08-27 04:30:12 +02:00
Manuel Thalmann c292a3c7fc Force the use of the managed distribution 2024-08-27 04:26:25 +02:00
Manuel Thalmann 6022adac79 Initialize operation for all users 2024-08-27 04:24:29 +02:00
Manuel Thalmann 9a37921063 Handle initialization in operation code 2024-08-27 04:15:37 +02:00
Manuel Thalmann e0b5abe72b Execute script non-interactive during OneShot tasks 2024-08-27 03:50:08 +02:00
Manuel Thalmann 0f67360232 Exit script after running OneShot task 2024-08-27 03:45:44 +02:00
Manuel Thalmann fd53dd903e Modify user after first login 2024-08-27 03:27:54 +02:00
Manuel Thalmann fb633298ba Rearm Windows Activation before creating MSAcc 2024-08-27 03:25:19 +02:00
Manuel Thalmann 2afaff1999 Register MSAcc logon script early 2024-08-27 03:24:37 +02:00
Manuel Thalmann 94f5657ea7 Allow rebooting without registering setup 2024-08-27 03:11:35 +02:00
Manuel Thalmann beb97a95f5 Fix non-functioning NoProfile argument 2024-08-27 02:09:04 +02:00
Manuel Thalmann f9a68c631c Prevent unnecessary installation actions 2024-08-27 01:57:46 +02:00
Manuel Thalmann 3a0f841160 Only install PowerShell module if necessary 2024-08-27 01:25:32 +02:00
Manuel Thalmann 6c615c4707 Streamline PowerShell installation 2024-08-27 00:45:46 +02:00
Manuel Thalmann 8b0048c7ee Add further functionality to the WSL script 2024-08-27 00:38:46 +02:00
Manuel Thalmann 273f3c9965 Create a separate script for WSL interaction 2024-08-26 23:33:46 +02:00
Manuel Thalmann 4f8c3b1c4d Fix recursive configuration 2024-08-25 03:58:28 +02:00
Manuel Thalmann 496620d367 Fix malformed module 2024-08-24 18:35:43 +02:00
Manuel Thalmann 1ac885964e Keep Windows fixes separate 2024-08-24 16:56:29 +02:00
Manuel Thalmann 493944f358 Remove WSL after operation 2024-08-24 16:52:41 +02:00
Manuel Thalmann 5daeb40d88 Make distribution name unique 2024-08-24 16:41:05 +02:00
Manuel Thalmann 2728c45ac5 Streamline WSL distribution name 2024-08-24 16:27:34 +02:00
Manuel Thalmann fa5b462312 Remove unused resources after user setup 2024-08-24 16:15:10 +02:00
Manuel Thalmann cfbe29eb0e Print update logs properly 2024-08-24 14:47:51 +02:00
Manuel Thalmann 64e6e62c29 Allow overriding Windows settings 2024-08-24 14:20:22 +02:00
Manuel Thalmann ff925b57d7 Update incorrect path 2024-08-24 14:11:38 +02:00
Manuel Thalmann dd11967f95 Simplify osu!lazer installation 2024-08-24 14:10:02 +02:00
Manuel Thalmann a4577812b3 Determine name of setup user properly 2024-08-24 14:01:05 +02:00
Manuel Thalmann 1da7ad2a44 Make OMP configuration platform independent 2024-08-24 13:27:48 +02:00
Manuel Thalmann a9f2abf033 Fix incorrect character in OMP theme 2024-08-24 13:27:35 +02:00
Manuel Thalmann 758502ae08 Remove unnecessary code 2024-08-24 04:25:07 +02:00
Manuel Thalmann e064c55087 Remove unnecessary loop 2024-08-24 04:24:55 +02:00
Manuel Thalmann 196e530627 Add missing module 2024-08-24 04:24:37 +02:00
Manuel Thalmann e89a34b304 Add nextcloud to the module list 2024-08-24 04:18:57 +02:00
Manuel Thalmann 576e52d604 Add a function for creating shortcuts 2024-08-24 04:18:33 +02:00
Manuel Thalmann 4900b6b081 Configure nextcloud syncs 2024-08-24 04:07:47 +02:00
Manuel Thalmann 21907e77f6 Allow configuring nextcloud syncs 2024-08-24 04:07:35 +02:00
Manuel Thalmann e63d263247 Create separate option holding win users 2024-08-24 03:25:28 +02:00
Manuel Thalmann d10c040e4e Rename Nextcloud installer 2024-08-24 01:50:07 +02:00
Manuel Thalmann 147f67e11c Add file system driver for dual boot 2024-08-24 01:41:09 +02:00
Manuel Thalmann a4819bf1c6 Prevent unnecessary config evaluation 2024-08-24 01:31:39 +02:00
Manuel Thalmann b495406999 Fix non-functioning installer 2024-08-24 01:27:26 +02:00
Manuel Thalmann 3dd2c7de8f Install vscode extensions by default 2024-08-24 01:16:56 +02:00
Manuel Thalmann bedde68d66 Load theme file from WSL properly 2024-08-24 00:59:59 +02:00
Manuel Thalmann 3b0baae206 Update aliae configuration script 2024-08-24 00:42:57 +02:00
Manuel Thalmann 60e47dc297 Strip duplicate variables and aliases 2024-08-24 00:08:58 +02:00
Manuel Thalmann ab4b6dc63c Install posh theme automatically 2024-08-23 23:53:48 +02:00
Manuel Thalmann 0ad9e94a1f Export missing function 2024-08-23 23:50:13 +02:00
Manuel Thalmann 896c6fb2fb Install aliae by default 2024-08-23 23:46:23 +02:00
Manuel Thalmann 87fc264f6b Add scripts for changing aliae config 2024-08-23 23:44:51 +02:00
Manuel Thalmann 1d5b147b21 Fix compatibility with mixed new line characters 2024-08-23 23:44:23 +02:00
Manuel Thalmann 0bdf6e33ed Add a script for installing aliae 2024-08-23 22:38:28 +02:00
Manuel Thalmann e24dbe89f9 Add desired posh theme 2024-08-23 19:43:06 +02:00
Manuel Thalmann 4c6f9d8dbf Make option names more clear 2024-08-23 19:42:27 +02:00
Manuel Thalmann 689e55b6d7 Allow configuring oh-my-posh 2024-08-23 19:39:18 +02:00
Manuel Thalmann e40d22676c Fetch config from proper section 2024-08-23 19:24:49 +02:00
Manuel Thalmann 8ccef0e870 Adjust configuration accordingly 2024-08-23 19:14:09 +02:00
Manuel Thalmann 361827218b Refactor option descriptions 2024-08-23 19:02:06 +02:00
Manuel Thalmann fedd304543 Clean up the Windows configuration 2024-08-23 18:59:49 +02:00
Manuel Thalmann fd1a6f2973 Clean up the users.nix file 2024-08-23 18:51:54 +02:00
Manuel Thalmann 4c9568f974 Create dedicated rclone module 2024-08-23 18:48:30 +02:00
Manuel Thalmann cf04b3d320 Move git module to separate directory 2024-08-23 18:42:16 +02:00
Manuel Thalmann 865fc519f0 Move git options to separate module 2024-08-23 18:40:24 +02:00
Manuel Thalmann 1445192c55 Fix inheritance of user config 2024-08-23 18:28:20 +02:00
Manuel Thalmann 4d7cc6f567 Allow OS specific settings 2024-08-23 18:11:48 +02:00
Manuel Thalmann 727a80b24c Update archiso 2024-08-23 14:19:56 +02:00
Manuel Thalmann c81f63b416 Set user info during git setup 2024-08-23 02:01:16 +02:00
Manuel Thalmann 3aa6967734 Make all config scripts platform independent 2024-08-23 01:57:53 +02:00
Manuel Thalmann fc2bf2276c Allow leaving aliases unspecified 2024-08-23 01:52:25 +02:00
Manuel Thalmann 720ec85bf0 Make scripts platform independent 2024-08-23 01:52:04 +02:00
Manuel Thalmann 47f6d45da6 Add scripts for configuring git 2024-08-23 01:43:26 +02:00
Manuel Thalmann 7d6c3d6a60 Configure software implicitly 2024-08-23 01:41:32 +02:00
Manuel Thalmann 6cade00931 Skip profile creation for PinnedItem 2024-08-22 23:55:41 +02:00
Manuel Thalmann b2f5dd6fc1 Allow skipping powershell module registration 2024-08-22 23:55:00 +02:00
Manuel Thalmann 3c4f794d0a Add profiles to the flake 2024-08-22 23:37:53 +02:00
Manuel Thalmann 9b5c9d1126 Remove user profile of OneShot user 2024-08-22 23:12:11 +02:00
Manuel Thalmann b303844e4a Add missing OneShotTask declaration 2024-08-22 20:41:30 +02:00
Manuel Thalmann 2afc7a0c69 Fix infinite loop 2024-08-22 20:41:17 +02:00
Manuel Thalmann 834aaa2d5b Fix incorrect variable name 2024-08-22 20:34:16 +02:00
Manuel Thalmann fe48bbe881 Fix handling empty error messages 2024-08-22 20:12:18 +02:00
Manuel Thalmann 110d55a302 Add choco to the profile of the setup user 2024-08-22 13:46:55 +02:00
Manuel Thalmann f063536b7d Fix incorrect typings 2024-08-22 11:11:12 +02:00
Manuel Thalmann 06c9f61030 Fix permission issues when enabling Win hack 2024-08-22 11:11:00 +02:00
Manuel Thalmann 317509167d Register setup script as admin 2024-08-22 11:10:39 +02:00
Manuel Thalmann 51655b2291 Execute the entire installer using live scripts 2024-08-21 23:21:32 +02:00
Manuel Thalmann 539780ba3c Streamline the creation of users 2024-08-21 18:34:18 +02:00
Manuel Thalmann 899eddf507 Replace osk with cmd during debugging 2024-08-21 18:33:41 +02:00
Manuel Thalmann d82c3ae1e9 Prevent pauses in OneShot tasks 2024-08-21 18:28:50 +02:00
Manuel Thalmann b441e9231a Print commands in debug mode 2024-08-21 18:28:08 +02:00
Manuel Thalmann 83165588f9 Run OneShot tasks with dedicated user 2024-08-21 18:27:47 +02:00
Manuel Thalmann d00d571194 Add function for generating startup command 2024-08-21 18:26:58 +02:00
Manuel Thalmann 977fe76248 Allow registering startup script for the default user 2024-08-21 18:20:11 +02:00
Manuel Thalmann 187f0d465a Prevent unnecessary errors during WSL execution 2024-08-21 14:08:26 +02:00
Manuel Thalmann 4c587f87b1 Register WSL before running OneShot tasks 2024-08-21 03:37:44 +02:00
Manuel Thalmann d871b48864 Overwrite broken module 2024-08-21 03:20:37 +02:00
Manuel Thalmann 7feae37eb9 Prevent initialization of nested operations 2024-08-21 03:18:31 +02:00
Manuel Thalmann d2dbe59071 Improve log messages of OneShot tasks 2024-08-21 02:02:30 +02:00
Manuel Thalmann d029018563 Retry Linux path conversion for errors 2024-08-20 00:20:33 +02:00
Manuel Thalmann 72d46420f4 Fix typo 2024-08-20 00:20:07 +02:00
Manuel Thalmann f5359efad7 Fix broken signature of Restart-Intermediate 2024-08-19 12:07:26 +02:00
Manuel Thalmann 8e3abf6087 Report unexpected path conversions 2024-08-19 02:50:41 +02:00
Manuel Thalmann 4f89c167cb Load missing path 2024-08-19 02:50:19 +02:00
Manuel Thalmann 4d56597f86 Ensure error file can be read from 2024-08-19 02:24:45 +02:00
Manuel Thalmann 4dccba5632 Streamline OneShot task handler 2024-08-19 02:24:30 +02:00
Manuel Thalmann fae955e126 Simplify script registration 2024-08-19 02:24:13 +02:00
Manuel Thalmann 59e61b6ea8 Fix broken regedit paths 2024-08-19 01:38:25 +02:00
Manuel Thalmann 8eecac02bf Allow registering reboots for users 2024-08-19 01:37:14 +02:00
Manuel Thalmann 345b3fb1df Prevent users from being excluded 2024-08-19 01:10:29 +02:00
Manuel Thalmann d8596f0a58 Force copying of Linux users to Windows 2024-08-19 00:54:13 +02:00
Manuel Thalmann df57160ef5 Improve log messages of updates 2024-08-18 12:20:21 +02:00
Manuel Thalmann 2f59726682 Remove unnecessary command 2024-08-18 10:24:15 +02:00
Manuel Thalmann 7dbf75e591 Fix time for QEMU VMs 2024-08-18 09:35:16 +02:00
Manuel Thalmann 0b2824cf9e Remove unnecessary desktop icons 2024-08-18 09:25:23 +02:00
Manuel Thalmann bd8224b3f4 Add a timeout for the reWASD downloader 2024-08-18 09:05:04 +02:00
Manuel Thalmann 5c0e462cc7 Allow setting a timeout for clicking download buttons 2024-08-18 09:04:42 +02:00
Manuel Thalmann 7015a69d16 Emit errors concerning WSL commands 2024-08-17 13:51:10 +02:00
Manuel Thalmann 0a23112e2c Emit errors using Write-Error 2024-08-17 13:49:21 +02:00
Manuel Thalmann d684d1ec42 Convert Argument to string explicitly 2024-08-16 23:03:19 +02:00
Manuel Thalmann 40b3472700 Ignore unfinished browser downloads 2024-08-16 17:57:22 +02:00
Manuel Thalmann 24ff14ca99 Install powershell modules for all users 2024-08-16 16:43:30 +02:00
Manuel Thalmann 60074b9ad0 Fix typos 2024-08-16 16:10:09 +02:00
Manuel Thalmann 73c0f0913e Install AutoHotkey as preparation 2024-08-16 15:22:09 +02:00
Manuel Thalmann ff8b949b35 Allow running live scripts in debug mode 2024-08-16 15:21:41 +02:00
Manuel Thalmann 6a73d54056 Generate env variables using shorthand scripts 2024-08-16 15:16:56 +02:00
Manuel Thalmann 0d8ea792fc Allow running installation in debug mode 2024-08-16 15:16:28 +02:00
Manuel Thalmann f3e70d2908 Redirect winiso exit code properly 2024-08-16 15:13:53 +02:00
Manuel Thalmann a3a3b5e9b4 Allow specifying winiso build type 2024-08-16 15:13:33 +02:00
Manuel Thalmann cb0af07f0c Refactor winget check for rare issue 2024-08-16 15:04:37 +02:00
Manuel Thalmann 36dd010efb Disable Windows Update reboot only as admin 2024-08-16 14:35:35 +02:00
Manuel Thalmann 1e198093cc Add a function for queueing startup commands 2024-08-15 18:34:48 +02:00
Manuel Thalmann d6a85c8cda Hide output of DISM commands 2024-08-15 13:57:15 +02:00
Manuel Thalmann fac547f4be Ensure website is loaded before download 2024-08-15 02:42:00 +02:00
Manuel Thalmann 1ff78c6769 Prevent Jellyfin from rebooting 2024-08-15 02:22:07 +02:00
Manuel Thalmann 18a0b3d577 Improve handling of slow websites 2024-08-14 18:47:29 +02:00
Manuel Thalmann 318a880b5f Fix potential CRC errors 2024-08-14 18:46:42 +02:00
Manuel Thalmann fcfc58ff7e Ensure auto reboot is disabled properly 2024-08-12 21:32:53 +02:00
Manuel Thalmann 580cbd2f2a Disable auto reboot by default 2024-08-12 01:27:50 +02:00
Manuel Thalmann a9090b9b9c Add methods for managing auto restart feature 2024-08-12 01:23:42 +02:00
Manuel Thalmann 908a847bbe Install Wave Link first 2024-08-11 18:27:16 +02:00
Manuel Thalmann df0a2847c4 Throw an error when failing to load config 2024-08-11 18:27:06 +02:00
Manuel Thalmann dfc70a2b0c Fix incorrect script path 2024-08-10 20:37:10 +02:00
Manuel Thalmann 6db6fd02ee Allow leaving install action unspecified 2024-08-10 19:27:56 +02:00
Manuel Thalmann b504ee0979 Retrieve registry value properly 2024-08-10 19:26:53 +02:00
Manuel Thalmann 234a0f17d5 Add scripts for installing git 2024-08-10 15:28:10 +02:00
Manuel Thalmann 77ed70468e Remove unnecessary code 2024-08-10 15:24:15 +02:00
Manuel Thalmann e0771278a5 Add a function for removing the RunOnce key 2024-08-10 15:24:04 +02:00
Manuel Thalmann 2fd325d580 Set user groups properly 2024-08-10 15:23:38 +02:00
Manuel Thalmann 20c3244301 Configure MS accounts properly 2024-08-10 15:21:13 +02:00
Manuel Thalmann 882ecb28fd Queue next user after configuration finished 2024-08-10 15:20:36 +02:00
Manuel Thalmann 6c120c6149 Disable UAC after logging in MS account 2024-08-10 15:19:14 +02:00
Manuel Thalmann 1fc72a3f5e Enable OneShot listener for MS accounts 2024-08-10 15:18:10 +02:00
Manuel Thalmann 03f144cc43 Set timezone automatically 2024-08-10 15:17:21 +02:00
Manuel Thalmann d80e4a63e3 Prevent variable overwrite 2024-08-10 15:16:57 +02:00
Manuel Thalmann 15e73aa0e7 Register installer script after disabling UAG 2024-08-10 15:16:27 +02:00
Manuel Thalmann b2445ef769 Redirect user for configuration properly 2024-08-10 15:16:00 +02:00
Manuel Thalmann d8aee75468 Fix broken redirection of arguments 2024-08-10 15:15:40 +02:00
Manuel Thalmann e9e24e243d Determine installer action properly 2024-08-10 15:15:21 +02:00
Manuel Thalmann 3ee92c243e Redirect arguments to chocolatey properly 2024-08-10 15:13:46 +02:00
Manuel Thalmann 69a09752b0 Fix non-functioning OneShot script 2024-08-10 15:13:20 +02:00
Manuel Thalmann 9e7436bfca Fix oneshot task execution 2024-08-10 06:11:55 +02:00
Manuel Thalmann 53f0bc9644 Allow removing the OneShot listener 2024-08-10 05:19:24 +02:00
Manuel Thalmann fbbfd0cfe1 Remove duplicate code 2024-08-10 05:17:08 +02:00
Manuel Thalmann 31b149db32 Fix typo 2024-08-10 03:57:37 +02:00
Manuel Thalmann 114545d4cc Fix copy paste error 2024-08-10 03:57:26 +02:00
Manuel Thalmann b916c7d46d Allow skipping the User parameter 2024-08-10 03:40:37 +02:00
Manuel Thalmann 9a084acf75 Fix incorrect script path 2024-08-10 03:13:13 +02:00
Manuel Thalmann 29d4964ba5 Fix broken scripts 2024-08-10 01:50:52 +02:00
Manuel Thalmann 8cf4f8ce4f Remove unnecessary confirmation dialogue 2024-08-10 00:23:47 +02:00
Manuel Thalmann db4a48702d Add a task for disabling UAC 2024-08-10 00:23:37 +02:00
Manuel Thalmann 56492ec332 Force creation of sudo alias 2024-08-10 00:22:46 +02:00
Manuel Thalmann fb60713ae4 Allow execution of OneShot tasks 2024-08-10 00:22:30 +02:00
Manuel Thalmann 66fed9c176 Ensure CONFIG_MODULE is resolved 2024-08-09 23:23:55 +02:00
Manuel Thalmann 33bbfc5d0b Add dedicated functions for creating startup scripts 2024-08-09 23:23:29 +02:00
Manuel Thalmann 734309c960 Change login message 2024-08-09 22:11:12 +02:00
Manuel Thalmann 2149b90be9 Set up shared WSL 2024-08-09 16:02:33 +02:00
Manuel Thalmann b8c6038da8 Install updates only as admin 2024-08-09 16:02:24 +02:00
Manuel Thalmann 9f55fe7734 Disable boot message only as admin 2024-08-09 16:02:00 +02:00
Manuel Thalmann 2928649ee0 Add a function for allowing user access 2024-08-09 15:56:16 +02:00
Manuel Thalmann 0cfbb26b17 Fix broken reboot registration 2024-08-09 15:49:36 +02:00
Manuel Thalmann 36d88a713a Ensure the script path is detected properly 2024-08-09 14:45:50 +02:00
Manuel Thalmann 7caf1de4cb Allow automatic script execution for MS accounts 2024-08-09 14:45:29 +02:00
Manuel Thalmann e3f84a227b Reorder winget arguments 2024-08-09 14:45:05 +02:00
Manuel Thalmann babef7a9ac Allow registering reboot for the default user 2024-08-09 14:44:57 +02:00
Manuel Thalmann cc919b4d46 Add a dedicated function for disabling boot message 2024-08-09 13:35:12 +02:00
Manuel Thalmann dc7fe9f418 Implement root install loop using a switch 2024-08-09 13:34:46 +02:00
Manuel Thalmann d23bcac5d2 Force computer reboots 2024-08-09 04:42:55 +02:00
Manuel Thalmann 3f3799add0 Add scripts for controlling UAC 2024-08-09 04:29:26 +02:00
Manuel Thalmann 9d662fbce5 Set displayname of all users 2024-08-09 04:20:00 +02:00
Manuel Thalmann 43f7672df3 Login to users for configuration 2024-08-09 04:19:49 +02:00
Manuel Thalmann 839e0ccaaf Skip PWSH_PATH if undefined 2024-08-09 04:08:22 +02:00
Manuel Thalmann a2fa8bb699 Fix typo 2024-08-09 03:38:10 +02:00
Manuel Thalmann 4ec658b387 Add missing setup stage 2024-08-09 03:02:25 +02:00
Manuel Thalmann 916b5c9649 Make Get-Users output explicit 2024-08-09 03:02:17 +02:00
Manuel Thalmann 53730a9a52 Allow displaying a boot message 2024-08-09 02:59:06 +02:00
Manuel Thalmann 49e8a3fd43 Disable users by default 2024-08-09 02:58:01 +02:00
Manuel Thalmann 7ab68a71ba Add a stage for configuring users 2024-08-09 02:27:24 +02:00
Manuel Thalmann 5e0f528616 Detect installation properly 2024-08-09 02:24:59 +02:00
Manuel Thalmann bcc1536b22 Remove unnecessary icon 2024-08-09 02:23:56 +02:00
Manuel Thalmann 1d2ef65310 Add Predator Z301C to the hardware list 2024-08-09 02:23:41 +02:00
Manuel Thalmann f38794c3c0 Add support for the sudo command 2024-08-09 02:22:45 +02:00
Manuel Thalmann c68ce2b4e3 Fix renaming user 2024-08-09 02:20:27 +02:00
Manuel Thalmann 3fad7125f7 Make specifying PWSH_PATH optional 2024-08-09 02:12:27 +02:00
Manuel Thalmann 8f43f82e5f Show error properly 2024-08-09 02:00:18 +02:00
Manuel Thalmann 456fe11ab5 Fix typo 2024-08-09 01:53:59 +02:00
Manuel Thalmann 85288488f9 Remove code duplication 2024-08-09 01:33:04 +02:00
Manuel Thalmann ebf7408858 Remove unnecessary console output 2024-08-09 01:22:51 +02:00
Manuel Thalmann 66786ad5cd Fix incorrect file paths 2024-08-09 00:17:05 +02:00
Manuel Thalmann 565f5f927e Fix incorrect hardware name 2024-08-09 00:03:45 +02:00
Manuel Thalmann 2ea5578a54 Reorder installation steps 2024-08-08 23:03:10 +02:00
Manuel Thalmann d86d27e8de Suppress unnecessary output 2024-08-08 22:24:41 +02:00
Manuel Thalmann 5d7022f981 Refactor the wsl installation check 2024-08-08 22:21:49 +02:00
Manuel Thalmann 01c90615ef Ensure WSL Ubuntu is installed 2024-08-08 22:08:13 +02:00
Manuel Thalmann 5f6d8839f4 Make config script platform independent 2024-08-08 18:21:16 +02:00
Manuel Thalmann 31eb506bc8 Leave groups unspecified 2024-08-08 17:50:32 +02:00
Manuel Thalmann f82b43c057 Add users during installation 2024-08-08 17:49:43 +02:00
Manuel Thalmann 927b1e5a4a Fix incorrect user conversion 2024-08-08 17:16:51 +02:00
Manuel Thalmann 6bd5335a2a Keep Windows groups separate 2024-08-08 15:33:55 +02:00
Manuel Thalmann 497115ca6a Remove unnecessary options from Win users 2024-08-08 15:32:05 +02:00
Manuel Thalmann 700c0498d1 Inherit Windows users from linux 2024-08-08 15:28:29 +02:00
Manuel Thalmann b238484519 Add functions for retrieving attributes 2024-08-08 14:45:34 +02:00
Manuel Thalmann 141b5061ed Install Oh My Posh system wide 2024-08-08 14:23:15 +02:00
Manuel Thalmann c08052998c Fix typo 2024-08-08 14:22:22 +02:00
Manuel Thalmann 3cc7ee3298 Skip scope argument by default 2024-08-08 14:22:13 +02:00
Manuel Thalmann 26ed09b13b Fix incorrect file paths 2024-08-08 14:21:55 +02:00
Manuel Thalmann 97efefcbf0 Configure NVS after installation 2024-08-08 14:09:20 +02:00
Manuel Thalmann f665b3e1f7 Refactor app association script 2024-08-08 14:09:07 +02:00
Manuel Thalmann 30f1b9323c Fix typo 2024-08-08 14:08:48 +02:00
Manuel Thalmann 1e6b6d8447 Apply the error action globally 2024-08-08 14:08:38 +02:00
Manuel Thalmann d059374124 Move PinnedItem script to proper location 2024-08-08 14:04:51 +02:00
Manuel Thalmann b02c63adb2 Add notes to installation script 2024-08-08 14:03:15 +02:00
Manuel Thalmann a147c2d8ea Add a script for installing LGHub 2024-08-08 13:25:21 +02:00
Manuel Thalmann 2223123808 Reorder installation steps 2024-08-08 13:17:14 +02:00
Manuel Thalmann 823909a847 Reload env after installing git 2024-08-08 12:18:04 +02:00
Manuel Thalmann 5733639a99 Enure features for PinnedItem are installed 2024-08-08 05:21:21 +02:00
Manuel Thalmann 3ccf3b43a7 Install features using chocolatey 2024-08-08 05:20:58 +02:00
Manuel Thalmann 9d205f353a Ensure git is installed 2024-08-08 05:14:31 +02:00
Manuel Thalmann cc05ba4fed Fix broken XML document creation 2024-08-08 05:04:59 +02:00
Manuel Thalmann 627a8e61c4 Fix incorrect parameter access 2024-08-08 05:03:24 +02:00
Manuel Thalmann 41cf18bd81 Fix incorrect path 2024-08-08 05:01:45 +02:00
Manuel Thalmann a9dadb8419 Add a dedicated user option for windows 2024-08-08 04:45:27 +02:00
Manuel Thalmann 40a983dc65 Add a stage for creating users 2024-08-08 04:38:40 +02:00
Manuel Thalmann 03460b7e44 Add scripts for all remaining apps 2024-08-08 04:36:35 +02:00
Manuel Thalmann dfe237dfd7 Allow custom winget arguments 2024-08-08 04:29:00 +02:00
Manuel Thalmann c59dce210f Improve winget function 2024-08-08 04:28:21 +02:00
Manuel Thalmann f347f2b3ec Add missing function 2024-08-08 04:20:11 +02:00
Manuel Thalmann 223249e1c4 Refactor browser scripts 2024-08-08 03:32:03 +02:00
Manuel Thalmann 05837fb6be Ensure Selenium is imported 2024-08-08 02:59:02 +02:00
Manuel Thalmann bd926e2412 Allow skipping the Action argument 2024-08-08 02:56:28 +02:00
Manuel Thalmann fcbbc12a63 Rename all old installation scripts 2024-08-08 02:56:13 +02:00
Manuel Thalmann 1dd6ddce11 Add options for enabling LG Hub 2024-08-08 02:29:51 +02:00
Manuel Thalmann d29c6f1c45 Remove Firefox taskbar icon 2024-08-08 02:29:09 +02:00
Manuel Thalmann 1010b795bb Allow removing task bar icons 2024-08-08 02:28:40 +02:00
Manuel Thalmann 889f969045 Allow installing modules native only 2024-08-08 02:28:23 +02:00
Manuel Thalmann 0d1dbda873 Rename old LGHub script 2024-08-08 02:27:39 +02:00
Manuel Thalmann 6a443c7438 Add missing config 2024-08-08 01:51:21 +02:00
Manuel Thalmann a532df391a Rename PuTTY script 2024-08-08 00:51:45 +02:00
Manuel Thalmann 96cdbb231d Fix permission issue 2024-08-08 00:48:18 +02:00
Manuel Thalmann 219e991d45 Add scripts for installing Tobii apps 2024-08-08 00:06:49 +02:00
Manuel Thalmann 6f4a22b5aa Copy keyboard layout to welcome screen 2024-08-07 23:53:26 +02:00
Manuel Thalmann 933402144d Add scripts for desktop apps 2024-08-07 23:53:12 +02:00
Manuel Thalmann bb9eb99a36 Rename old Nextcloud script 2024-08-07 23:45:56 +02:00
Manuel Thalmann f9752543c1 Configure user only outside of setup 2024-08-07 23:30:29 +02:00
Manuel Thalmann e32d97ec51 Add a script for installing Oh My Posh 2024-08-07 23:22:04 +02:00
Manuel Thalmann ff86ea62f9 Fix incorrect installation filter 2024-08-07 23:20:28 +02:00
Manuel Thalmann dde206a980 Fix profile script for individual profiles 2024-08-07 23:18:44 +02:00
Manuel Thalmann bfba6b532f Show messages if packages are installed 2024-08-07 23:18:23 +02:00
Manuel Thalmann 1c9de44bd8 Fix incorrect package check 2024-08-07 23:17:07 +02:00
Manuel Thalmann 72d8ebe35f Refactor default winget parameters 2024-08-07 22:56:42 +02:00
Manuel Thalmann 036d2a8338 Add scripts for installing PS modules 2024-08-07 22:55:25 +02:00
Manuel Thalmann 049c8d5eba Allow skipping PowerShell profile files 2024-08-07 22:25:42 +02:00
Manuel Thalmann 096446e646 Resolve dependency loop 2024-08-07 21:54:58 +02:00
Manuel Thalmann 27bd44a127 Remove unnecessary statement 2024-08-07 21:53:26 +02:00
Manuel Thalmann 30638e42f1 Refactor chocolatey script 2024-08-07 21:50:21 +02:00
Manuel Thalmann a667593dbb Pass arguments to software script 2024-08-07 21:37:33 +02:00
Manuel Thalmann df850deeea Use internal OS detection 2024-08-07 21:35:03 +02:00
Manuel Thalmann 438bbb911e Refactor PowerShell profile script 2024-08-07 21:34:40 +02:00
Manuel Thalmann d90e3bb437 Move scripts properly 2024-08-07 21:05:32 +02:00
Manuel Thalmann cebc95eae9 Add scripts for installing PowerShell 2024-08-07 20:30:12 +02:00
Manuel Thalmann 2f0198257e Rename PowerShell script directory 2024-08-07 19:08:13 +02:00
Manuel Thalmann aa295bae1c Add script for installing Thunderbird 2024-08-07 18:57:27 +02:00
Manuel Thalmann 6ffc02ad16 Install drivers in proper phase 2024-08-07 18:54:07 +02:00
Manuel Thalmann 6de06321ca Add a script for installing WinSCP 2024-08-07 18:30:14 +02:00
Manuel Thalmann 9b8ba848f6 Refactor app association script 2024-08-07 18:29:20 +02:00
Manuel Thalmann 7532873c6c Prevent reboot during WaveLink installation 2024-08-07 18:01:17 +02:00
Manuel Thalmann 770445ea95 Add scripts for installing drivers 2024-08-07 16:17:49 +02:00
Manuel Thalmann 3e57070f4e Add script for installing AMD packages 2024-08-07 15:25:12 +02:00
Manuel Thalmann 8b921112e2 Add missing package for selenium 2024-08-07 15:24:56 +02:00
Manuel Thalmann 6ca8369d08 Ensure correct types for setting download dir 2024-08-07 15:24:37 +02:00
Manuel Thalmann 979e77a95d Add a script for installing ASUS packages 2024-08-07 14:40:24 +02:00
Manuel Thalmann 81db7a4bca Refactor browser automation scripts 2024-08-07 14:28:26 +02:00
Manuel Thalmann 46c30157a0 Execute winget script in a module 2024-08-07 13:36:47 +02:00
Manuel Thalmann d6f58f3185 Install components for browser automation 2024-08-07 13:36:31 +02:00
Manuel Thalmann a1c094dba5 Add functions for installing choco and winget packages 2024-08-07 13:22:12 +02:00
Manuel Thalmann 82a365a14a Add a function for checking winget packages 2024-08-07 13:18:29 +02:00
Manuel Thalmann cd822fc916 Enhance the winget install check 2024-08-07 03:34:12 +02:00
Manuel Thalmann 35867a0016 Add a function for checking NuGet packages 2024-08-07 03:23:59 +02:00
Manuel Thalmann ff48173d0d Fix non-functioning script 2024-08-07 03:23:21 +02:00
Manuel Thalmann 143b4d86fb Install PowerShell modules after removing old copy 2024-08-06 18:19:33 +02:00
Manuel Thalmann 639eb26da1 Add config for declaring hardware 2024-08-06 17:23:20 +02:00
Manuel Thalmann 4a5c658315 Silence unnecessary output 2024-08-06 17:07:57 +02:00
Manuel Thalmann 9cbf51fe45 Add a separate function for executing software actions 2024-08-06 16:54:11 +02:00
Manuel Thalmann 44d4bdb7ec Add a function for checking whether a setup is being run 2024-08-06 14:32:37 +02:00
Manuel Thalmann 76a9004e3c Determine software script name properly 2024-08-06 12:21:48 +02:00
Manuel Thalmann 92d041c327 Fix incorrect path 2024-08-06 12:21:00 +02:00
Manuel Thalmann 1521de74cb Fix incorrectly imported modules 2024-08-06 11:39:57 +02:00
Manuel Thalmann 9a83325ff4 Fix incorrect XPaths 2024-08-06 11:39:48 +02:00
Manuel Thalmann eb014bac8a Create Windows image as normal user 2024-08-06 11:39:34 +02:00
Manuel Thalmann a74b21e32a Make the name of the setup user look more Windows like 2024-08-06 11:39:05 +02:00
Manuel Thalmann 5d16278931 Set the name of the setup user properly 2024-08-06 10:22:50 +02:00
Manuel Thalmann 5ad6fa685b Add scripts for installing essential software 2024-08-06 00:04:02 +02:00
Manuel Thalmann a20956ac7d Add a function for removing desktop icons 2024-08-06 00:02:07 +02:00
Manuel Thalmann c7a982cecc Add an option for showing file extensions 2024-08-05 23:22:22 +02:00
Manuel Thalmann 110da58eae Ensure the environment variables are always set properly 2024-08-05 23:09:58 +02:00
Manuel Thalmann 35a03d27ca Fix incorrect argument initialization 2024-08-05 23:08:36 +02:00
Manuel Thalmann 3c7ee2c4c1 Ensure Arguments contains an object 2024-08-05 22:51:29 +02:00
Manuel Thalmann 304a99ce68 Fix argument redirection 2024-08-05 22:49:44 +02:00
Manuel Thalmann a2136a0dc0 Fix non-functioning script 2024-08-05 22:45:17 +02:00
Manuel Thalmann b8bd928029 Allow running further installer actions within an installer 2024-08-05 22:29:20 +02:00
Manuel Thalmann 8cecf2d724 Refactor windows configuration script 2024-08-05 20:07:39 +02:00
Manuel Thalmann af93ffd764 Add settings for customizing windows 2024-08-05 19:12:59 +02:00
Manuel Thalmann 2654ba7629 Refactor software script environment 2024-08-05 00:07:41 +02:00
Manuel Thalmann ecd9027e4c Set CONFIG_MODULE to full path by default 2024-08-02 01:57:31 +02:00
Manuel Thalmann 3a28990a98 Enter next stage after configuration 2024-08-02 01:44:56 +02:00
Manuel Thalmann 8d6b1b8baf Make config module persist in WSL 2024-08-02 00:47:33 +02:00
Manuel Thalmann 6dfc060a4e Ensure arguments are passed to fish 2024-08-01 23:36:03 +02:00
Manuel Thalmann d079f853bc Fix installer script structure 2024-08-01 23:34:35 +02:00
Manuel Thalmann 94c7df6913 Declare InstallerAction in a separate file 2024-08-01 22:52:51 +02:00
Manuel Thalmann 9c84539b2f Ensure necessary modules are imported 2024-08-01 21:49:46 +02:00
Manuel Thalmann cf926260df Import SetupStage enum into installation module 2024-08-01 21:32:33 +02:00
Manuel Thalmann 85dc2a8c48 Pause on error by default 2024-08-01 21:08:31 +02:00
Manuel Thalmann e5a3bdd0b8 Display the software name during installation 2024-08-01 21:06:03 +02:00
Manuel Thalmann b62adc9f9a Fix non-functioning command 2024-08-01 20:34:55 +02:00
Manuel Thalmann ea6f8d3dfe Remove non-existent script 2024-08-01 19:10:10 +02:00
Manuel Thalmann e52a389b0b Nest installation functions in a module 2024-08-01 19:02:12 +02:00
Manuel Thalmann 2d58aece66 Install winget if nonexistent 2024-08-01 18:58:33 +02:00
Manuel Thalmann 59b2a47fd1 Use the new commands 2024-08-01 18:36:47 +02:00
Manuel Thalmann 88f24b9752 Add dedicated commands for checking software 2024-08-01 18:35:45 +02:00
Manuel Thalmann f389aee193 Add a script for managing software 2024-08-01 18:24:26 +02:00
Manuel Thalmann 89aaa40b19 Fix nix installation check 2024-08-01 18:05:10 +02:00
Manuel Thalmann 6e98ce7777 Make nix visible to WSL 2024-08-01 18:03:48 +02:00
Manuel Thalmann fb925692ae Add a function for getting the users to create 2024-08-01 17:56:42 +02:00
Manuel Thalmann f5685f051a Rename the file containing software functions 2024-08-01 17:38:59 +02:00
Manuel Thalmann c7af9c8a3c Configure clock for dualboot systems 2024-08-01 16:32:03 +02:00
Manuel Thalmann 3b66106a0c Enter configuration stage if nix exists 2024-08-01 16:28:48 +02:00
Manuel Thalmann db3b109c0c Reboot WSL to pick up nix 2024-08-01 16:25:18 +02:00
Manuel Thalmann 4e62179e74 Add a function for retrieving nix options 2024-08-01 16:12:58 +02:00
Manuel Thalmann 8624596e2e Make CONFIG_MODULE available in WSL 2024-08-01 14:39:44 +02:00
Manuel Thalmann 8f8f455e84 Install WSL and nix by default 2024-08-01 14:06:40 +02:00
Manuel Thalmann 17237a0d67 Rename config module file 2024-08-01 12:39:27 +02:00
Manuel Thalmann a584d864af Reword log messages 2024-08-01 12:32:43 +02:00
Manuel Thalmann a39174fe48 Fix syntax error 2024-08-01 12:31:25 +02:00
Manuel Thalmann 4d3dd0ba33 Import scripting module inside the PowerManagement module 2024-08-01 12:24:28 +02:00
Manuel Thalmann 8a41a75527 Add scripts for updating windows 2024-08-01 02:59:32 +02:00
Manuel Thalmann f109ab9d7e Fix errors in the PowerManagement module 2024-08-01 02:19:05 +02:00
Manuel Thalmann c4dc9d40f7 Fix syntax error 2024-08-01 01:22:23 +02:00
Manuel Thalmann 4c11b787ae Fix incorrect documentation comment 2024-07-31 23:10:21 +02:00
Manuel Thalmann a44a5413fb Fix handling of setup stages 2024-07-31 22:33:37 +02:00
Manuel Thalmann 4e489f4076 Set registry values properly 2024-07-31 22:33:16 +02:00
Manuel Thalmann 625b9f3d03 Display console output of hooks 2024-07-31 22:18:47 +02:00
Manuel Thalmann 5e186fb9dd Store stages using their name 2024-07-31 16:52:49 +02:00
Manuel Thalmann edf4a57c0f Refactor the installation loop architecture 2024-07-31 16:25:32 +02:00
Manuel Thalmann fe79e4b13a Implement install loop properly 2024-07-31 16:15:09 +02:00
Manuel Thalmann 4f1d032a2a Implement the windows installation in a loop 2024-07-31 16:09:50 +02:00
Manuel Thalmann a9d0ef43e2 Recreate script to first install pwsh 2024-07-31 15:52:41 +02:00
Manuel Thalmann 46c4caa76e Normalize script formatting 2024-07-31 15:52:23 +02:00
Manuel Thalmann f330b1f9a3 Add a script for managing setup options 2024-07-31 15:42:02 +02:00
Manuel Thalmann af552af3cc Add a script for rebooting the computer 2024-07-31 15:41:45 +02:00
Manuel Thalmann fc60e85a48 Add a separate script for injecting values into scripts 2024-07-31 14:55:00 +02:00
Manuel Thalmann bf3cde37e3 Add a script for checking for installed choco packages 2024-07-31 14:53:21 +02:00
Manuel Thalmann 0656dc18fa Copy pwsh to newly setup windows systems 2024-07-31 14:47:42 +02:00
Manuel Thalmann e9f5f1571f Rename old windows installation script 2024-07-30 18:47:01 +02:00
Manuel Thalmann 638cbd454e Add a function for executing hooks 2024-07-30 18:34:19 +02:00
Manuel Thalmann 2def5be4f9 Enable rclone services properly 2024-07-30 17:42:29 +02:00
Manuel Thalmann f374c55a5e Disable root bash login during installation 2024-07-30 00:54:43 +02:00
Manuel Thalmann 7b8071311b Silence unnecessary output 2024-07-30 00:53:20 +02:00
Manuel Thalmann 4a7f502209 Install vscode extensions for each user 2024-07-30 00:53:10 +02:00
Manuel Thalmann 9dfcd2ae6c Fix installation of brave extensions 2024-07-30 00:52:55 +02:00
Manuel Thalmann cf004bb962 Fix non-functioning installation scripts 2024-07-30 00:52:35 +02:00
Manuel Thalmann 6960db47dc Fix missing variables 2024-07-30 00:51:50 +02:00
Manuel Thalmann 50d9eb52a9 Fix non-functioning command 2024-07-29 23:46:14 +02:00
Manuel Thalmann 5ed546f559 Load dualboot sizes from nix 2024-07-29 01:44:12 +02:00
Manuel Thalmann e24026e821 Improve handling of wmic output 2024-07-29 01:22:42 +02:00
Manuel Thalmann 1995da2cc2 Save unnecessary space 2024-07-29 00:10:07 +02:00
Manuel Thalmann 4dd0b74e3f Allow overwriting packages 2024-07-28 23:45:30 +02:00
Manuel Thalmann 026fd790d9 Generate locales in proper system 2024-07-28 23:45:09 +02:00
Manuel Thalmann 81c1a577a0 Execute userConfig for current user only once 2024-07-28 23:44:58 +02:00
Manuel Thalmann 20ca5297a4 Prevent userConfig from execute multiple times 2024-07-28 23:43:11 +02:00
Manuel Thalmann 0d532702e4 Nest Windows setup in a function 2024-07-28 20:52:07 +02:00
Manuel Thalmann e558557f4f Configure Windows on DerGeret 2024-07-28 17:14:38 +02:00
206 changed files with 7332 additions and 1400 deletions

2
.gitattributes vendored Normal file
View file

@ -0,0 +1,2 @@
*.fish text eol=lf
*.sh text eol=lf

View file

@ -23,7 +23,7 @@ automated_script() {
sleep 1
done
printf '%s: downloading %s\n' "$0" "${script}"
curl "${script}" --location --retry-connrefused --retry 10 -s -o /tmp/startup_script
curl "${script}" --location --retry-connrefused --retry 10 --fail -s -o /tmp/startup_script
rt=$?
else
cp "${script}" /tmp/startup_script

View file

@ -1,8 +1,8 @@
diff --git a/airootfs/root/.zlogin b/airootfs/root/.zlogin
index bf6bc8f..76e5893 100755
index bf6bc8f..a0dae7b 100755
--- a/airootfs/root/.zlogin
+++ b/airootfs/root/.zlogin
@@ -4,3 +4,18 @@ if grep -Fqa 'accessibility=' /proc/cmdline &> /dev/null; then
@@ -4,3 +4,19 @@ if grep -Fqa 'accessibility=' /proc/cmdline &> /dev/null; then
fi
~/.automated_script.sh
@ -16,13 +16,14 @@ index bf6bc8f..76e5893 100755
+
+git diff -p -R --no-ext-diff --no-color --diff-filter=M \
+ | grep -E "^(diff|(old|new) mode)" --color=never \
+ | sed "/^diff/{ x; d; }; x; /./{ p; z; }; x;" \
+ | git apply
+
+popd > /dev/null
+
+loadkeys de_CH-latin1
diff --git a/packages.x86_64 b/packages.x86_64
index 9e876e7..b89ab30 100755
index 9e876e7..c5db92a 100755
--- a/packages.x86_64
+++ b/packages.x86_64
@@ -30,8 +30,10 @@ ethtool
@ -36,7 +37,15 @@ index 9e876e7..b89ab30 100755
gnu-netcat
gpart
gpm
@@ -75,6 +77,7 @@ nbd
@@ -45,6 +47,7 @@ irssi
iw
iwd
jfsutils
+jq
kitty-terminfo
ldns
less
@@ -75,6 +78,7 @@ nbd
ndisc6
nfs-utils
nilfs-utils

View file

@ -6,7 +6,7 @@
flake-utils.url = "github:numtide/flake-utils?ref=b1d9ab70662946ef0850d488da1c9019f3a9752a";
};
outputs = { self, flake-utils, nixpkgs }: flake-utils.lib.eachDefaultSystem (
outputs = { self, flake-utils, nixpkgs }: (flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
@ -32,5 +32,10 @@
packages = {
archiso = pkgs.archiso;
};
});
})) // {
valhalla = {
DerGeret = import ./profiles/machines/manuel/DerGeret/Arch/config.nix;
ManuSurface = import ./profiles/machines/manuel/ManuSurface/Arch/config.nix;
};
};
}

15
lib/eval-attribute.nix Normal file
View file

@ -0,0 +1,15 @@
let
inherit (nixpkgs) lib;
nixpkgs = import <nixpkgs> { config = {}; overlay = []; };
property = (builtins.getEnv "PROPERTY");
processor = if (builtins.stringLength property > 0)
then
(_: lib.attrsets.getAttrFromPath (lib.strings.splitString "." property) _)
else
(_: _);
in
_: processor (lib.evalModules {
modules = [
_
];
}).config

View file

@ -1,7 +0,0 @@
{ lib, ... }: {
options = {
valhalla = {
git = (import ./git/options.nix) { inherit lib; };
};
};
}

View file

@ -1,33 +0,0 @@
{ lib, ... }:
let
inherit (lib)
mkOption
types
;
in {
defaultBranch = mkOption {
type = types.nullOr types.str;
description = "The name of the default branch in git.";
default = null;
};
flow = {
mainBranch = mkOption {
type = types.nullOr types.str;
description = "The name of the stable branch in git flow.";
default = null;
};
devBranch = mkOption {
type = types.nullOr types.str;
description = "The name of the development branch in git flow.";
default = null;
};
};
aliases = mkOption {
type = types.attrsOf types.str;
description = "Git command aliases to install.";
default = {};
};
}

55
lib/modules/hardware.nix Normal file
View file

@ -0,0 +1,55 @@
{ lib, ... }:
let
inherit (lib)
mkOption
types
;
in {
options = {
valhalla = {
hardware = {
components = mkOption {
type = types.listOf types.str;
description = "The names of the hardware components of the computer.";
default = [];
};
eyeX = mkOption {
type = types.bool;
description = "A value indicating whether a Tobii EyeX device is present.";
default = false;
};
amdCPU = mkOption {
type = types.bool;
description = "A value indicating whether an AMD CPU is present.";
default = false;
};
nvidiaGPU = mkOption {
type = types.bool;
description = "A value indicating whether an NVIDIA GPU is present.";
default = false;
};
corsairDevice = mkOption {
type = types.bool;
description = "A value indicating whether a Corsair device is present.";
default = false;
};
elgatoWave = mkOption {
type = types.bool;
description = "A value indicating whether an Elgato Wave device is present.";
default = false;
};
logitechG = mkOption {
type = types.bool;
description = "A value indicating whether a Logitech G device is present.";
default = false;
};
};
};
};
}

52
lib/modules/os.nix Normal file
View file

@ -0,0 +1,52 @@
{ lib, ... }:
let
inherit (lib)
mkOption
types
;
in {
options = {
valhalla = mkOption {
type = types.submodule (
{ extendModules, ... }:
let
osVariant = extendModules {
modules = [
({ config, ... }: {
options = {
config = mkOption {
type = types.attrs;
description = "The configuration of the Operating System.";
default = builtins.removeAttrs config ["_module" "config" "linux" "windows"];
visible = false;
};
};
})
];
};
linuxVariant = osVariant.extendModules { };
windowsVariant = osVariant.extendModules { };
in {
options = {
linux = mkOption {
inherit (linuxVariant) type;
description = "The options for setting up Linux.";
default = {};
visible = "shallow";
};
windows = mkOption {
inherit (windowsVariant) type;
description = "The options for setting up Windows.";
default = {};
visible = "shallow";
};
};
});
description = "Configuration for PortValhalla.";
default = {};
};
};
}

View file

@ -0,0 +1,59 @@
{ lib, ... }:
let
inherit (lib)
mkOption
types
;
gitType = types.submodule (
{ ... }: {
options = {
defaultBranch = mkOption {
type = types.nullOr types.str;
description = "The name of the default branch in newly created repositories.";
default = null;
};
flow = {
mainBranch = mkOption {
type = types.nullOr types.str;
description = "The name of the stable branch in git flow.";
default = null;
};
devBranch = mkOption {
type = types.nullOr types.str;
description = "The name of the development branch in git flow.";
default = null;
};
};
aliases = mkOption {
type = types.attrsOf types.str;
description = "The git command aliases to install.";
default = {};
};
};
});
gitOption = mkOption {
type = gitType;
description = "The git related options.";
default = {};
};
in {
options = {
valhalla = {
git = gitOption;
users = mkOption {
type = types.attrsOf (types.submodule (
{ ... }: {
options = {
git = gitOption;
};
}));
};
};
};
}

View file

@ -0,0 +1,44 @@
{ lib, ... }:
let
inherit (lib)
mkEnableOption
mkOption
types
;
syncType = types.submodule (
{ ... }: {
options = {
remotePath = mkOption {
type = types.str;
description = "The path to the folder on the cloud to sync.";
};
localPath = mkOption {
type = types.str;
description = "The path to sync the cloud content to.";
};
virtualFiles = (mkEnableOption "virtual file support") // {
default = true;
};
};
});
in {
options = {
valhalla.windows.users = mkOption {
type = types.attrsOf (types.submodule (
{ ... }: {
options = {
nextcloud = {
folderSyncs = mkOption {
type = types.listOf syncType;
description = "The folders to synchronize.";
default = [];
};
};
};
}));
};
};
}

View file

@ -0,0 +1,60 @@
{ lib, ... }:
let
inherit (lib)
mkOption
types
;
themeType = types.submodule (
{ config, ... }: {
options = {
source = mkOption {
type = types.nullOr types.path;
description = "The path to the oh-my-posh theme to use.";
default = null;
};
name = mkOption {
type = types.nullOr types.str;
description = "The name of the theme.";
default = if (config.source != null)
then
lib.strings.removeSuffix ".omp" (lib.strings.removeSuffix ".json" (builtins.baseNameOf config.source))
else
null;
};
};
});
ompType = types.submodule (
{ config, ... }: {
options = {
theme = mkOption {
type = types.either types.str themeType;
description = "The default theme.";
default = {};
};
additionalThemes = mkOption {
type = types.listOf themeType;
description = "A set of additional themes to install.";
default = [];
};
};
});
in {
options = {
valhalla.users = mkOption {
type = types.attrsOf (types.submodule (
{ ... }: {
options = {
oh-my-posh = mkOption {
type = ompType;
description = "The Oh My Posh configuration to apply.";
default = {};
};
};
}));
};
};
}

View file

@ -0,0 +1,40 @@
{ lib, ... }:
let
inherit (lib)
mkOption
types
;
syncType = types.submodule (
{ ... }: {
options = {
dirName = mkOption {
type = types.str;
description = "The name of the directory to sync the remote files to.";
};
cacheDuration = mkOption {
type = types.nullOr types.str;
description = "The amount of time to keep cached files.";
default = null;
};
};
});
in {
options = {
valhalla.linux.users = mkOption {
type = types.attrsOf (types.submodule (
{ ... }: {
options = {
rclone = {
configurations = mkOption {
type = types.attrsOf syncType;
description = "The configurations of the rclone mounts.";
default = {};
};
};
};
}));
};
};
}

View file

@ -5,21 +5,7 @@
types
;
syncType = types.submodule (
{ ... }: {
options = {
dirName = mkOption {
type = types.str;
description = "The name of the directory to sync the remote files to.";
};
cacheDuration = mkOption {
type = types.nullOr types.str;
description = "The amount of time to keep cached files.";
default = null;
};
};
});
capitalize = (import ../text.nix { inherit lib; }).capitalize;
userType = types.submodule (
{ ... } : {
@ -41,21 +27,27 @@
description = "The additional groups of the user.";
default = [];
};
};
});
linuxUserType = types.submodule (
{ ... }: {
options = {
defaultShell = mkOption {
type = types.nullOr types.str;
description = "The default shell of the user.";
default = null;
};
git = (import ./git/options.nix) { inherit lib; };
rclone = {
configurations = mkOption {
type = types.attrsOf syncType;
description = "The configurations of the rclone mounts.";
default = {};
};
});
winUserType = types.submodule (
{ ... }: {
options = {
microsoftAccount = mkOption {
type = types.bool;
description = "A value indicating whether this user is a Microsoft Account.";
default = false;
};
};
});
@ -67,6 +59,33 @@
description = "The users to create on the machine.";
default = {};
};
linux.users = mkOption {
type = types.attrsOf linuxUserType;
};
windows = mkOption {
type = types.submoduleWith {
modules = [
({ config, options, ... }: {
options = {
users = mkOption {
type = types.attrsOf winUserType;
};
winUsers = mkOption {
type = options.users.type;
description = "Blablabla";
default = (lib.attrsets.concatMapAttrs (
name: options: {
${capitalize name} = options;
}) config.users);
};
};
})
];
};
};
};
};
}

View file

@ -6,8 +6,13 @@
;
in {
imports = [
./git.nix
./packages/git.nix
./packages/nextcloud.nix
./packages/oh-my-posh.nix
./packages/rclone.nix
./hardware.nix
./i18n.nix
./os.nix
./partition.nix
./software.nix
./users.nix

View file

@ -1,15 +1,18 @@
{ lib, ... }:
{ lib, config, ... }:
let
inherit (lib)
mkOption
mkDefault
mkEnableOption
mkIf
mkOption
types
;
winType = types.submodule (
{ config, ... }: {
capitalize = (import ../text.nix { inherit lib; }).capitalize;
in {
options = {
valhalla = {
windows = {
dualboot = {
enable = mkEnableOption "dual boot";
@ -18,20 +21,27 @@
description = "The percentage of the disk size reserved for Linux.";
};
};
showFileExt = mkOption {
type = types.bool;
description = "A value indicating whether file extensions should be displayed in Windows Explorer.";
default = true;
};
legacyIconSpacing = mkEnableOption "legacy icon spacing" // {
default = true;
};
dynamicLighting = mkEnableOption "dynamic lighting";
adware = mkEnableOption "adware"; # Fuck you for displaying ads on an OS I fricking paid for!
};
};
};
config = {
dualboot.linuxPercentage = mkIf (!config.dualboot.enable) 0;
};
});
in {
options = {
valhalla = {
windows = mkOption {
type = winType;
description = "The options for setting up Windows.";
default = {};
};
valhalla.windows = {
setupUser.name = mkDefault (capitalize config.valhalla.setupUser.name);
dualboot.linuxPercentage = mkIf (!config.valhalla.windows.dualboot.enable) (mkDefault 0);
};
};
}

9
lib/text.nix Normal file
View file

@ -0,0 +1,9 @@
{ lib, ... }: {
capitalize = text:
let
chars = lib.strings.stringToCharacters text;
in lib.strings.concatStrings (
[(lib.strings.toUpper (builtins.elemAt chars 0))] ++
(lib.lists.drop 1 chars)
);
}

View file

@ -1,19 +0,0 @@
#!/bin/bash -e
function install() {
function installDrivers() {
. "../../../scripts/Arch/Config/SecureBoot/install.sh";
. "../../../scripts/Arch/Software/nvidia-dkms/install.sh";
. "../../../scripts/Arch/Software/xone/install.sh";
. "../../../scripts/Arch/Software/bt-dualboot/install.sh";
}
function initializeConfig() {
. "../../../scripts/Unix/Devices/Logitech G903/install.sh";
}
pushd "$dir" > /dev/null;
. "../../../scripts/Arch/OS/install.sh";
popd > /dev/null;
}
install;

View file

@ -1,139 +0,0 @@
#!/bin/pwsh
$env:WIN_COMPUTER_NAME = "DerGeret";
$env:SETUP_SCRIPT_NAME = "$PSScriptRoot/Restore.ps1";
function Initialize-SetupConfig() {
param(
[xml] $config,
[System.Xml.XmlNamespaceManager] $namespace
);
$setupComponent = $config.SelectSingleNode(
"/ua:unattend/ua:settings[@pass='windowsPE']/ua:component[@name='Microsoft-Windows-Setup']",
$namespace);
$diskConfig = $setupComponent.SelectSingleNode("./ua:DiskConfiguration/ua:Disk", $namespace);
$partitionCreationContainer = $diskConfig.SelectSingleNode("./ua:CreatePartitions", $namespace);
$partitionCreations = $partitionCreationContainer.SelectNodes("./ua:CreatePartition", $namespace);
$partitionModificationContainer = $diskConfig.SelectSingleNode("./ua:ModifyPartitions", $namespace);
$partitionModifications = $partitionModificationContainer.SelectNodes("./ua:ModifyPartition", $namespace);
<#
.SYNOPSIS
Gets the XML element describing the installation partition ID.
#>
function Get-InstallationPartition {
$setupComponent.SelectSingleNode("./ua:ImageInstall/ua:OSImage/ua:InstallTo/ua:PartitionID", $namespace)
}
<#
.SYNOPSIS
Increases the ID of all partitions in the specified range by 1.
#>
function Move-PartitionRange {
param (
[int]$From = 0,
[System.Nullable[int]]$To = $null,
[int]$By = 1
)
# Update installation partition ID if necessary
$installationPartition = Get-InstallationPartition;
$installPartitionID = [int]$installationPartition.InnerText;
if (($installPartitionID -ge $From) -and (($null -eq $To) -or ($installPartitionID -le $To))) {
$installationPartition.InnerText = "$($installPartitionID + $By)";
}
# Update IDs of all partition creations
foreach ($partition in $partitionCreations) {
$orderNode = $partition.SelectSingleNode("./ua:Order", $namespace);
$order = [int]$orderNode.InnerText;
$newOrder = $order;
if (($newOrder -ge $From) -and (($null -eq $To) -or ($newOrder -le $To))) {
$newOrder += $By;
}
if ($order -ne $newOrder) {
$orderNode.InnerText = "$newOrder";
}
}
# Update IDs of all partition modifications
foreach ($partition in $partitionModifications) {
$partitionNode = $partition.SelectSingleNode("./ua:PartitionID", $namespace);
$partitionID = [int]$partitionNode.InnerText;
$newID = $partitionID;
if (($newID -ge $From) -and (($null -eq $To) -or ($newID -le $To))) {
$newID += $By;
}
if ($partitionID -ne $newID) {
$partitionNode.InnerText = "$newID";
$partition.SelectSingleNode("./ua:Order", $namespace).InnerText = "$newID";
}
}
}
function Add-Partition {
param (
[int]$Index,
[int]$Size,
[string]$Type = "Primary"
)
Move-PartitionRange -From $Index -By 1;
$newPartition = $partitionCreations[0].CloneNode($true);
$newPartition.SelectSingleNode("./ua:Order", $namespace).InnerText = "$Index";
$newPartition.SelectSingleNode("./ua:Type", $namespace).InnerText = "$Type";
$newPartition.SelectSingleNode("./ua:Size", $namespace).InnerText = "$Size";
$null = $partitionCreationContainer.AppendChild($newPartition);
$newModification = $partitionModifications[2].CloneNode($true);
$newModification.SelectSingleNode("./ua:Order", $namespace).InnerText = "$Index";
$newModification.SelectSingleNode("./ua:PartitionID", $namespace).InnerText = "$Index";
$null = $partitionModificationContainer.AppendChild($newModification);
}
<#
.SYNOPSIS
Relocates the partition with the specified `$From` ID to the specified `$To` ID.
#>
function Invoke-PartitionRelocation {
param (
[int]$From,
[int]$To
)
Move-PartitionRange $From $From (-1 * ($From + 1))
if ($From -gt $To) {
Move-PartitionRange $To ($From - 1);
}
elseif ($From -lt $To) {
Move-PartitionRange ($From + 1) $To -1;
}
Move-PartitionRange -1 -1 ($To + 1)
}
# Resize EFI partition to 1GB
$partitionCreations[1].SelectSingleNode("./ua:Size", $namespace).InnerText = "$(1024)";
# Swap Windows RE partition (partition #1) and boot partition (partition #2)
Invoke-PartitionRelocation 2 1;
# Add space before Windows installation... wha-!? For Linux, ofc! I use Arch Linux, btw.
$swapSpacer = 100;
Add-Partition 2 $swapSpacer;
# Add a 1.2 TB partition for Linux
Add-Partition 3 ((1.2 * 1024 * 1024) - 1024 - $swapSpacer);
}
. "$PSScriptRoot/../../../scripts/Windows/OS/Setup.ps1";

View file

@ -1,20 +0,0 @@
{ ... }: {
imports = [
../Generic/config.nix
];
config = {
valhalla.partition.os.partitions = {
Boot.keepExisting = true;
Windows = {
index = 6;
label = "OS";
format = "ntfs";
mountPoint = "/win";
mountOptions = ["force"];
keepExisting = true;
};
};
};
}

View file

@ -1,13 +0,0 @@
#!/bin/pwsh
. "$PSScriptRoot/../../../scripts/Windows/Scripts/Context.ps1";
. "$PSScriptRoot/../../../scripts/Windows/OS/Install.ps1";
. "$PSScriptRoot/../../../scripts/Windows/Collections/Generic.ps1"
function Restore-Apps {
param([Context] $context)
Restore-GenericApps $context;
}
[Context]$context = [Context]::new();
Invoke-WindowsInstallation $context;
Restart-Computer -Force;

View file

@ -1,6 +0,0 @@
#!/bin/pwsh
$env:WIN_COMPUTER_NAME ??= "win11";
$env:SETUP_SCRIPT_NAME ??= "$PSScriptRoot/Install.ps1";
$env:CONFIG_MODULE ??= "$PSScriptRoot/../config.nix";
. "$PSScriptRoot/../../../scripts/Windows/OS/Setup.ps1";

View file

@ -1,4 +0,0 @@
#!/bin/pwsh
$env:SETUP_SCRIPT_NAME ??= "$PSScriptRoot/Install.ps1";
. "$PSScriptRoot/../../Generic/Windows/Setup.ps1";

View file

@ -1,5 +0,0 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../../scripts/Arch/OS/install.fish"
end

View file

@ -1,26 +0,0 @@
#!/bin/bash -e
function install() {
function installDrivers() {
. "../../../scripts/Arch/Config/SecureBoot/install.sh";
. "../../../scripts/Arch/Drivers/SurfaceBook2/install.sh";
}
function installSoftware() {
. "../../../scripts/Arch/Collections/school.sh";
}
function initializeConfig() {
. "../../../scripts/Common/Config/Steam/hidpi.sh";
. "../../../scripts/Unix/Devices/Surface Book 2/install.sh";
. "../../../scripts/Unix/Devices/Logitech G903/install.sh";
# Because, as it looks, Surface Books are fucking stupid.
. "../../../scripts/Common/Config/GRUB/verbose.sh";
}
pushd "${BASH_SOURCE%/*}" > /dev/null;
. "../../../scripts/Arch/OS/install.sh";
popd > /dev/null;
}
install;

View file

@ -1,16 +0,0 @@
#!/bin/bash
pushd "${BASH_SOURCE%/*}" > /dev/null;
# Set Hostname
sudo hostnamectl set-hostname ManuSurface;
source "../../../scripts/PopOS/Scripts/preinstall.sh";
source "../../../scripts/PopOS/OS/install.sh";
source "../../../scripts/Debian/Drivers/SurfaceBook2/Setup/install.sh";
source "../../../scripts/PopOS/Software/Collections/school.sh";
INSTALL_FONTS=1 NEXTCLOUD_DIR="${NEXTCLOUD_DIR}" source "../../../scripts/Common/Config/UserProfile/install.sh";
# Install equalizer
source "../../../scripts/Common/Config/EasyEffects/SurfaceBook2/install.sh";
source "../../../scripts/PopOS/Scripts/postinstall.sh";
popd > /dev/null;

View file

@ -1,12 +0,0 @@
#!/bin/bash
pushd "${BASH_SOURCE%/*}" > /dev/null;
# Set Hostname
sudo hostnamectl set-hostname ManuPopOSLive;
source "../../scripts/PopOS/Scripts/prepare.sh";
source "../../scripts/PopOS/OS/install.sh";
source "../../scripts/PopOS/Software/Collections/personal.sh";
INSTALL_FONTS=1 NEXTCLOUD_DIR="${NEXTCLOUD_DIR}" source "../../scripts/Common/Config/UserProfile/personal.sh";
source "../../scripts/PopOS/Scripts/postinstall.sh";
popd > /dev/null;

View file

@ -0,0 +1,19 @@
#!/bin/bash -e
function install() {
function installDrivers() {
. "../../../../../scripts/Arch/Config/SecureBoot/install.sh";
. "../../../../../scripts/Arch/Software/nvidia-dkms/install.sh";
. "../../../../../scripts/Arch/Software/xone/install.sh";
. "../../../../../scripts/Arch/Software/bt-dualboot/install.sh";
}
function initializeConfig() {
. "../../../../../scripts/Unix/Devices/Logitech G903/install.sh";
}
pushd "$dir" > /dev/null;
. "../../../../../scripts/Arch/OS/install.sh";
popd > /dev/null;
}
install;

View file

@ -6,8 +6,8 @@ begin
echo "$dir/install.fish"
end
CONFIG_MODULE="$dir/config.nix" \
CONFIG_NAME="DerGeret" \
ARCH_HOSTNAME="der-geret" \
USER_DISPLAYNAME="Manuel Thalmann" \
source "$(status dirname)/../../../scripts/Arch/OS/setup.fish"
source "$(status dirname)/../../../../../scripts/Arch/OS/setup.fish"
end

View file

@ -4,6 +4,6 @@ pushd "${BASH_SOURCE%/*}" > /dev/null;
CONFIG_MODULE="./config.nix" \
ARCH_HOSTNAME="der-geret" \
USER_DISPLAYNAME="Manuel Thalmann" \
. "../../../scripts/Arch/OS/setup.sh";
. "../../../../../scripts/Arch/OS/setup.sh";
popd > /dev/null;

View file

@ -1,7 +1,7 @@
#!/bin/pwsh
$null = New-Module {
. "$PSScriptRoot/../../../scripts/Windows/Scripts/Context.ps1";
. "$PSScriptRoot/../../../scripts/Windows/OS/Manage.ps1";
. "$PSScriptRoot/../../../../../scripts/Common/Scripts/Context.ps1";
. "$PSScriptRoot/../../../../../scripts/Windows/OS/Legacy.ps1";
Write-Host "Starting Backup of Windows";
$context = [Context]::new();

View file

@ -1,12 +1,12 @@
#!/bin/pwsh
. "$PSScriptRoot/../../../scripts/Windows/Scripts/Context.ps1";
. "$PSScriptRoot/../../../../../scripts/Common/Scripts/Context.ps1";
function Install-PortValhallaDrivers {
param(
[Context] $context
)
$winPath = "$PSScriptRoot/../../../scripts/Windows";
$winPath = "$PSScriptRoot/../../../../../scripts/Windows";
$driverPath = "$winPath/Drivers";
$mbDriverPath = "$driverPath/ROG Zenith Extreme Alpha";
$context.RegisterReboot();
@ -38,7 +38,7 @@ function Install-PersonalDrivers {
[Context] $context
)
$softwarePath = "$PSScriptRoot/../../../scripts/Windows/Software";
$softwarePath = "$PSScriptRoot/../../../../../scripts/Windows/Software";
. "$softwarePath/TobiiGhost/Install.ps1" $context;
. "$softwarePath/TobiiGameHub/Install.ps1" $context;
}

View file

@ -1,8 +1,8 @@
#!/bin/pwsh
. "$PSScriptRoot/Drivers.ps1";
. "$PSScriptRoot/../../../scripts/Windows/Collections/Personal.ps1"
. "$PSScriptRoot/../../../scripts/Windows/OS/Install.ps1";
. "$PSScriptRoot/../../../scripts/Windows/Scripts/Context.ps1";
. "$PSScriptRoot/../../../../../scripts/Common/Scripts/Context.ps1";
. "$PSScriptRoot/../../../../../scripts/Windows/Collections/Personal.ps1"
. "$PSScriptRoot/../../../../../scripts/Windows/OS/Manage.ps1";
function Initialize-Configuration {
# Fix synchronization between Linux and Windows clock
@ -26,5 +26,4 @@ function Restore-Apps {
Write-Host "Starting Restoration of Windows";
[Context]$context = [Context]::new();
Invoke-WindowsInstallation $context;
Restart-Computer -Force;
Start-WindowsInstallation;

View file

@ -0,0 +1,5 @@
#!/bin/pwsh
$env:WIN_COMPUTER_NAME = "DerGeret";
$env:CONFIG_NAME = $env:WIN_COMPUTER_NAME;
. "$PSScriptRoot/../../../../../scripts/Windows/OS/Setup.ps1";

View file

@ -0,0 +1,48 @@
{ ... }: {
imports = [
../defaults.nix
];
config = {
valhalla = {
windows = {
dualboot = {
enable = true;
linuxPercentage = 30;
};
users.manuel = {
microsoftAccount = true;
groups = ["Administrators"];
};
};
partition.os.partitions = {
Boot.keepExisting = true;
Windows = {
index = 6;
label = "OS";
format = "ntfs";
mountPoint = "/win";
mountOptions = ["force"];
keepExisting = true;
};
};
hardware = {
components = [
"ROG Zenith Extreme Alpha"
"Predator Z301C"
];
eyeX = true;
amdCPU = true;
nvidiaGPU = true;
logitechG = true;
corsairDevice = true;
elgatoWave = true;
};
};
};
}

View file

@ -3,11 +3,11 @@ function install() {
local dir="$(realpath "${BASH_SOURCE%/*}")";
function installDrivers() {
. "$dir/../../../scripts/Arch/Config/SecureBoot/install.sh";
. "$dir/../../../../../scripts/Arch/Config/SecureBoot/install.sh";
}
. "../../../scripts/Arch/OS/install.sh";
. "../../../../../scripts/Arch/OS/install.sh";
}
install;

View file

@ -4,6 +4,6 @@ pushd "${BASH_SOURCE%/*}" > /dev/null;
ARCH_MOUNT_ROOT="/mnt" \
ARCH_HOSTNAME="archlinux" \
USER_DISPLAYNAME="Manuel Thalmann" \
. "../../../scripts/Arch/OS/setup.sh";
. "../../../../../scripts/Arch/OS/setup.sh";
popd > /dev/null;

View file

@ -0,0 +1,13 @@
#!/bin/pwsh
. "$PSScriptRoot/../../../../../scripts/Common/Scripts/Context.ps1";
. "$PSScriptRoot/../../../../../scripts/Windows/OS/Manage.ps1";
. "$PSScriptRoot/../../../../../scripts/Windows/Collections/Generic.ps1"
function Restore-Apps {
param([Context] $context)
Restore-GenericApps $context;
}
[Context]$context = [Context]::new();
Invoke-WindowsInstallation $context;
Restart-Computer -Force;

View file

@ -0,0 +1,5 @@
#!/bin/pwsh
$env:WIN_COMPUTER_NAME ??= "win11";
$env:CONFIG_MODULE ??= "$PSScriptRoot/../config.nix";
. "$PSScriptRoot/../../../../../scripts/Windows/OS/Setup.ps1";

View file

@ -1,9 +1,9 @@
{ lib, config, ... }:
let
fs = import ../../lib/modules/partition/fs.nix;
fs = import ../../../../lib/modules/partition/fs.nix;
in {
imports = [
../../lib/modules/valhalla.nix
../defaults.nix
];
config = {
@ -35,31 +35,6 @@
};
};
users = {
manuel = {
displayName = "Manuel Thalmann";
mailAddress = "m@nuth.ch";
groups = [
"wheel"
"nix-users"
];
defaultShell = "fish";
rclone = {
configurations = {
nextcloud = {
dirName = "Nextcloud";
};
proton = {
dirName = "Proton";
};
};
};
};
};
timeZone = "Europe/Zurich";
keyMap = "de_CH-latin1";
keyboardLayout = "ch";

View file

@ -14,4 +14,4 @@ function Install-PortValhallaDrivers {
choco install -y spice-agent;
}
. "$PSScriptRoot/../../Generic/Windows/Install.ps1";
. "$PSScriptRoot/../../../../Generic/Windows/Install.ps1";

View file

@ -0,0 +1,2 @@
#!/bin/pwsh
. "$PSScriptRoot/../../../../Generic/Windows/Setup.ps1";

View file

@ -0,0 +1,5 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../../../../scripts/Arch/OS/install.fish"
end

View file

@ -0,0 +1,26 @@
#!/bin/bash -e
function install() {
function installDrivers() {
. "../../../../../scripts/Arch/Config/SecureBoot/install.sh";
. "../../../../../scripts/Arch/Drivers/SurfaceBook2/install.sh";
}
function installSoftware() {
. "../../../../../scripts/Arch/Collections/school.sh";
}
function initializeConfig() {
. "../../../../../scripts/Common/Config/Steam/hidpi.sh";
. "../../../../../scripts/Unix/Devices/Surface Book 2/install.sh";
. "../../../../../scripts/Unix/Devices/Logitech G903/install.sh";
# Because, as it looks, Surface Books are fucking stupid.
. "../../../../../scripts/Common/Config/GRUB/verbose.sh";
}
pushd "${BASH_SOURCE%/*}" > /dev/null;
. "../../../../../scripts/Arch/OS/install.sh";
popd > /dev/null;
}
install;

View file

@ -3,7 +3,7 @@ begin
set -l dir (status dirname)
function installDrivers -V dir -S
source "$dir/../../../scripts/Common/Scripts/config.fish"
source "$dir/../../../../../scripts/Common/Scripts/config.fish"
pacstrap -K (getConfig valhalla.partition.rootDir) linux-firmware-marvell;
end
@ -11,8 +11,8 @@ begin
echo "$dir/install.fish"
end
CONFIG_MODULE="$(status dirname)/config.nix" \
CONFIG_NAME="ManuSurface" \
ARCH_HOSTNAME="manu-surface" \
USER_DISPLAYNAME="Manuel Thalmann" \
source "$(status dirname)/../../../scripts/Arch/OS/setup.fish";
source "$(status dirname)/../../../../../scripts/Arch/OS/setup.fish";
end

View file

@ -0,0 +1,16 @@
#!/bin/bash
pushd "${BASH_SOURCE%/*}" > /dev/null;
# Set Hostname
sudo hostnamectl set-hostname ManuSurface;
source "../../../../../scripts/PopOS/Scripts/preinstall.sh";
source "../../../../../scripts/PopOS/OS/install.sh";
source "../../../../../scripts/Debian/Drivers/SurfaceBook2/Setup/install.sh";
source "../../../../../scripts/PopOS/Software/Collections/school.sh";
INSTALL_FONTS=1 NEXTCLOUD_DIR="${NEXTCLOUD_DIR}" source "../../../../../scripts/Common/Config/UserProfile/install.sh";
# Install equalizer
source "../../../../../scripts/Common/Config/EasyEffects/SurfaceBook2/install.sh";
source "../../../../../scripts/PopOS/Scripts/postinstall.sh";
popd > /dev/null;

View file

@ -0,0 +1,12 @@
#!/bin/bash
pushd "${BASH_SOURCE%/*}" > /dev/null;
# Set Hostname
sudo hostnamectl set-hostname ManuPopOSLive;
source "../../../../scripts/PopOS/Scripts/prepare.sh";
source "../../../../scripts/PopOS/OS/install.sh";
source "../../../../scripts/PopOS/Software/Collections/personal.sh";
INSTALL_FONTS=1 NEXTCLOUD_DIR="${NEXTCLOUD_DIR}" source "../../../../scripts/Common/Config/UserProfile/personal.sh";
source "../../../../scripts/PopOS/Scripts/postinstall.sh";
popd > /dev/null;

View file

@ -0,0 +1,6 @@
{ ... }: {
imports = [
../../users/manuel/config.nix
../../../lib/modules/valhalla.nix
];
}

View file

@ -0,0 +1,66 @@
{ ... }: {
imports = [
../../../lib/modules/valhalla.nix
];
config = {
valhalla = {
users.manuel = {
displayName = "Manuel Thalmann";
mailAddress = "m@nuth.ch";
oh-my-posh = {
theme = {
source = ./manuel.omp.json;
};
};
};
linux.users.manuel = {
defaultShell = "fish";
groups = [
"wheel"
"nix-users"
];
rclone = {
configurations = {
nextcloud = {
dirName = "Nextcloud";
};
proton = {
dirName = "Proton";
};
};
};
};
windows.users.manuel = {
nextcloud = {
folderSyncs =
let
localPath = "C:/tools/RetroArch-Win64";
remotePath = "/Saved Games/RetroArch";
in [
{
remotePath = "${remotePath}/Saves";
localPath = "${localPath}/saves";
virtualFiles = false;
}
{
remotePath = "${remotePath}/System";
localPath = "${localPath}/system";
}
];
};
};
partition = {
os = {
partitions = { };
};
};
};
};
}

View file

@ -0,0 +1,173 @@
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"version": 2,
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "os",
"style": "diamond",
"leading_diamond": "\ue0b6",
"trailing_diamond": "\ue0b4",
"background_templates": [
"{{ if eq .OS \"ubuntu\" }}#EA531A{{ end }}",
"{{ if eq .OS \"debian\" }}#D80150{{ end }}",
"{{ if eq .OS \"arch\" }}#1793D1{{ end }}"
],
"foreground": "p:white",
"template": "{{ if ne .OS \"windows\" }}{{ .Icon }} {{ end }}"
},
{
"type": "session",
"style": "diamond",
"leading_diamond": "\ue0b6",
"trailing_diamond": "\ue0b0",
"background": "p:yellow",
"foreground": "p:black",
"properties": {
"display_host": false
},
"template": " {{ if .SSHSession }}\ueb39 {{ end }}{{ .UserName }} "
},
{
"type": "path",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"background": "p:orange",
"foreground": "p:black",
"properties": {
"home_icon": "~",
"style": "folder"
},
"template": " \udb80\ude4b {{ path .Path .Location }} "
},
{
"type": "dotnet",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "p:black",
"background": "#00ffff",
"template": " \udb81\ude10 {{ .Full }} "
},
{
"type": "java",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"background": "#4063d8",
"template": " \udb82\udf37 {{ .Full }} "
},
{
"type": "python",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"background": "#906cff",
"template": " \udb80\udf20 {{ .Full }} "
},
{
"type": "git",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"trailing_diamond": "\ue0b4",
"background": "p:green",
"background_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}p:yellow{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:red{{ end }}",
"{{ if gt .Ahead 0 }}#49416D{{ end }}",
"{{ if gt .Behind 0 }}#7A306C{{ end }}"
],
"foreground": "p:black",
"foreground_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}p:black{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:white{{ end }}",
"{{ if gt .Ahead 0 }}p:white{{ end }}"
],
"properties": {
"branch_max_length": 25,
"fetch_stash_count": true,
"fetch_status": true,
"fetch_upstream_icon": true,
"upstream_icons": {
"codeberg.org": "\uf330 ",
"git.nuth.ch": "\uf335",
"git.jonascosta.ch": "\uf339 ",
"git.romhackersworld.eu": "\uf339 ",
"aur.archlinux.org": "\uf303 "
}
},
"templates": [
"{{ if .UpstreamURL }} {{ url .UpstreamIcon .UpstreamURL }}{{ end }}",
" {{ .HEAD }} ",
"{{ if .BranchStatus }}{{ .BranchStatus }} {{ end }}",
"{{ if .Working.Changed }} \uf044 {{ .Working.String }} {{ end }}",
"{{ if and (.Working.Changed) (or (.Staging.Changed) (gt .StashCount 0)) }} | {{ end }}",
"{{ if .Staging.Changed }} \uf046 {{ .Staging.String }} {{ end }}",
"{{ if and (.Staging.Changed) (gt .StashCount 0) }} | {{ end }}",
"{{ if gt .StashCount 0 }} \udb80\udd93 {{ .StashCount }}{{ end }} "
]
},
{
"type": "node",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"background": "#6ca35e",
"foreground": "p:white",
"properties": {
"fetch_version": true
},
"template": " \udb80\udf99 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }} "
},
{
"type": "root",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"background": "p:yellow",
"foreground": "p:white",
"properties": {
"root_icon": "\uf0e7"
}
},
{
"type": "executiontime",
"style": "plain",
"background": "#83769c",
"foreground": "p:white",
"properties": {
"always_enabled": true
},
"template": "<transparent>\ue0b0</> \udb81\udead {{ .FormattedMs }}\u2800"
},
{
"type": "text",
"style": "diamond",
"background": "p:blue",
"trailing_diamond": "\ue0b4",
"background_templates": [
"{{ if gt .Code 0 }}p:red{{ end }}"
],
"foreground": "p:white",
"properties": {
"always_enabled": true
},
"template": "<parentBackground>\ue0b0</> {{ if gt .Code 0 }}\uf00d{{ else }}\uf00c{{ end }} "
}
]
}
],
"transient_prompt": {
"background": "transparent",
"foreground": "p:black",
"template": "<p:yellow,transparent>\ue0b6</><,p:yellow> {{ .Folder }} </><p:yellow,transparent>\ue0b0</> "
},
"final_space": true,
"palette": {
"black": "#262B44",
"blue": "#4B95E9",
"green": "#59C9A5",
"orange": "#F07623",
"red": "#D81E5B",
"white": "#E0DEF4",
"yellow": "#F3AE35"
}
}

View file

@ -68,7 +68,7 @@ begin
end | begin
read LOCALES
and arch-chroot "$mountDir" sed -i "s/^#\?\(\($LOCALES\).*\)\$/\1/" /etc/locale.gen
and locale-gen
and arch-chroot "$mountDir" locale-gen
end
and begin

View file

@ -3,11 +3,19 @@ begin
set -l dir (status dirname)
source "$dir/../../Common/Scripts/software.fish"
function runYay -d "Run yay with pre-configured defaults"
yay --needed --answerclean=None --answerdiff=None -Syu $argv
end
function yayinst -d "Install yay-package non-interactively"
yay --noconfirm --needed --answerclean=None --answerdiff=None -Syu $argv
runYay --noconfirm $argv
end
function runPacman -d "Run pacman with pre-configured defaults"
sudo pacman --needed -Syu $argv
end
function pacinst -d "Install pacman-package non-interactively"
sudo pacman --noconfirm --needed -Syu $argv
runPacman --noconfirm $argv
end
end

View file

@ -5,12 +5,12 @@ begin
function installSW
yayinst qemu-full
yes | runPacman --asdeps iptables-nft
yes | yayinst \
virtiofsd \
virt-manager \
dnsmasq \
iptables-nft \
swtpm \
lxc \
virt-bootstrap-git

View file

@ -3,7 +3,7 @@ begin
set -l dir (status dirname)
source "$dir/../../Scripts/software.fish"
function installSW
function installSW -V dir
yayinst \
aliae-bin

View file

@ -4,7 +4,7 @@ begin
source "$dir/../../Scripts/software.fish"
source "$dir/../../../Common/Software/brave/main.fish"
function installSW
function installSW -V dir
yayinst brave-bin (
# brave-beta-bin
# brave-nightly-bin

View file

@ -4,7 +4,7 @@ begin
source "$dir/../../Scripts/software.fish"
source "$dir/../../../Common/Software/git/main.fish"
function installSW
function installSW -V dir
yayinst \
git \
git-lfs \

View file

@ -3,7 +3,7 @@ begin
set -l dir (status dirname)
source "$dir/../../Scripts/software.fish"
function installSW
function installSW -V dir
yayinst grub-theme-minegrub-git
fish "$dir/../../../Common/Software/minegrub-theme/main.fish" configure
end

View file

@ -5,7 +5,7 @@ begin
function installSW -V dir
yayinst nodejs-n
sudo fish "$dir/../../../Common/Software/n/main.fish" configure
sudo --preserve-env --set-home fish "$dir/../../../Common/Software/n/main.fish" configure
end
runInstaller $argv

View file

@ -7,10 +7,12 @@ begin
yayinst \
openssh \
libfido2
source (status filename) configure
end
function configureSW
systemctl --global enable --now ssh-agent
sudo systemctl --global enable ssh-agent
and begin
printf %s\n \

View file

@ -3,7 +3,7 @@ begin
set -l dir (status dirname)
source "$dir/../../Scripts/software.fish"
function installSW
function installSW -V dir
yayinst pyenv
fish "$dir/../../../Common/Software/pyenv/main.fish" configure
end

View file

@ -4,7 +4,7 @@ begin
source "$dir/../../Scripts/software.fish"
source "$dir/../../../Common/Software/vim/main.fish"
function installSW
function installSW -V dir
yayinst (
# Necessary for accessing clipboard in terminal: https://wiki.archlinux.org/title/Vim
) gvim \

View file

@ -3,7 +3,7 @@ begin
set -l dir (status dirname)
source "$dir/../../Scripts/software.fish"
function installSW
function installSW -V dir
yayinst \
zoxide

View file

@ -1,10 +1,10 @@
#!/bin/pwsh
. "$PSScriptRoot/../../Software/powershell/profile.ps1";
. "$PSScriptRoot/../../Software/PowerShell/Profile.ps1";
Add-PowerShellProfileStatement `
-System `
-Category "oh-my-posh" `
-Statement $(
-Script $(
@(
"# Oh My Posh!",
$(Get-ScriptInitializer "oh-my-posh init pwsh"),

View file

@ -1,8 +1,8 @@
#!/bin/pwsh
. "$PSScriptRoot/../../Software/powershell/profile.ps1";
. "$PSScriptRoot/../../Software/PowerShell/Profile.ps1";
foreach ($defaultUser in @($true, $false)) {
Add-PowerShellProfileStatement -DefaultUser:$defaultUser -Statement "# aliae`naliae init pwsh | Invoke-Expression";
Add-PowerShellProfileStatement -DefaultUser:$defaultUser -Script "# aliae`naliae init pwsh | Invoke-Expression";
}
Add-PowerShellProfileStatement -System -Category "aliae" -Statement "# aliae`n$(Get-ScriptInitializer "aliae completion powershell")";
Add-PowerShellProfileStatement -System -Category "aliae" -Script "# aliae`n$(Get-ScriptInitializer "aliae completion powershell")";

View file

@ -1,10 +1,10 @@
#!/bin/pwsh
. "$PSScriptRoot/../../Software/powershell/profile.ps1";
. "$PSScriptRoot/../../Software/PowerShell/Profile.ps1";
Add-PowerShellProfileStatement `
-System `
-Category "zoxide" `
-Statement $(
-Script $(
@(
"# zoxide",
$(Get-ScriptInitializer "zoxide init powershell | Out-String")

View file

@ -6,6 +6,7 @@ source "$dir/../Scripts/hooks.fish"
if [ (id -u) -eq 0 ]
set -l name (getConfig valhalla.setupUser.name)
set -l sudoConfig "/etc/sudoers.d/PortValhalla"
rm ~/.bash_profile
runHook createUser || \
begin
@ -23,7 +24,7 @@ if [ (id -u) -eq 0 ]
echo "$name ALL=(ALL:ALL) NOPASSWD: ALL"
end > "$sudoConfig"
and sudo --preserve-env="CONFIG_MODULE" --user "$name" "$INSTALLER_SCRIPT"
and sudo --preserve-env="CONFIG_NAME" --user "$name" "$INSTALLER_SCRIPT"
rm "$sudoConfig"
userdel -r "$name"
else

View file

@ -39,7 +39,7 @@ function runSetup
function wrapScript -S
printf %s\n \
"cd $PROJECT_CLONE_ROOT" \
"export CONFIG_MODULE=$(string escape (getCloneFile "$CONFIG_MODULE"))" \
"export CONFIG_NAME=$(string escape (getCloneFile "$CONFIG_NAME"))" \
"$argv"
end

View file

@ -0,0 +1,163 @@
#!/bin/bash
$null = New-Module {
. "$PSScriptRoot/System.ps1";
<#
.SYNOPSIS
Runs an action involving browser automation.
.PARAMETER Action
The action to execute.
#>
function Start-BrowserAutomation {
param(
[scriptblock] $Action
)
if (-not ("OpenQA.Selenium.Firefox.FirefoxDriver" -as [type])) {
$packageRoot = Split-Path -Parent (Get-Package Selenium.WebDriver).Source;
$file = Join-Path $packageRoot "lib/netstandard2.0/WebDriver.dll";
$env:SE_MANAGER_PATH = Join-Path $packageRoot "manager" ($IsWindows ? "windows" : "linux") "selenium-manager$($IsWindows ? ".exe" : '')";
$null = [System.Reflection.Assembly]::LoadFile($file);
}
& $Action;
}
<#
.SYNOPSIS
Downloads a file from the specified url using browser automation.
.PARAMETER URL
The url to download the file from.
.PARAMETER Action
The action to execute in the browser for initiating the download.
.PARAMETER OutDir
The directory to download the file to.
#>
function Start-CustomBrowserDownload {
param(
[string] $URL,
[scriptblock] $Action,
[string] $OutDir
)
$downloadAction = $Action;
Start-BrowserAutomation {
if (-not $OutDir) {
$OutDir = ".";
}
$dir = New-TemporaryDirectory;
Write-Host "Downloading ``$URL`` using browser automation…";
$options = [OpenQA.Selenium.Firefox.FirefoxOptions]::new();
$options.SetPreference("browser.download.folderList", 2);
$options.SetPreference("browser.download.dir", "$dir");
$downloadChecker = {
$files = Get-ChildItem $dir;
if ((@($files)).Count -eq 1) {
$file = $files[0];
try {
$stream = [System.IO.File]::Open($file.FullName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None);
if ($stream) {
$stream.Close();
}
}
catch {
return $true;
}
return $false;
} else {
return $true;
}
};
$browser = [OpenQA.Selenium.Firefox.FirefoxDriver]::new($options);
$browser.Navigate().GoToUrl($URL);
while (-not ($browser.ExecuteScript("return document.readyState;") -eq "complete")) {
Start-Sleep 0.1;
}
try {
$null = & $downloadAction -Browser $browser;
while (& $downloadChecker) {
Write-Host "Waiting for the download to finish…";
Start-Sleep 1;
}
$file = Get-ChildItem $dir;
$result = Move-Item $file $OutDir -PassThru;
$browser.Quit();
Remove-Item -Recurse $dir;
$result;
}
catch {
Write-Error $Error;
}
}
}
<#
.SYNOPSIS
Downloads a file from the specified url using browser automation.
.PARAMETER URL
The url to download the file from.
.PARAMETER ButtonSelector
The jQuery selector for finding the download button.
.PARAMETER OutDir
The directory to download the file to.
.PARAMETER Timeout
The number of seconds to wait before clicking the download button.
#>
function Start-BrowserDownload {
param(
[string] $URL,
[string] $ButtonSelector,
[string] $OutDir = $null,
[double] $Timeout = 0
)
Start-CustomBrowserDownload @PSBoundParameters -Action {
param(
[OpenQA.Selenium.Firefox.FirefoxDriver] $Browser
)
$selector = [OpenQA.Selenium.By]::CssSelector($ButtonSelector);
[OpenQA.Selenium.IWebElement] $element = $null;
for ($i = 0; $i -lt 5; $i++) {
$element = $Browser.FindElement($selector);
if ($element) {
break;
} else {
Start-Sleep 1;
}
}
if ($Timeout -gt 0) {
Start-Sleep $Timeout;
}
if ($element) {
$Browser.FindElement($selector).Click();
} else {
Write-Error "Unable to find download button!";
}
};
}
};

View file

@ -0,0 +1,575 @@
using namespace Microsoft.Win32;
using namespace System.Management.Automation.Host;
using namespace System.Security.AccessControl;
using namespace System.Security.Principal;
enum WindowsInstallerStage {
Initialize
Run
Cleanup
Completed
}
enum SetupStage {
Initialize
Configure
Install
CreateUser
}
enum BackupStage {
Initialize
Backup
BackupUsers
}
enum UserStage {
Create
Configure
Cleanup
Completed
}
$null = New-Module {
[string] $configRoot = "HKLM:\Software\PortValhalla";
[string] $stageOption = "Stage";
[string] $setupStageOption = "SetupStage";
[string] $backupStageOption = "BackupStage";
[string] $userOption = "SetupUser";
[string] $userStageOption = "UserStage";
[string] $accountOption = "MSAccount";
[string] $finishedOption = "Finished";
[RegistryKey] $key = $null;
<#
.SYNOPSIS
Prompts the user to select a profile to act on.
#>
function Show-ProfileNamePrompt {
. "$PSScriptRoot/../../Windows/Types/WindowsInstallerAction.ps1";
$profiles = & {
. "$PSScriptRoot/SoftwareManagement.ps1";
if (Test-Command "wsl") {
return Invoke-ConfigScript "getProfiles";
} else {
return Get-ChildItem "$PSScriptRoot/../../../.config" | ForEach-Object { Split-Path -LeafBase $_ };
}
};
$choice = $Host.UI.PromptForChoice(
"Select Profile",
(& {
switch (Get-Stage) {
([WindowsInstallerAction]::Backup) {
"Which profile do you wish to back up?";
}
([WindowsInstallerAction]::Install) {
"Which profile do you wish to install?";
}
$null {
"Which profile do you wish to set up?";
}
}
}),
(& {
for ($i = 0; $i -lt $profiles.Count; $i++) {
[ChoiceDescription]"&$i - $($profiles[$i])";
}
[ChoiceDescription]"&Abort";
}),
$profiles.Count);
if ($choice -eq $profiles.Count) {
exit;
} else {
$env:CONFIG_NAME = $profiles[$choice];
}
}
<#
.SYNOPSIS
Converts the specified path to linux and escapes it for the use in a script.
.PARAMETER Path
The path to convert.
#>
function ConvertTo-LinuxPath {
param(
[string] $Path
)
& {
$ErrorActionPreference = 'Continue';
$completed = $false;
while (-not $completed) {
$job = Start-Job {
$env:Value = Resolve-Path $Using:Path;
$env:WSLENV = "Value/p";
$result = wsl -- bash -c 'echo "$Value"';
wsl -e printf "%q" "$result";
};
$result = Receive-Job -Wait $job;
if ((Split-Path -Leaf $Path) -ne (Split-Path -Leaf $result)) {
Write-Error "The result of the path conversion of ``$Path`` was unexpected: ``$result``";
continue;
}
if ($job.State -ne ([System.Management.Automation.JobState]::Completed)) {
Write-Error "An error occurred while converting ``$Path`` to a Linux path.`nOutput: ``$result``";
continue;
}
$completed = $true;
}
$result;
};
}
<#
.SYNOPSIS
Gets the registry key containing options related to the setup.
#>
function Get-SetupConfigKey {
if (-not (Test-Path $configRoot)) {
$key = New-Item $configRoot;
$acl = Get-Acl $configRoot;
$acl.AddAccessRule(
[RegistryAccessRule]::new(
[SecurityIdentifier]::new([WellKnownSidType]::BuiltinUsersSid, $null),
[RegistryRights]::FullControl,
[InheritanceFlags]::ObjectInherit -bor [InheritanceFlags]::ContainerInherit,
[PropagationFlags]::None,
[AccessControlType]::Allow));
Set-Acl $configRoot $acl;
} else {
$key = Get-Item $configRoot;
}
return $key;
}
<#
.SYNOPSIS
Runs a script based on the `config.fish` script.
.PARAMETER Script
The script to run.
#>
function Invoke-ConfigScript {
param(
[string] $Script
)
$scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish";
if ($env:CONFIG_NAME -or ($Script -eq "getProfiles")) {
$output = & {
if (-not $IsWindows) {
$escapedPath = (fish -c 'string escape $argv' "$scriptPath");
fish -c ". $escapedPath; $Script";
} else {
$cleanup = { };
$projectRoot = "$PSScriptRoot/../../..";
$archisoDir = "$projectRoot/archiso";
function fish {
wsl --shell-type login -- nix --extra-experimental-features "nix-command flakes" run nixpkgs`#fish -- $args
}
if (Test-Path -PathType Container "$archisoDir") {
$git = {
git -C "$projectRoot" -c safe.directory="$("$(Resolve-Path $projectRoot)".Replace("\", "/"))" @args;
};
& $git rm -r --cached "$archisoDir" *> $null;
$cleanup = { & $git restore --staged "$archisoDir" };
}
$output = fish -c ". $(ConvertTo-LinuxPath $scriptPath); $Script";
if (-not $?) {
Write-Error "The configuration could not be retrieved!";
} else {
$output;
}
& $cleanup *> $null;
}
}
if (-not ($output -and ($output | Test-Json))) {
Write-Error "The value ``$output`` is not valid JSON.";
} else {
$output | ConvertFrom-Json;
}
} else {
$null;
}
}
<#
.SYNOPSIS
Gets a configuration option.
.PARAMETER Name
The name of the option to get.
#>
function Get-Config {
param(
[string] $Name,
[Parameter(ValueFromRemainingArguments)]
[string[]] $ArgumentList
)
Invoke-ConfigScript "getConfig $Name --json $ArgumentList";
}
<#
.SYNOPSIS
Gets the name of the config root.
#>
function Get-ConfigRootName {
return "valhalla.$($IsWindows ? "windows" : "linux")";
}
<#
.SYNOPSIS
Gets the name of the user root.
#>
function Get-UserRootName {
return "$(Get-ConfigRootName).$($IsWindows ? "winUsers" : "users")";
};
<#
.SYNOPSIS
Gets a user configuration.
.PARAMETER UserName
The name of the user to get the configuration for.
.PARAMETER Name
The name of the configuration to get.
#>
function Get-UserConfig {
param(
[string] $UserName = ($IsWindows ? $env:UserName : $env:USER),
[Parameter(Mandatory, Position = 0)]
[string] $Name
)
if ((Get-Users) -contains $UserName) {
Get-Config "$(Get-UserRootName).$UserName.$Name";
} else {
return $null;
}
}
<#
.SYNOPSIS
Gets the attributes of a configuration object.
.PARAMETER Name
The name of the configuration to get the attributes of.
#>
function Get-Attributes {
param(
[string] $Name
)
Invoke-ConfigScript "getAttributes $Name";
}
<#
.SYNOPSIS
Gets the names of the users to create.
#>
function Get-Users {
[OutputType([string[]])]
param()
Get-Attributes "$(Get-UserRootName)";
}
<#
.SYNOPSIS
Gets the name of the setup user.
#>
function Get-SetupUser {
[OutputType([string])]
param()
Get-Config "$(Get-ConfigRootName).setupUser.name";
}
<#
.SYNOPSIS
Gets the value of an option related to the setup.
.PARAMETER Name
The name of the option value to get.
#>
function Get-SetupOption {
param(
[string] $Name
)
$key = Get-SetupConfigKey;
if ($key.GetValueNames().Contains($Name)) {
return $key.GetValue($Name);
} else {
return $null;
}
}
<#
.SYNOPSIS
Sets the value of an option related to the setup.
.PARAMETER Name
The name of the option to set.
.PARAMETER Value
The value to set the option to.
#>
function Set-SetupOption {
param(
[string] $Name,
$Value
)
$key = Get-SetupConfigKey;
$null = Set-ItemProperty ($key.PSPath) -Name $Name -Value $Value;
}
<#
.SYNOPSIS
Gets the name of the current stage of the Windows install script action.
#>
function Get-Stage {
$stage = Get-SetupOption $stageOption;
if ($null -ne $stage) {
$stage = [WindowsInstallerStage]$stage;
}
return $stage;
}
<#
.SYNOPSIS
Sets the name of the current stage of the Windows install script action.
.PARAMETER Name
The name of the stage to set.
#>
function Set-Stage {
param(
$Name
)
if (-not (($null -eq $Name) -or ($Name -is [string]))) {
$Name = ([WindowsInstallerStage]$Name).ToString();
}
$null = Set-SetupOption $stageOption $Name;
}
<#
.SYNOPSIS
Gets the name of the current setup stage.
#>
function Get-SetupStage {
$stage = Get-SetupOption $setupStageOption;
if ($null -ne $stage) {
$stage = [SetupStage]$stage;
}
return $stage;
}
<#
.SYNOPSIS
Sets the current stage.
.PARAMETER Name
The name to set the current stage to.
#>
function Set-SetupStage {
param(
$Name
)
if (-not (($null -eq $Name) -or ($Name -is [string]))) {
$Name = ([SetupStage]$Name).ToString();
}
$null = Set-SetupOption $setupStageOption $Name;
}
<#
.SYNOPSIS
Gets the name of the current stage of the backup.
#>
function Get-BackupStage {
$stage = Get-SetupOption $backupStageOption;
if ($null -ne $stage) {
$stage = [BackupStage]$stage;
}
return $stage;
}
<#
.SYNOPSIS
Sets the current stage of the backup.
.PARAMETER Name
The name to set the current stage to.
#>
function Set-BackupStage {
param(
$Name
)
if (-not (($null -eq $Name) -or ($Name -is [string]))) {
$Name = ([BackupStage]$Name).ToString();
}
$null = Set-SetupOption $backupStageOption $Name;
}
<#
.SYNOPSIS
Gets the current user to set up.
#>
function Get-CurrentUser {
return (Get-SetupOption $userOption) ?? 0;
}
<#
.SYNOPSIS
Sets the index of the current user to set up.
.PARAMETER Value
The index of the user to set up.
#>
function Set-CurrentUser {
param(
[int] $Value
)
Set-SetupOption $userOption $value;
}
<#
.SYNOPSIS
Gets the name of the current stage of the user setup.
#>
function Get-UserStage {
$stage = Get-SetupOption $userStageOption;
if ($null -ne $stage) {
$stage = [UserStage]$stage;
}
return $stage;
}
<#
.SYNOPSIS
Sets the current stage of the user setup.
.PARAMETER Name
The name of the stage to set.
#>
function Set-UserStage {
param(
$Name
)
if (-not (($null -eq $Name) -or ($Name -is [string]))) {
$Name = ([UserStage]$Name).ToString();
}
$null = Set-SetupOption $userStageOption $Name;
}
<#
.SYNOPSIS
Gets the name of the microsoft account to create.
#>
function Get-MSAccountName {
return Get-SetupOption $accountOption;
}
<#
.SYNOPSIS
Sets the name of the microsoft account to create.
.PARAMETER Name
The name of the microsoft account to create.
#>
function Set-MSAccountName {
param(
[string] $Name
)
Set-SetupOption $accountOption $Name;
}
<#
.SYNOPSIS
Gets a value indicating whether the setup has finished.
#>
function Get-IsFinished {
return [bool](Get-SetupOption $finishedOption);
}
<#
.SYNOPSIS
Sets a value indicating whether the setup has finished.
#>
function Set-IsFinished {
param(
$Value
)
Set-SetupOption $finishedOption $true;
}
<#
.SYNOPSIS
Checks whether the running system is a QEMU virtual machine.
#>
function Test-Qemu {
((Get-WmiObject win32_computersystem).Manufacturer) -eq "QEMU";
}
<#
.SYNOPSIS
Checks whether the current user is the setup user.
#>
function Test-SetupUser {
($IsWindows ? $env:UserName : $env:USER) -eq (Get-SetupUser);
}
<#
.SYNOPSIS
Checks whether the active session is executed with admin rights.
#>
function Test-Admin {
net session 2> $null | Out-Null;
return $?;
}
}

View file

@ -1,6 +1,6 @@
#!/bin/pwsh
. "$PSScriptRoot/Entrypoints.ps1";
. "$PSScriptRoot/../../Common/Software/powershell/profile.ps1";
. "$PSScriptRoot/../../Common/Scripts/Entrypoints.ps1";
. "$PSScriptRoot/../../Common/Software/PowerShell/Profile.ps1";
class Context {
[string]$EntryPoint;
@ -68,9 +68,9 @@ class Context {
[void] AddPowerShellProfileStatement([bool] $system, [string] $category, [string] $statement, [bool] $overwrite) {
if ($system) {
Add-PowerShellProfileStatement -System -Category $category -Statement $statement -Overwrite $overwrite;
Add-PowerShellProfileStatement -System -Category $category -Script $statement -Overwrite:$overwrite;
} else {
Add-PowerShellProfileStatement -Category $category -Statement $statement -Overwrite $overwrite;
Add-PowerShellProfileStatement -Category $category -Script $statement -Overwrite:$overwrite;
}
}

View file

@ -0,0 +1,429 @@
using namespace System.Management.Automation.Host;
. "$PSScriptRoot/../Types/OneShotTask.ps1";
$null = New-Module {
. "$PSScriptRoot/Config.ps1";
. "$PSScriptRoot/../Scripts/SoftwareManagement.ps1";
. "$PSScriptRoot/../Types/OneShotTask.ps1";
. "$PSScriptRoot/../../Windows/Scripts/Hooks.ps1";
. "$PSScriptRoot/../../Windows/Scripts/PowerManagement.ps1";
. "$PSScriptRoot/../../Windows/Scripts/Registry.ps1";
. "$PSScriptRoot/../../Windows/Scripts/Security.ps1";
. "$PSScriptRoot/../../Windows/Scripts/WSL.ps1";
$oneShotTaskName = "PortValhalla OneShot";
$logName = "Application";
$oneShotTrigger = 1337;
$taskOption = "OneShotTask";
# ToDo: Store "ProgramData/PortValhalla" path somewhere as const
$errorPath = "$env:ProgramData/PortValhalla/error.txt";
$getUserName = {
"$(Get-SetupUser)OneShot";
};
$taskSetter = {
param([Nullable[OneShotTask]] $Task)
Set-SetupOption $taskOption ([string]$Task);
};
<#
.SYNOPSIS
Gets the PowerShell modules required for operating.
#>
function Get-RequiredModules {
$modules = @(
@("PSScriptAnalyzer")
) + (& {
if (-not $IsWindows) {
@()
} else {
@(
@("KnownFolders"),
@("PSWindowsUpdate"),
@("LocalAccounts", $true),
@("NuGet")
)
}
});
for ($i = 0; $i -lt $modules.Count; $i++) {
if ($modules[$i] -is [string]) {
$modules[$i] = @($modules[$i]);
}
}
return $modules;
}
function Start-Operation {
param(
[switch] $NonInteractive,
[switch] $NoImplicitCleanup,
[scriptblock] $Action
)
$cleanup = { };
$taskPending = $false;
if (-not $Global:InOperation) {
if ($env:DEBUG) {
Set-PSDebug -Trace 1;
}
if ($IsWindows -and ($null -ne (Get-OneShotTask))) {
$taskPending = $true;
[switch] $NonInteractive = $true;
}
$Global:InOperation = $true;
$Global:ErrorActionPreference = $NonInteractive.IsPresent ? 'Continue' : 'Inquire';
if ($IsWindows) {
$env:WSLENV = "CONFIG_NAME";
New-Alias -Force "sudo" gsudo;
}
if (-not $NoImplicitCleanup.IsPresent) {
$cleanup = {
Clear-OperationResources;
};
}
& {
$initialized = $false;
while (-not $initialized) {
if ($IsWindows) {
if (-not ((Test-Command "choco") -and (Test-Command "refreshenv"))) {
Invoke-Hook "Install-Chocolatey" -Fallback {
# Install chocolatey
New-Item -Force $PROFILE;
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'));
Import-Module $env:ChocolateyInstall/helpers/chocolateyProfile.psm1;
refreshenv;
};
continue;
}
if (-not (Test-ChocoPackage "powershell-core")) {
Invoke-Hook "Install-PowerShellCore" -Fallback {
choco install -y powershell-core --install-arguments='"ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1 ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 REGISTER_MANIFEST=1 USER_MU=1 ENABLE_MU=1"';
};
Restart-Intermediate;
return;
}
if ($env:PWSH_PATH -and (Test-Path $env:PWSH_PATH)) {
attrib "-R" "$env:PWSH_PATH\*" /S /D;
Remove-Item -Recurse -Force $env:PWSH_PATH;
continue;
}
if ($env:DEBUG) {
$liveScriptOption = "LiveScripts";
if (($null -eq (Get-SetupOption $liveScriptOption)) -and (Test-Qemu)) {
$result = $Host.UI.PromptForChoice(
"Confirm",
"Do you wish to swap to live scripts?",
[ChoiceDescription[]]@(
[ChoiceDescription]::new("&No", "Use scripts stored in the virtual machine"),
[ChoiceDescription]::new("&Yes", "Use live scripts stored on the host")),
0);
Set-SetupOption $liveScriptOption $result;
if ($result -eq 1) {
Install-ChocoPackage winfsp qemu-guest-agent;
Get-Service VirtioFsSvc | Start-Service -PassThru | Set-Service -StartupType Automatic;
while (-not (Test-Path Z:\)) {
Start-Sleep 0.1;
}
foreach ($name in @("INSTALLER_SCRIPT")) {
$variable = Get-Item "Env:\$name";
$path = Join-Path `
"Z:\Repositories\PortValhalla" `
([System.IO.Path]::GetRelativePath("$PSScriptRoot/../../..", $variable.Value));
Set-Item "Env:\$name" $path;
Write-Host "The new value of ``$name`` is ``$path``";
}
Restart-Intermediate;
exit;
}
}
}
if (-not (Test-Command "gsudo")) {
Install-ChocoPackage gsudo;
refreshenv;
continue;
}
if ($env:DEBUG) {
& {
$sys32 = "$env:WINDIR/System32";
$osk = (Get-Item "$sys32/osk.exe").FullName;
$cmd = (Get-Item "$sys32/cmd.exe").FullName;
if ((Get-FileHash $osk).Hash -ne (Get-FileHash $cmd).Hash) {
Set-MpPreference -ExclusionPath $osk;
gsudo -d --ti move $osk "${osk}_";
gsudo -d -s copy $cmd $osk;
continue;
}
};
}
if (-not (Test-Winget)) {
. "$PSScriptRoot/../../Windows/Software/winget/Manage.ps1";
continue;
}
if (-not (Test-Command "git")) {
Install-WingetPackage Git.Git;
refreshenv;
continue;
}
if (-not (Test-Command "7z")) {
Install-ChocoPackage 7zip.portable;
refreshenv;
continue;
}
if (-not (Test-Command "yq")) {
Install-ChocoPackage "yq";
refreshenv;
continue;
}
if (-not (Test-Wsl)) {
Install-Wsl;
Restart-Intermediate;
return;
}
if (-not (Test-WslDistribution)) {
if (-not (Test-Path (Get-WslDistributionDisk))) {
Install-WslDistribution;
}
Register-WslDistribution;
continue;
}
if (-not (wsl --shell-type login type -t nix)) {
wsl -- sh `<`(curl -L https://nixos.org/nix/install`) --daemon --yes;
wsl --shutdown;
continue;
}
if (-not (Test-PSPackage Selenium.WebDriver)) {
Write-Host "Installing browser automation tools…";
$null = Install-Package -Force Selenium.WebDriver -RequiredVersion 4.24.0 -SkipDependencies;
continue;
}
Install-ChocoPackage selenium-gecko-driver firefox;
Install-WingetPackage AutoHotkey.AutoHotkey;
. "$PSScriptRoot/../../Windows/Software/PinnedItem/Manage.ps1";
}
Invoke-Hook "Install-PSModules" -Fallback {
foreach ($module in (Get-RequiredModules)) {
$parameters = @{ };
if ($module -is [string]) {
$module = @($module);
}
if ($module[1]) {
$parameters = @{
allowPrerelease = $true;
};
}
if (-not (Test-PSModule $module[0])) {
Install-Module -Scope AllUsers -AcceptLicense -Force -AllowClobber $module[0] @parameters;
Import-Module $module[0];
}
}
};
if (-not $env:CONFIG_NAME) {
Show-ProfileNamePrompt;
}
$initialized = $true;
}
}
}
if ($taskPending) {
Start-OneShot;
} else {
& $Action;
}
& $cleanup;
}
<#
.SYNOPSIS
Gets the current OneShot task.
#>
function Get-OneShotTask {
$task = Get-SetupOption $taskOption;
if ($task) {
return [OneShotTask]$task;
} else {
return $null;
}
}
<#
.SYNOPSIS
Registers a task for listening to OneShot invocations.
#>
function Enable-OneShotListener {
$tempTask = "PortValhalla Temp";
$user = & $getUserName;
$password = [string]([guid]::NewGuid());
$adminGroup = @{
SID = [SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null);
};
$null = New-LocalUser -Name $user -Password (ConvertTo-SecureString -AsPlainText $password);
Add-LocalGroupMember -Member $user @adminGroup;
$path = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList";
$null = New-Item -Force -ErrorAction SilentlyContinue $path;
Set-ItemProperty $path -Name $user -Value 0;
$action = New-ScheduledTaskAction -Execute "pwsh" -Argument "-Command & { $([string](Get-StartupCommand)) } 2>&1 | Tee-Object -FilePath `$env:ProgramData/PortValhalla/OneShotTask.log";
schtasks /Create /SC ONEVENT /EC $logName /MO "*[System[Provider[@Name='$logName'] and EventID=$($oneShotTrigger)]]" /TR cmd.exe /TN $tempTask;
$trigger = (Get-ScheduledTask $tempTask).Triggers;
$null = Register-ScheduledTask -Force $oneShotTaskName -Action $action -Trigger $trigger -RunLevel Highest -User $user -Password $password;
$null = Unregister-ScheduledTask -Confirm:$false $tempTask;
}
<#
.SYNOPSIS
Removes the OneShot task.
#>
function Disable-OneShotListener {
Unregister-ScheduledTask -Confirm:$false $oneShotTaskName;
$user = Get-LocalUser (& $getUserName);
[string] $sid = $user.SID;
Remove-LocalUser $user;
Get-CimInstance Win32_UserProfile | Where-Object { $_.SID -eq $sid } | Remove-CimInstance;
}
<#
.SYNOPSIS
Invokes a one-shot task.
.PARAMETER Task
The task to run.
#>
function Invoke-OneShot {
param(
[OneShotTask] $Task
)
& $taskSetter $Task;
& {
$identifier = "EventLog$oneShotTrigger";
$log = [System.Diagnostics.EventLog]::new($logName);
$log.EnableRaisingEvents = $true;
$null = Register-ObjectEvent -InputObject $log -EventName EntryWritten -Action {
$entry = $Event.SourceEventArgs.Entry;
$trigger = $Event.MessageData.Trigger;
$identifier = $Event.MessageData.Identifier;
if ($entry.EventID -eq $trigger) {
$null = New-Event -SourceIdentifier $identifier;
}
} `
-MessageData @{
Trigger = $oneShotTrigger;
Identifier = $identifier;
};
Write-EventLog -LogName $logName -Source $logName -EventId $oneShotTrigger -Message "Starting OneShot task ``$(Get-OneShotTask)``";
for ($i = 0; $i -lt 2; $i++) {
Remove-Event -EventIdentifier (Wait-Event -SourceIdentifier $identifier).EventIdentifier;
}
};
if (Test-Path $errorPath) {
$errorMessage = Get-Content $errorPath;
Remove-Item $errorPath;
if ($errorMessage) {
Write-Error $errorMessage;
}
}
}
# ToDo: Store Run-OneShot and Receive-OneShot somewhere else in Windows folder
<#
.SYNOPSIS
Executes the specified action and notifies the OneShot task executor.
#>
function Start-OneShot {
try {
Write-Host "Running OneShot task ``$(Get-OneShotTask)``";
switch (Get-OneShotTask) {
([OneShotTask]::InitializeMSAccount) {
Initialize-UserCreation;
}
([OneShotTask]::DisableUAC) {
Disable-UAC;
Register-Setup;
}
}
}
catch {
Set-Content -Path $errorPath -Value $Error;
Set-UserPermissions $errorPath;
}
finally {
& $taskSetter $null;
Write-EventLog -LogName $logName -Source $logName -EventId $oneShotTrigger -Message "The OneShot task ``$(Get-OneShotTask)`` finished.";
}
}
<#
.SYNOPSIS
Clears resources allocated during the operation.
#>
function Clear-OperationResources {
if ($IsWindows) {
Uninstall-WslDistribution;
$null = Uninstall-Package Selenium.WebDriver -ErrorAction Continue;
Uninstall-ChocoPackage 7zip.portable gsudo selenium-gecko-driver yq;
Uninstall-WingetPackage AutoHotkey.AutoHotkey;
}
foreach ($module in (Get-RequiredModules)) {
Remove-Module -Force $module[0];
Uninstall-Module -Force -Name $module[0] -ErrorAction SilentlyContinue;
}
}
};

View file

@ -0,0 +1,71 @@
<#
.SYNOPSIS
Converts the specified value into a form to safle inject it into a script.
.PARAMETER value
The value to convert for injection.
#>
function ConvertTo-Injection {
param(
$Value
)
"([System.Text.Encoding]::Default.GetString([System.Convert]::FromBase64String('$(
[System.Convert]::ToBase64String([System.Text.Encoding]::Default.GetBytes($value))
)')))"
}
<#
.SYNOPSIS
Writes a PowerShell script to a specified location.
.PARAMETER FileName
The name of the file to write the script to.
.PARAMETER Script
The script to write to the file.
.PARAMETER Replace
A value indicating whether the file should be overwritten if it exists.
.PARAMETER Append
A value indicating whether the content should be appended if the file already exists.
#>
function Write-PSScript {
param(
[Parameter(Mandatory=$true)]
[Parameter(ParameterSetName="Common")]
[Parameter(ParameterSetName="Replace")]
[Parameter(ParameterSetName="Append")]
[string] $FileName,
[Parameter(Mandatory=$true)]
[Parameter(ParameterSetName="Common")]
[Parameter(ParameterSetName="Replace")]
[Parameter(ParameterSetName="Append")]
[string] $Script,
[Parameter(ParameterSetName="Replace", Mandatory=$true)]
[switch] $Replace,
[Parameter(ParameterSetName="Append", Mandatory=$true)]
[switch] $Append
)
Import-Module PSScriptAnalyzer;
$dirName = Split-Path -Parent $FileName;
$Script = ($Script -split "\r?\n") -join [System.Environment]::NewLine;
$content = Invoke-Formatter -ScriptDefinition $Script;
$exists = Test-Path -PathType Leaf $FileName;
if (-not (Test-Path -PathType Container $dirName)) {
$null = New-Item -ItemType Directory $dirName;
}
if ($exists -and ($Append.IsPresent)) {
Add-Content -Force $FileName "`n$content";
} else {
if ((-not $exists) -or $Replace.IsPresent) {
Set-Content -Force $FileName $content;
} else {
Write-Host "The file ``$FileName`` already exists!";
}
}
}

View file

@ -0,0 +1,392 @@
. "$PSScriptRoot/Config.ps1";
. "$PSScriptRoot/Operations.ps1";
. "$PSScriptRoot/System.ps1";
. "$PSScriptRoot/../Types/InstallerAction.ps1";
$null = New-Module {
. "$PSScriptRoot/BrowserAutomation.ps1";
. "$PSScriptRoot/SoftwareManagement.ps1";
. "$PSScriptRoot/../Types/InstallerAction.ps1";
$userArgument = "name";
$chocoRunner = {
param(
[string] $Action = 'install',
[string[]] $ArgumentList,
[scriptblock] $Guard = { $true },
[Parameter(Position = 0)]
[string] $Name,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]] $AdditionalNames = @()
)
[System.Collections.ArrayList] $Names = @();
$null = $Names.Add($Name);
$Names.AddRange($AdditionalNames);
if (-not ($Force.IsPresent)) {
for ($i = $Names.Count - 1; $i -ge 0; $i--) {
$name = $Names[$i];
if (-not (& $Guard $name)) {
$Names.RemoveAt($i);
}
}
}
if ($Names.Count -ge 1) {
choco $Action -y @ArgumentList @Names;
}
};
$wingetRunner = {
param(
[string] $Action = 'install',
[string[]] $ArgumentList,
[scriptblock] $Guard = { $true },
[Parameter(Position = 0)]
[string] $Name,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]] $AdditionalNames = @()
)
[System.Collections.ArrayList] $Names = @();
$null = $Names.Add($Name);
$Names.AddRange($AdditionalNames);
[string[]] $arguments = $ArgumentList + (& {
if ($Action -eq 'install') {
@("--accept-package-agreements")
};
});
foreach ($name in $Names) {
if ($Force.IsPresent -or (& $Guard $name $PSBoundParameters)) {
winget $Action `
--accept-source-agreements `
--source winget `
@arguments `
--exact --id $name ;
} else {
Write-Host "Package ``$name`` is already installed"
}
}
};
<#
.SYNOPSIS
Installs the specified packages using chocolatey.
.PARAMETER Names
The names of the packages to install.
#>
function Install-ChocoPackage {
param(
[switch] $Force,
[string[]] $ArgumentList,
[Parameter(Position=0)]
[string] $Name,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]] $AdditionalNames = @()
)
& $chocoRunner @PSBoundParameters -Guard {
param($Name)
if (Test-ChocoPackage $Name) {
Write-Host "Package ``$Name`` is already installed"
$false;
} else {
$true;
}
};
}
<#
.SYNOPSIS
Uninstalls the specified packages using chocolatey.
#>
function Uninstall-ChocoPackage {
param(
[string[]] $ArgumentList,
[Parameter(Position=0)]
[string] $Name,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]] $AdditionalNames = @()
)
& $chocoRunner @PSBoundParameters -Action 'uninstall' -Guard {
param($Name)
if (Test-ChocoPackage $Name) {
$true;
} else {
Write-Host "Package ``$Name`` is not installed";
$false;
}
};
}
<#
.SYNOPSIS
Installs the specified packages using `winget`.
.PARAMETER Names
The names of the packages to install.
#>
function Install-WingetPackage {
param(
[switch] $Force,
[string[]] $ArgumentList,
[Parameter(Position=0)]
[string] $Name,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]] $AdditionalNames = @()
)
& $wingetRunner @PSBoundParameters `
-Guard {
param($Name, $Parameters)
if (Test-WingetPackage @Parameters) {
Write-Host "Package ``$Name`` is already installed"
$false;
} else {
$true;
}
};
}
<#
.SYNOPSIS
Uninstalls the specified packages using `winget`.
#>
function Uninstall-WingetPackage {
param(
[string[]] $ArgumentList,
[Parameter(Position=0)]
[string] $Name,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]] $AdditionalNames = @()
)
& $wingetRunner @PSBoundParameters -Action 'uninstall' -Guard {
param($Name, $Parameters)
if (Test-WingetPackage @Parameters) {
$true;
} else {
Write-Host "Package ``$Name`` is not installed"
$false;
}
};
}
<#
.SYNOPSIS
Installs a setup package from the specified source.
.PARAMETER Source
The location of the setup package.
.PARAMETER ArgumentList
The arguments to pass to the setup package.
.PARAMETER Local
A value indicating whether the setup package is stored locally.
#>
function Install-SetupPackage {
param(
[string] $Source,
[string[]] $ArgumentList = @("/S"),
[switch] $Local
)
[string] $dir = $null;
[string] $filePath = $null;
if (-not ($Local.IsPresent)) {
$dir = New-TemporaryDirectory;
Write-Host "Determining the file name of ``$Source``";
$fileName = ([uri]$Source).Segments[-1];
Write-Host "Found name ``$fileName``";
$filePath = Join-Path $dir $fileName;
Write-Host "Downloading setup file from ``$Source``";
Invoke-WebRequest $Source -OutFile $filePath;
} else {
$filePath = $Source;
}
Write-Host "Starting installation of ``$(Split-Path -Leaf $filePath)``";
Start-Process -Wait -WorkingDirectory (Split-Path -Parent $filePath) -FilePath $filePath -ArgumentList $ArgumentList;
if ($dir) {
Remove-Item -Recurse $dir;
}
}
<#
.SYNOPSIS
Installs a package downloaded from ASUS.
.PARAMETER URL
The URL to download the package from.
#>
function Install-AsusPackage {
param(
[string] $URL
)
$file = "AsusPackage.zip";
$dir = New-TemporaryDirectory;
$unpackDir = New-TemporaryDirectory;
$null = Push-Location $dir;
Invoke-WebRequest $URL -OutFile $file;
Expand-Archive $file $unpackDir;
$null = Pop-Location;
Remove-Item -Recurse $dir;
$null = Start-Process -Wait -WorkingDirectory $unpackDir -FilePath (Join-Path $unpackDir "AsusSetup.exe") -ArgumentList "/S";
Remove-Item -Recurse $unpackDir;
}
<#
.SYNOPSIS
Downloads and installs a package from the AMD website.
.PARAMETER URL
The URL to download the package from.
#>
function Install-AmdPackage {
param(
[string] $URL
)
$dir = New-TemporaryDirectory;
$cookieBannerSelector = "#onetrust-consent-sdk";
$osSelector = "div[id$='oscategory']>div[id$='-0']";
$downloadSelector = "$osSelector div[id$='panel'] .button a";
$file = Start-CustomBrowserDownload @PSBoundParameters -OutDir $dir -Action {
param(
[OpenQA.Selenium.Firefox.FirefoxDriver] $Browser
)
$osContainer = $Browser.FindElement([OpenQA.Selenium.By]::CssSelector($osSelector));
if (-not ([bool] $osContainer.GetAttribute("cmp-expanded"))) {
$osContainer.Click();
}
$download = {
$browser.FindElement([OpenQA.Selenium.By]::CssSelector($downloadSelector)).Click();
};
try {
& $download;
} catch {
$null = $Browser.ExecuteScript("document.querySelector('$cookieBannerSelector').remove()");
& $download;
}
};
Start-Process -Wait -WorkingDirectory (Split-Path -Parent "$file") -FilePath "$file" -ArgumentList "/S";
Remove-Item -Recurse $dir;
}
function Start-SoftwareInstaller {
param(
[string] $Name,
[scriptblock] $Backup = $null,
[scriptblock] $Installer = $null,
[scriptblock] $Configurator = $null,
[scriptblock] $UserBackup = $null,
[scriptblock] $UserConfigurator = $null,
[Nullable[InstallerAction]] $Action,
[hashtable] $Arguments
)
[InstallerAction] $Action = & {
if ($null -ne $Action) {
$Action;
} else {
[InstallerAction]::Install;
}
};
if (-not $Name) {
$Name = Split-Path -Leaf (Split-Path -Parent ((Get-PSCallStack)[1].ScriptName));
}
Start-Operation {
if ($null -ne $Name) {
$Name = "``$Name``";
} else {
$Name = "unknown software";
}
$installHandler = {
param(
[InstallerAction] $Action,
[hashtable] $Arguments
)
$Arguments ??= @{ };
$argumentList = @{
installer = $installHandler;
arguments = $Arguments;
};
switch ($Action) {
([InstallerAction]::Backup) {
if ($Backup) {
Write-Host "Backing up $Name";
& $Backup @argumentList;
}
}
([InstallerAction]::Install) {
if ($Installer) {
Write-Host "Installing $Name";
& $Installer @argumentList;
}
& $installHandler @argumentList -Action ([InstallerAction]::Configure);
if ($UserConfigurator -and (-not (Test-SetupUser))) {
& $installHandler @argumentList -Action ([InstallerAction]::ConfigureUser);
}
}
([InstallerAction]::Configure) {
if ($Configurator) {
Write-Host "Configuring $Name";
& $Configurator @argumentList;
}
}
default {
if ((-not $Arguments.ContainsKey($userArgument)) -or (-not $Arguments[$userArgument])) {
$Arguments.Add($userArgument, ($IsWindows ? $env:UserName : $env:USER));
}
$user = $Arguments[$userArgument];
switch ($_) {
([InstallerAction]::BackupUser) {
if ($UserBackup) {
Write-Host "Backing up ``$Name`` for user ``$user``";
& $UserBackup @argumentList;
}
}
([InstallerAction]::ConfigureUser) {
if ($UserConfigurator) {
Write-Host "Configuring $Name for user ``$user``";
& $UserConfigurator @argumentList;
}
}
}
}
}
};
& $installHandler -Action $Action -Arguments $Arguments;
};
}
}

View file

@ -0,0 +1,121 @@
#!/bin/bash
function Install-SoftwarePackage($context, [string] $location, [string[]] $argumentList = @("/S"), [switch]$local) {
. "$PSScriptRoot/Context.ps1";
[Context]$context = $context;
[string]$filePath = "";
[string]$tempDir = $null;
if (-not ($local.IsPresent)) {
$tempDir = $context.GetTempDirectory();
Write-Information "Determining the file name of $location";
$fileName = ([uri]$location).Segments[-1];
Write-Information "$fileName";
$filePath = Join-Path $tempDir $fileName;
Write-Information "Downloading setup file from $location";
Invoke-WebRequest $location -OutFile $filePath;
} else {
$filePath = $location;
}
$fileName = [System.IO.Path]::GetFileName($filePath);
Write-Information "Starting installation of $fileName";
Start-Process -Wait -FilePath $filePath -ArgumentList $argumentList;
if ($tempDir) {
Remove-Item -Recurse $tempDir;
}
}
<#
.SYNOPSIS
Checks whether the specified package has been installed using Chocolatey.
.PARAMETER Name
The name of the package to check.
#>
function Test-ChocoPackage {
[OutputType([bool])]
param(
[string] $Name
);
-not [string]::IsNullOrEmpty((choco list --limit-output --exact $name));
}
<#
.SYNOPSIS
Checks whether a `winget` package with the specified id is installed.
.PARAMETER ID
The id of the package to check.
#>
function Test-WingetPackage {
[OutputType([bool])]
param(
[string] $Name,
[string[]] $ArgumentList
)
& { $null = winget list --accept-source-agreements -e --id $Name @ArgumentList; $?; };
}
<#
.SYNOPSIS
Checks whether a command with the specified name exists.
.PARAMETER Name
The name of the command to check.
#>
function Test-Command {
param (
[string] $Name
)
[bool] (Get-Command $Name -ErrorAction SilentlyContinue);
}
<#
.SYNOPSIS
Checks whether `winget` is working properly.
#>
function Test-Winget {
(Test-Command winget) -and (
& {
$output = winget source update winget;
$? -and -not ([System.Linq.Enumerable]::Any(
[string[]]($output),
[System.Func[string,bool]]{ param($line) $line -eq "Cancelled"; }));
});
}
<#
.SYNOPSIS
Checks whether a package with the specified name is installed.
.PARAMETER Name
The name of the package to check.
#>
function Test-PSPackage {
param(
[string] $Name
)
[bool] (Get-Package $Name -ErrorAction SilentlyContinue);
}
<#
.SYNOPSIS
Checks whether a module with the specified name is installed.
.PARAMETER Name
The name of the module to check.
#>
function Test-PSModule {
param(
[string] $Name
)
[bool](Get-Module -ListAvailable $Name -ErrorAction SilentlyContinue);
}

View file

@ -0,0 +1,68 @@
<#
.SYNOPSIS
Creates a new temporary directory.
#>
function New-TemporaryDirectory {
$path = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName());
New-Item -ItemType Directory $path;
}
<#
.SYNOPSIS
Removes desktop icons which apply to the specified pattern.
.PARAMETER Pattern
The pattern to match the icons to delete.
#>
function Remove-DesktopIcon {
param(
[string] $Pattern
)
$path = "Desktop/$Pattern";
foreach ($userDir in @("~", $env:PUBLIC, "$env:SystemDrive/Users/Default")) {
$fullName = "$userDir/$path";
if (Test-Path -PathType Leaf $fullName) {
Remove-Item $fullName;
}
}
}
<#
.SYNOPSIS
Adds a new shortcut to the start menu.
.PARAMETER Name
The name of the icon to create.
.PARAMETER Target
The file to link to.
#>
function Add-StartMenuIcon {
param(
[string] $Name,
[string] $Target
)
Import-Module KnownFolders;
Import-Module "$env:ChocolateyInstall/helpers/chocolateyInstaller.psm1";
Install-ChocolateyShortcut -ShortcutFilePath "$((Get-KnownFolder "Common Programs").Path)/$Name.lnk" -TargetPath ((Get-Item $Target).FullName);
}
<#
.SYNOPSIS
Removes icons from the task bar.
.PARAMETER Pattern
The pattern of the icon names to remove.
#>
function Remove-TaskbarItem {
param(
[string] $Pattern
)
Import-Module -UseWindowsPowerShell PinnedItem;
Get-PinnedItem -Type TaskBar | Where-Object { $_.Name -like "$Pattern" } | ForEach-Object { Remove-PinnedItem $_ };
}

View file

@ -1,15 +1,24 @@
#!/bin/env fish
function isConfigured -S
set -q "$CONFIG_MODULE"
set -q "$CONFIG_NAME"
end
function getProfiles -S
source "$(status dirname)/eval-flake.fish";
evalFlake "" "" --apply "builtins.attrNames" --json
end
function getConfig -S -a property
source "$(status dirname)/eval-module.fish"
evalModule "$CONFIG_MODULE" "$property" $argv[2..]
source "$(status dirname)/eval-flake.fish"
evalFlake "$CONFIG_NAME" "$property" $argv[2..]
end
function getAttributes -S -a property
getConfig "$property" --apply "builtins.attrNames" --json
end
function getUsers -S
getConfig valhalla.users --apply "builtins.attrNames" --json
getAttributes "valhalla.users"
end
function isSet -S -a property

View file

@ -0,0 +1,27 @@
#!/bin/env fish
function evalFlake --argument-names config property
set -l argv $argv[3..]
argparse --ignore-unknown "apply=" "json" -- $argv
if [ -z "$_flag_json" ]
set -a argv --raw
else
set -a argv --json
end
if [ -z "$_flag_apply" ]
set _flag_apply "_: _"
end
if [ -n "$config" ]
set config ".$config"
set _flag_apply "_: ($_flag_apply) ((import $(status dirname)/../../../lib/eval-attribute.nix) _)"
end
ROOT="$(realpath (status dirname))/../../.." \
PROPERTY="$property" \
nix eval --impure --extra-experimental-features "nix-command flakes" \
--apply "$_flag_apply" \
"$(status dirname)/../../..#valhalla$config" \
$argv
end

View file

@ -25,8 +25,10 @@ begin
end
for name in (echo "$users" | jq '.[]' --raw-output0 | string split0)
if [ "$name" != "$USER" ]
runInstaller userConfig "$name"
end
end
else if [ "$action" = "userConfig" ]
set -l name $argv[2]

View file

@ -14,7 +14,7 @@ then
UNPACKED_EXTENSION="${UNPACKED_EXTENSION}" \
EXTENSION_DIR="${EXTENSION_DIR}" \
EXTENSION_POLICY_DIR="${EXTENSION_POLICY_DIR}" \
bash "$BASH_SOURCE" "$USER";
bash --login "$BASH_SOURCE" "$USER";
else
keyFile="$UNPACKED_EXTENSION.pem";
extensionFile="$UNPACKED_EXTENSION.crx";

View file

@ -0,0 +1,57 @@
param (
$Action,
[hashtable] $Arguments
)
. "$PSScriptRoot/../aliae/Manage.ps1";
. "$PSScriptRoot/../PowerShell/Profile.ps1";
. "$PSScriptRoot/../../Scripts/Software.ps1";
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
Start-SoftwareInstaller @PSBoundParameters `
-Configurator {
Add-PowerShellProfileStatement `
-System `
-Category "oh-my-posh" `
-Script (
@(
"# Oh My Posh!",
(Get-ScriptInitializer "oh-my-posh init pwsh"),
(Get-ScriptInitializer "oh-my-posh completion powershell")
) -join [System.Environment]::NewLine)
} `
-UserConfigurator {
param(
[hashtable] $Arguments
)
$theme = Get-UserConfig "oh-my-posh.theme";
if ($theme) {
$varName = "POSH_THEME";
if ($theme -isnot [string]) {
$root = "$($IsWindows ? $env:AppData : "~/.config")/oh-my-posh";
$path = Join-Path $root "$($theme.name).omp.json";
$null = New-Item -Force -ItemType Directory $root;
Set-Content $path (
& {
if ($IsWindows) {
wsl cat $theme.source
} else {
cat $theme.source
}
});
$theme = [string] $path;
}
if ($IsWindows) {
[System.Environment]::SetEnvironmentVariable($varName, "%AppData%/$([System.IO.Path]::GetRelativePath($env:AppData, $path))", "User");
} else {
. "$PSScriptRoot/../aliae/Manage.ps1";
Add-EnvironmentVariable -User $Arguments.Name $varName ($path).Replace("~", "{{ .Home }}");
}
}
};

View file

@ -0,0 +1,43 @@
param (
$Action,
[hashtable] $Arguments
)
. "$PSScriptRoot/../../Scripts/Software.ps1";
. "$PSScriptRoot/../../Software/PowerShell/Profile.ps1";
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
Start-SoftwareInstaller @PSBoundParameters `
-Configurator {
[string] $globalDir = $null;
$indicator = "# Profile Files";
if (-not $IsWindows) {
$globalDir = '"/etc/powershell/conf.d"';
} else {
$globalDir = '"$env:ProgramData/PowerShell/conf.d"';
}
if (-not ((Test-Path -PathType Leaf $PROFILE) -and ((Get-Content $PROFILE) -contains $indicator))) {
Add-PowerShellProfileStatement `
-DefaultUser `
-Script (@(
$indicator,
"`$globalDir = $globalDir",
({
$profileRoot = Split-Path -Parent $PROFILE;
$profilePaths = @(
"$profileRoot/conf.d/*.ps1",
"$globalDir/*.ps1"
)
foreach ($profilePath in $profilePaths) {
if (Test-Path $profilePath) {
Get-Item $profilePath | ForEach-Object { . $_; };
}
}
}).ToString()) -join "`n") `
-Append;
}
};

View file

@ -0,0 +1,72 @@
. "$PSScriptRoot/../../Software/PowerShell/Profile.ps1";
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
$null = New-Module {
<#
.SYNOPSIS
Generates the components for creating a module installer.
.PARAMETER Name
The name of the module to install.
.PARAMETER NativeOnly
A value indicating whether the module is installed in Windows PowerShell only.
.PARAMETER NoProfile
A value indicating whether the module is not added to the profile script of users.
#>
function Get-ModuleInstallerComponents {
param(
[string] $Name,
[switch] $NativeOnly,
[switch] $NoProfile
)
@{
arguments = @{
name = $Name;
nativeOnly = $NativeOnly;
};
installer = {
param(
[scriptblock] $Installer,
[hashtable] $Arguments
)
$env:PENDING_MODULE_NAME = $Arguments.Name;
$installAction = {
$module = $env:PENDING_MODULE_NAME;
if (-not (Get-Module -ListAvailable $module -ErrorAction SilentlyContinue)) {
Install-Module -Scope AllUsers -Force $module @args;
}
};
if (-not $Arguments.NativeOnly) {
& $installAction -AcceptLicense;
}
if (Test-Command powershell) {
powershell -c ($installAction.ToString());
}
Remove-Item Env:\PENDING_MODULE_NAME;
& $Installer -Action ([InstallerAction]::Configure) @PSBoundParameters;
};
configurator = ($NoProfile.IsPresent) ? { } : {
param(
[hashtable] $Arguments
)
$name = $Arguments.Name;
Add-PowerShellProfileStatement `
-DefaultUser `
-Category $name `
-Script "Import-Module `"$name`";";
};
}
}
};

View file

@ -0,0 +1,123 @@
$null = New-Module {
. "$PSScriptRoot/../../Scripts/Scripting.ps1";
. "$PSScriptRoot/../../Scripts/Software.ps1";
<#
.SYNOPSIS
Adds an initialization script to the profile.
.PARAMETER System
A value indicating whether the script should be installed globally.
.PARAMETER DefaultUser
A value indicating whether the script should be installed to users by default.
.PARAMETER HomeDir
The path to the home directory of the user to install the script to.
.PARAMETER Category
The category name of the script to install.
.PARAMETER Script
The script to install.
.PARAMETER Replace
A value indicating whether the script should be replaced if it already exists.
.PARAMETER Append
A value indicating whether the content should be appended to the script if it already exists.
#>
function Add-PowerShellProfileStatement {
param(
[Parameter(ParameterSetName = "Global", Mandatory)]
[switch] $System,
[Parameter(ParameterSetName = "DefaultUser", Mandatory)]
[switch] $DefaultUser,
[Parameter(ParameterSetName = "Home")]
[string] $HomeDir = "~",
[Parameter(ParameterSetName = "Global", Mandatory)]
[Parameter(ParameterSetName = "DefaultUser")]
[Parameter(ParameterSetName = "Home")]
[string] $Category = $null,
[Parameter(Position = 0, Mandatory)]
[string] $Script,
[switch] $Replace,
[switch] $Append
)
[System.Collections.ArrayList] $profiles = @();
if ($System) {
[string] $configRoot = $null;
if ($IsWindows) {
# ToDo Change to "PowerShell"
$configRoot = "$env:ProgramData";
} else {
$configRoot = "/etc";
}
$profiles = @("$configRoot/powershell/.");
} else {
if ($DefaultUser) {
if (-not $IsWindows) {
$HomeDir = "/etc/skel";
} else {
$HomeDir = "C:/Users/Default";
}
}
foreach ($shell in @("pwsh", "powershell")) {
if (Test-Command $shell) {
$null = $profiles.Add((& $shell -NoProfile -c '$PROFILE'));
}
}
Push-Location ~;
$profiles = @(
$profiles |
ForEach-Object { [System.IO.Path]::GetRelativePath((Get-Location), $_) } |
ForEach-Object { "$HomeDir/$_" }
);
Pop-Location;
}
if ($Category) {
$profiles = @($profiles | ForEach-Object { Join-Path (Split-Path -Parent $_) "conf.d" "$Category.ps1" });
}
$profiles | ForEach-Object {
$arguments = @{};
if ($Replace.IsPresent) {
$null = $arguments.Add("Replace", $Replace);
}
if ($Append.IsPresent) {
$null = $arguments.Add("Append", $Append);
}
Write-PSScript @arguments `
-FileName $_ `
-Script $Script;
};
}
<#
.SYNOPSIS
Creates an eval-script using the `[scriptblock]::Create` method.
.PARAMETER Initializer
The code to evaluate.
#>
function Get-ScriptInitializer {
param (
[Parameter(Position=0, Mandatory=$true)]
$Initializer
)
return ". ([scriptblock]::Create(($Initializer) -join `"``n`"))";
}
};

View file

@ -0,0 +1,15 @@
param (
$Action,
[hashtable] $Arguments
)
. "$PSScriptRoot/../PowerShell/Module.ps1";
. "$PSScriptRoot/../../Scripts/Software.ps1";
$parameters = Get-ModuleInstallerComponents "Terminal-Icons";
foreach ($key in $PSBoundParameters.Keys) {
$parameters.Add($key, $PSBoundParameters[$key]);
}
Start-SoftwareInstaller @parameters;

View file

@ -14,5 +14,9 @@ begin
end
end
function userConfig -a name
sudo usermod -aG libvirt "$name"
end
runInstaller $argv
end

View file

@ -0,0 +1,15 @@
<#
.SYNOPSIS
Gets a powershell expression which points to the global `aliae` configuration.
#>
function Get-GlobalConfigExpression {
return "`"$($IsWindows ? "`$env:ProgramData" : "/etc")/aliae/aliae.yml`"";
}
<#
.SYNOPSIS
Gets the path to the global `aliae` configuration.
#>
function Get-GlobalConfigPath {
return & ([scriptblock]::Create((Get-GlobalConfigExpression)));
}

View file

@ -0,0 +1,50 @@
param(
$Action,
[hashtable] $Arguments
)
. "$PSScriptRoot/Constants.ps1";
. "$PSScriptRoot/../PowerShell/Profile.ps1";
. "$PSScriptRoot/../../Scripts/Software.ps1";
Start-SoftwareInstaller @PSBoundParameters `
-Configurator {
. "$PSScriptRoot/Constants.ps1";
$pathExpression = Get-GlobalConfigExpression;
$path = Get-GlobalConfigPath;
$null = New-Item -Force -ItemType Directory (Split-Path -Parent $path);
Copy-Item -Force "$PSScriptRoot/aliae.yml" $path;
Add-PowerShellProfileStatement `
-System `
-Category "aliae" `
-Script (
@(
{
#aliae
},
"`$globalPath = $pathExpression",
{
$userPath = & {
if ($env:ALIAE_CONFIG) {
$env:ALIAE_CONFIG;
} else {
"~/.aliae.yaml";
}
};
if (Test-Path $globalPath) {
$null = & ([scriptblock]::Create((aliae init pwsh --config $globalPath))) *>&1;
}
if (Test-Path $userPath) {
$null = & ([scriptblock]::Create((aliae init pwsh))) *>&1;
}
aliae completion powershell | Out-String | Invoke-Expression;
}
) -join [System.Environment]::NewLine)
} `
-UserConfigurator {
Copy-Item -Force "$PSScriptRoot/aliae.yml" ~/.aliae.yml;
};

View file

@ -0,0 +1,98 @@
$null = New-Module {
. "$PSScriptRoot/Constants.ps1";
<#
.SYNOPSIS
Adds an alias to an existing `aliae` configuration.
.PARAMETER Name
The name of the alias to add.
.PARAMETER Value
The script the alias should point to.
.PARAMETER User
The user to add the alias to.
#>
function Add-Alias {
param(
[string] $Name,
[string] $Value,
[string] $User
)
Edit-Config `
-Variables @{
Name = "$Name";
Value = "$Value";
} `
".alias |= [((. // [])[] | select(.name != env.Name))] + [{ name: env.Name, value: env.Value }]" `
-User $User;
}
<#
.SYNOPSIS
Adds an environment variable to an existing `aliae` configuration.
.PARAMETER Name
The name of the variable to add.
.PARAMETER Value
The value of the variable.
#>
function Add-EnvironmentVariable {
param(
[string] $Name,
[string] $Value,
[string] $User
)
Edit-Config `
-Variables @{
Name = "$Name";
Value = "$Value";
} `
".env |= [((. // [])[] | select(.name != env.Name))] + [{ name: env.Name, value: env.Value }]" `
-User $User;
}
<#
.SYNOPSIS
Edits the underlying `aliae` configuration.
.PARAMETER Script
The yq script to run over the configuration.
.PARAMETER User
The user to edit the configuration for.
#>
function Edit-Config {
param(
[string] $Script,
[hashtable] $Variables,
[string] $User
)
if ($User) {
$path = "$($IsWindows ? "~" : "$(sudo -u $User bash -c "realpath ~")")/.aliae.yaml";
} else {
$path = Get-GlobalConfigPath;
}
Start-Job {
$file = New-TemporaryFile;
$variables = $using:Variables;
foreach ($key in $variables.Keys) {
Set-Item "Env:\$key" $variables[$key];
}
sudo -u $using:User cp $using:path $file;
yq -yi $using:Script $file;
sudo -u $using:User cp $file $using:path;
Remove-Item $file;
} | Receive-Job -Wait;
}
Export-ModuleMember -Function Add-Alias,Add-EnvironmentVariable;
};

View file

@ -1,22 +1,4 @@
alias:
- name: totsch
value: git
env:
- name: POSH_THEME
value: '{{ if eq .OS "windows" }}{{ .Home }}/Nextcloud/.omp{{ else }}/usr/local/share/oh-my-posh/themes{{ end }}/manuel.omp.json'
alias: []
env: []
path: []
script:
- value: |
# Profile Files
$profileRoot = Split-Path -Parent $PROFILE;
$profilePaths = @(
"$profileRoot/conf.d/*.ps1",
"{{ if eq .OS "windows" }}$env:ProgramData{{ else }}/etc{{ end }}/powershell/conf.d/*.ps1"
);
foreach ($profilePath in $profilePaths) {
if (Test-Path $profilePath) {
Get-Item $profilePath | ForEach-Object { . $_; };
}
}
if: match .Shell "pwsh"
script: []

View file

@ -10,28 +10,35 @@ begin
function configureSW -V dir
source "$dir/../bash/profile.fish"
source "$dir/../fish/profile.fish"
set -l file /etc/aliae/aliae.yml
echo "export ALIAE_CONFIG=$(string escape "$file")" | sudo tee /etc/profile.d/aliae.sh
set -l file (pwsh -CommandWithArgs '. $args[0]; Get-GlobalConfigPath' "$dir/Constants.ps1");
sudo install -Dm644 "$dir/aliae.yml" "$file"
begin
printf %s\n \
"# aliae" \
"if [ -f $(string escape $file) ]" \
'then' \
" eval \"\$(aliae init bash --config $(string escape $file))\"" \
'fi' \
'' \
'if [ -n "$ALIAE_CONFIG" ] && [ -f "$ALIAE_CONFIG" ] || [ -f ~/.aliae.yaml ]' \
'then' \
' eval "$(aliae init bash)"' \
'fi' \
'' \
'eval "$(aliae completion bash)"'
end | installBashProfile "aliae" "aliae"
begin
printf %s\n "" \
"# aliae" \
'eval "$(aliae init bash)"' \
'eval "$(aliae completion bash)"'
end | sudo tee /etc/skel/.bashrc > /dev/null
if type -q fish
begin
printf %s\n \
"aliae init fish | source" \
"if [ -f $(string escape $file) ]" \
" eval \"\$(aliae init bash --config $(string escape $file))\"" \
'end' \
'' \
'if [ -n "$ALIAE_CONFIG" ] && [ -f "$ALIAE_CONFIG" ] || [ -f ~/.aliae.yaml ]' \
' aliae init fish | source' \
'end' \
'' \
"aliae completion fish | source"
end | installFishProfile "aliae" "aliae"
end

View file

@ -17,12 +17,22 @@ begin
if type -q "$bins[$i]"
set bin "$bins[$i]"
set extensionRoot "$extensionRoots[$i]"
break
end
end
BROWSER_BIN="$bin" \
EXTENSION_POLICY_DIR="$braveExtensions" \
EXTENSION_POLICY_DIR="$extensionRoot" \
bash "$dir/../Chromium/ytmdl.sh"
for i in (seq (count $bins))
if [ "$extensionRoots[$i]" != "$extensionRoot" ]
if [ -d "$extensionRoots[$i]" ]
sudo rm -rf "$extensionRoots[$i]"
sudo ln -s "$extensionRoot" "$extensionRoots[$i]"
end
end
end
end
runInstaller $argv

View file

@ -0,0 +1,113 @@
param (
$Action,
[hashtable] $Arguments
)
. "$PSScriptRoot/../../Scripts/Software.ps1";
. "$PSScriptRoot/../../Scripts/System.ps1";
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
$null = New-Module {
param(
[hashtable] $Parameters
)
$configure = {
param(
[string] $User
)
$root = "valhalla";
if ($User) {
$root = "$root$($IsWindows ? ".windows" : '').users.$User";
$sudoArgs = @("-u", $User);
$configArgs = @("--global");
} else {
$sudoArgs = @();
$configArgs = @("--system");
}
$config = Get-Config "$root.git";
<#
.SYNOPSIS
Sets a configuration option in git.
#>
function Set-GitConfig {
sudo @sudoArgs git config @configArgs $args;
}
if ((-not $IsWindows) -or $User) {
$branch = $config.defaultBranch;
if ($branch) {
Set-GitConfig "init.defaultBranch" $branch;
}
}
if ($User) {
$displayName = Get-UserConfig "displayName";
$mailAddress = Get-UserConfig "mailAddress";
if ($displayName) {
Set-GitConfig "user.name" $displayName;
}
if ($mailAddress) {
Set-GitConfig "user.email" $mailAddress;
}
}
# Git Flow
. {
$dir = New-TemporaryDirectory;
$key = "flow";
$mainBranch = $config."$key".mainBranch;
$devBranch = $config."$key".devBranch;
& {
git -C "$dir" init;
git -C "$dir" config user.name "PortValhalla";
git -C "$dir" config user.email "no-reply@valhal.la";
git -C "$dir" commit --allow-empty -m "Initial commit";
git -C "$dir" branch master;
git -C "$dir" branch dev;
git -C "$dir" flow init --defaults;
} | Out-Null;
if ($mainBranch) {
git -C "$dir" branch $mainBranch | Out-Null;;
sudo @sudoArgs git -C "$dir" flow config set @configArgs master $mainBranch;
}
if ($devBranch) {
git -C "$dir" branch $devBranch | Out-Null;
sudo @sudoArgs git -C "$dir" flow config set @configArgs develop $devBranch;
}
Remove-Item -Recurse -Force $dir;
};
# Aliases
[PSCustomObject] $aliases = $config.aliases;
if ($aliases) {
foreach ($alias in ($aliases | Get-Member -MemberType Properties)) {
Set-GitConfig "alias.$($alias.Name)" $aliases.$($alias.Name);
}
}
};
Start-SoftwareInstaller @Parameters `
-Configurator {
& $configure @PSBoundParameters;
} `
-UserConfigurator {
param(
[hashtable] $Arguments
)
& $configure -User $Arguments.Name;
};
} $PSBoundParameters;

Some files were not shown because too many files have changed in this diff Show more